@seatlayer/core 0.92.1 → 0.93.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 (106) hide show
  1. package/dist/ar-ALH3NJ5S.js +1 -0
  2. package/dist/be-L2ARGVAN.js +1 -0
  3. package/dist/bg-7664YNCK.js +1 -0
  4. package/dist/ca-FAFWDJLI.js +1 -0
  5. package/dist/{chunk-6FTHCEJW.js → chunk-A3ZL3R75.js} +1 -1
  6. package/dist/{chunk-S4H34KCG.js → chunk-CEIVHWRB.js} +1 -1
  7. package/dist/chunk-F7TP67LK.js +1 -0
  8. package/dist/{chunk-NKJS7MLW.js → chunk-M5X6G7FD.js} +1 -1
  9. package/dist/{chunk-K42NW62J.js → chunk-O3DGXAIC.js} +1 -1
  10. package/dist/{chunk-TXF2XAK4.js → chunk-TKYTTEJ2.js} +1 -1
  11. package/dist/{chunk-LQKUHEL6.js → chunk-U7CVRE4P.js} +1 -1
  12. package/dist/chunk-ZDETFCDH.js +1 -0
  13. package/dist/{chunk-NRZY5UXV.js → chunk-ZFWHAKAI.js} +1 -1
  14. package/dist/core/chart-ops/index.cjs +1 -1
  15. package/dist/core/chart-ops/index.js +1 -1
  16. package/dist/core/inventory/index.cjs +1 -1
  17. package/dist/core/inventory/index.js +1 -1
  18. package/dist/core/layout/index.cjs +1 -1
  19. package/dist/core/layout/index.d.cts +1 -1
  20. package/dist/core/layout/index.d.ts +1 -1
  21. package/dist/core/layout/index.js +1 -1
  22. package/dist/core/sections/index.cjs +1 -1
  23. package/dist/core/sections/index.js +1 -1
  24. package/dist/cs-X2R3ZSIS.js +1 -0
  25. package/dist/cy-TZAP42PI.js +1 -0
  26. package/dist/da-TXXYTHRV.js +1 -0
  27. package/dist/de-QTBBGD7H.js +1 -0
  28. package/dist/el-D5FP7YYV.js +1 -0
  29. package/dist/es-WBASDRVC.js +1 -0
  30. package/dist/et-DI4AFGPJ.js +1 -0
  31. package/dist/fa-475UAFRJ.js +1 -0
  32. package/dist/fi-VLWI3PVM.js +1 -0
  33. package/dist/fr-RIEQP5R4.js +1 -0
  34. package/dist/he-LMIQFGT5.js +1 -0
  35. package/dist/hr-HWWXJXMT.js +1 -0
  36. package/dist/hu-EGRPKEMV.js +1 -0
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.d.cts +26 -2
  39. package/dist/index.d.ts +26 -2
  40. package/dist/index.js +1 -1
  41. package/dist/it-QU2BONLV.js +1 -0
  42. package/dist/ja-GTPGN7AW.js +1 -0
  43. package/dist/ku-Q3XMN7GH.js +1 -0
  44. package/dist/localeLoaders-X2DDK7KL.js +1 -0
  45. package/dist/lt-ZGTEWYU4.js +1 -0
  46. package/dist/lv-3SV4YW2L.js +1 -0
  47. package/dist/nl-ALCHLVP2.js +1 -0
  48. package/dist/no-WRBQJCLX.js +1 -0
  49. package/dist/pl-4G6VEQZ3.js +1 -0
  50. package/dist/pt-OLA6ELAW.js +1 -0
  51. package/dist/ro-H5GU4DVI.js +1 -0
  52. package/dist/ru-BM3TYI5V.js +1 -0
  53. package/dist/sk-VU45GJYV.js +1 -0
  54. package/dist/sl-SYNAWIPU.js +1 -0
  55. package/dist/sr-6ZNE7HDN.js +1 -0
  56. package/dist/sv-52BO3IXQ.js +1 -0
  57. package/dist/{tableSizing-DUSD6Ksr.d.cts → tableSizing-Blb9Z_Tt.d.cts} +13 -1
  58. package/dist/{tableSizing-D7dXthik.d.ts → tableSizing-DmZYe2v2.d.ts} +13 -1
  59. package/dist/tr-SZJCCTGR.js +1 -0
  60. package/dist/uk-OSWQK4LA.js +1 -0
  61. package/dist/view3d/index.cjs +25 -25
  62. package/dist/view3d/index.js +1 -1
  63. package/dist/view3d/scene/scene.worker.cjs +1 -1
  64. package/dist/view3d/scene/scene.worker.js +1 -1
  65. package/dist/zh-Hans-JK2SPHB6.js +1 -0
  66. package/dist/zh-Hant-BYGBT56E.js +1 -0
  67. package/package.json +1 -1
  68. package/dist/ar-LFWD2QGQ.js +0 -1
  69. package/dist/be-EY5C4G3N.js +0 -1
  70. package/dist/bg-6K4MZR3F.js +0 -1
  71. package/dist/ca-EGP235FX.js +0 -1
  72. package/dist/chunk-D5ZLXZYU.js +0 -1
  73. package/dist/chunk-F45ZMLCU.js +0 -1
  74. package/dist/cs-ORLEKMIX.js +0 -1
  75. package/dist/cy-SOQ75PTT.js +0 -1
  76. package/dist/da-BQXNFQLH.js +0 -1
  77. package/dist/de-7NCFMKDX.js +0 -1
  78. package/dist/el-JRLNLFPD.js +0 -1
  79. package/dist/es-455FQSU3.js +0 -1
  80. package/dist/et-IZPVLXOT.js +0 -1
  81. package/dist/fa-7KW5P7GS.js +0 -1
  82. package/dist/fi-3GCPHLRX.js +0 -1
  83. package/dist/fr-JE2JHWLO.js +0 -1
  84. package/dist/he-SNAWKC2D.js +0 -1
  85. package/dist/hr-FBMQPEHL.js +0 -1
  86. package/dist/hu-5FA6YSLJ.js +0 -1
  87. package/dist/it-G7TVMSBG.js +0 -1
  88. package/dist/ja-XXFS7KXR.js +0 -1
  89. package/dist/ku-XNGWDNKF.js +0 -1
  90. package/dist/localeLoaders-KBBW44XO.js +0 -1
  91. package/dist/lt-UCSVRFCM.js +0 -1
  92. package/dist/lv-X4XMSWYY.js +0 -1
  93. package/dist/nl-5JRN5T6V.js +0 -1
  94. package/dist/no-LVSMOB3V.js +0 -1
  95. package/dist/pl-DQDXCKWT.js +0 -1
  96. package/dist/pt-5TKDH5QJ.js +0 -1
  97. package/dist/ro-2YAMHGG7.js +0 -1
  98. package/dist/ru-N5NY4PAA.js +0 -1
  99. package/dist/sk-KM77X2PZ.js +0 -1
  100. package/dist/sl-YSUPL47R.js +0 -1
  101. package/dist/sr-E75S6KSN.js +0 -1
  102. package/dist/sv-EXVTCWZ6.js +0 -1
  103. package/dist/tr-TPKRTGQO.js +0 -1
  104. package/dist/uk-TAQIY6K6.js +0 -1
  105. package/dist/zh-Hans-FP67ACQK.js +0 -1
  106. package/dist/zh-Hant-54CHKXAP.js +0 -1
@@ -1 +1 @@
1
- "use strict";var Wo=Object.create;var Ne=Object.defineProperty;var Zo=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var or=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of er(t))!nr.call(e,i)&&i!==n&&Ne(e,i,{get:()=>t[i],enumerable:!(o=Zo(t,i))||o.enumerable});return e};var rr=(e,t,n)=>(n=e!=null?Wo(tr(e)):{},en(t||!e||!e.__esModule?Ne(n,"default",{value:e,enumerable:!0}):n,e)),ir=e=>en(Ne({},"__esModule",{value:!0}),e);var Us={};or(Us,{COLORBLIND_SAFE_PALETTE:()=>Kt,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>_t,DEFAULT_SECTION_CORNER_SMOOTHING:()=>wt,MAX_BUYER_IMAGE_URL_LENGTH:()=>Rr,MAX_FLOOR_BASE_HEIGHT_M:()=>Ye,addArcFanRows:()=>_a,addBookableGridArray:()=>os,addBoothArray:()=>Fa,addChartCategory:()=>co,addChartFloor:()=>ei,addChartZone:()=>ri,addGAArea:()=>Ea,addRowBlock:()=>ja,addTableArray:()=>Ta,applyPolygonHole:()=>zi,applyReferenceScanRows:()=>ts,applySectionCornerSmoothing:()=>Wi,applySectionOutlineShaping:()=>Zn,applySectionRowFit:()=>$i,approveConfidenceEvidence:()=>Bs,arcFanInputForGroup:()=>fo,assignSectionInventoryCategory:()=>Vi,automaticPlacementCenter:()=>Ca,clearConfidenceEvidence:()=>$s,compactChartDoc:()=>zr,compactRowOverrides:()=>An,compactTableOverrides:()=>Mn,confidenceEvidenceChangeRequiresPublish:()=>Es,confidenceEvidenceChanges:()=>Jo,confirmReferenceCategoryOutputColor:()=>sa,convertGeneratedSectionToPolygon:()=>qi,countCoveredInventory:()=>tt,detectSeatLabelRun:()=>Pn,dropRedundantSeatOverrideFields:()=>He,familyCategoryLabel:()=>lo,gaAreaFootprint:()=>ho,groupRowsAsSegmented:()=>Na,insertSeatingBlock:()=>Fi,isSafeBuyerImageUrl:()=>pn,joinGAAreas:()=>Ps,mergeRows:()=>ms,mirrorFirstFloor:()=>_e,normalizeBuyerImageUrl:()=>ee,normalizeDraftEvidence:()=>Xo,parseSeatRefId:()=>as,pickColorblindSafeCategoryColor:()=>so,planCreationCategory:()=>uo,previewArcFanRows:()=>$t,previewBookableGridArray:()=>ns,previewGeneratedSectionPolygonConversion:()=>Qn,previewJoinGAAreas:()=>Rs,previewPolygonHole:()=>ot,previewRemovePolygonHole:()=>qn,previewRowCubicPath:()=>Hn,previewSectionRowFit:()=>Vn,reassignColorblindSafeCategoryColors:()=>aa,relabelChartRows:()=>Ti,removeChartCategory:()=>wa,removeChartFloor:()=>oi,removeChartObjects:()=>ki,removeChartZone:()=>ai,removePolygonHole:()=>Ui,renameChartFloor:()=>ti,renameDirectSeatImportCategory:()=>na,reorderChartCategories:()=>oa,replaceArcFanRows:()=>Aa,replaceRowBlock:()=>Ka,resetSeatOverrides:()=>ls,resizeShapes:()=>As,resolveCreationCategory:()=>pa,retractConfidenceEvidence:()=>zs,roundBuyerCoordinates:()=>Hr,seatRefId:()=>Ee,seatSemanticsSignature:()=>It,sectionInventorySelectionSummary:()=>Yn,setConfidenceEvidence:()=>Ks,setRowBlockSpacing:()=>Ss,splitRow:()=>ws,straightenAndSpaceRows:()=>xs,transformSectionBoundary:()=>Xi,transformSectionBoundaryObject:()=>Wn,ungroupSegmentedRow:()=>Da,updateBooths:()=>ji,updateCategoryDefinitions:()=>ao,updateChartFloorBaseHeight:()=>ni,updateChartTheme:()=>va,updateChartZones:()=>ii,updateGAAreas:()=>Li,updateRowCubicPath:()=>Di,updateRows:()=>ds,updateSeatOverrides:()=>Jt,updateSectionExactPath:()=>Yi,updateSectionMetadata:()=>Ji,updateSegmentedRow:()=>Ga,updateShapes:()=>_s,updateStageKinds:()=>Ms,updateTables:()=>Mi,updateTextObjects:()=>Ei,updateViewFromSeatFallback:()=>Ia});module.exports=ir(Us);var tn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function ar(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/tn(e))),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 nn(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*tn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=ar(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var Js=Math.PI/180;function D(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function ht(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function on(e,t){let n=1-t,o=n*n*n,i=3*n*n*t,a=3*n*t*t,r=t*t*t;return{x:o*e.start.x+i*e.control1.x+a*e.control2.x+r*e.end.x,y:o*e.start.y+i*e.control1.y+a*e.control2.y+r*e.end.y}}function De(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[on(e,.5)];let o=Array.from({length:n+1},(c,l)=>on(e,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:t},()=>({...e.start}));let r=[],s=1;for(let c=0;c<t;c+=1){let l=a*c/(t-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 xe(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 ve(e,t,n){return Math.max(t,Math.min(n,e))}function sr(e){return ve(e,0,1)}function rn(e){let t=sr(e);return t*t*(3-2*t)}var ie=Math.PI*2;function ae(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function cr(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ie;for(;o>=ie;)o-=ie}else{for(;o>0;)o-=ie;for(;o<=-ie;)o+=ie}return o}function Ge(e){if(e.version!==1||e.closed!==!0||!ae(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||!ae(n.end))return!1;if(n.kind==="line"){if(D(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!ae(n.control1)||!ae(n.control2)||D(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!ae(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(D(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(D(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||D(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return D(t,e.start)<=1e-4}function lr(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 yt(e,t=2){if(!Ge(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.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=cr(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=D(i,a.control1)+D(a.control1,a.control2)+D(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let c=1;c<=s;c+=1)o.push(lr(i,a,c/s))}i=a.end}return D(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function cn(e,t,n){return mt(e,i=>({x:i.x+t,y:i.y+n}))}function mt(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(i=>i.kind==="line"?{...i,end:t(i.end)}:i.kind==="arc"?{...i,center:t(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:t(i.end)}:{...i,control1:t(i.control1),control2:t(i.control2),end:t(i.end)})}}var wt=45,pt=150,dr=60;function ur(e){let t=wt/100;if(e<=t)return pt;let n=Math.min(1,(e-t)/(1-t));return pt-n*(pt-dr)}var an=.5523;function sn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function fr(e){let t=[],n=[];for(e.forEach((o,i)=>{ae(o)&&(t.length&&sn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&sn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var gr=.5,br=4/3;function hr(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,s=o/a,c=n*br;return{kind:"bezier",control1:{x:e.x+o/3+r*c,y:e.y+i/3+s*c},control2:{x:e.x+o*2/3+r*c,y:e.y+i*2/3+s*c},end:{...t}}}function ln(e,t){let{points:n,sourceIndex:o}=fr(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let S=0;S<i;S+=1){let x=r[o[S]];s[S]=Number.isFinite(x)?Math.min(100,Math.max(-100,x))/100:0}let c=s.some(S=>Math.abs(S)>1e-6);if(a<=0&&!c)return null;let l=t.wideAngleThresholdDeg??ur(a),d=[];for(let S=0;S<i;S+=1)d[S]=D(n[S],n[(S+1)%i]);let g=new Array(i).fill(0);for(let S=0;S<i;S+=1){let x=n[(S-1+i)%i],v=n[S],P=n[(S+1)%i],N={x:x.x-v.x,y:x.y-v.y},G={x:P.x-v.x,y:P.y-v.y},K=Math.hypot(N.x,N.y),$=Math.hypot(G.x,G.y);if(K<=1e-9||$<=1e-9)continue;let R=Math.min(1,Math.max(-1,(N.x*G.x+N.y*G.y)/(K*$))),z=Math.acos(R)*180/Math.PI;if(z<l)continue;let A=rn((z-l)/(180-l));g[S]=a*A*.5*Math.min(K,$)}for(let S=0;S<i;S+=1){let x=(S+1)%i,v=g[S]+g[x];if(v>d[S]&&v>1e-9){let P=d[S]/v;g[S]*=P,g[x]*=P}}let b=new Array(i),f=new Array(i);for(let S=0;S<i;S+=1){let x=n[(S-1+i)%i],v=n[S],P=n[(S+1)%i];if(g[S]<=1e-6){b[S]={...v},f[S]={...v};continue}let N=D(v,x)||1,G=D(v,P)||1;b[S]={x:v.x+(x.x-v.x)/N*g[S],y:v.y+(x.y-v.y)/N*g[S]},f[S]={x:v.x+(P.x-v.x)/G*g[S],y:v.y+(P.y-v.y)/G*g[S]}}if(g.every(S=>S<=1e-6)&&!c)return null;let y=[],m={...f[0]},w=m,I=(S,x)=>{if(D(w,S)<=1e-9)return;let v=s[x];Math.abs(v)>1e-6?y.push(hr(w,S,v*gr*d[x])):y.push({kind:"line",end:{...S}}),w=S};for(let S=1;S<=i;S+=1){let x=S%i,v=n[x];I(b[x],(S-1)%i),g[x]>1e-6&&D(b[x],f[x])>1e-9&&(y.push({kind:"bezier",control1:ht(b[x],v,an),control2:ht(f[x],v,an),end:{...f[x]}}),w=f[x])}if(!y.length)return null;let h=y[y.length-1];D(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:y.push({kind:"line",end:{...m}}));let p={version:1,closed:!0,start:m,segments:y};return Ge(p)?p:null}var dn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",pr="ABCDEFGHJKLMNPQRSTUVWXYZ",yr="abcdefghijklmnopqrstuvwxyz";function un(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function mr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?pr:dn;return un(o,i)}function St(e,t=!1){let n=t?yr:dn;return un(Math.max(0,Math.floor(e)-1),n)}var wr=[[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 fn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of wr)for(;t>=o;)n+=i,t-=o;return n}function gn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:mr(a,t)}})}function Sr(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 se(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,c=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(c/2),y=a==="updown"?t<f?n+2*t:n-1+2*(c-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${y}`}let l=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(c-1)*l:n,g=o==="center"?Sr(c)[t]:o==="rtl"?c-1-t:t,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=fn(d+g*i);break;case"letters-upper":b=St(d+g*i,!1);break;case"letters-lower":b=St(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function xr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Y(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${se(e,t)}`}function Ie(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return se(e,t);if(!n)return`${e.displayLabel||e.label}-${se(e,t)}`;let i=xr(n),a=n.displayOffset+t;return`${n.displayLabel}-${se(i,a)}`}var bn=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."}];var vr=Math.PI*2;function Ir(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function hn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,s=Math.cos(r),c=Math.sin(r),l=i/2,d=a/2,g=[],b=(f,y)=>{g.push({x:f,y})};switch(t){case"rect":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rounded":{let f=Math.min(i,a)*.18,y=5,m=(w,I,h)=>{for(let p=0;p<=y;p++){let S=h+p/y*(Math.PI/2);b(w+f*Math.cos(S),I+f*Math.sin(S))}};m(l-f,-d+f,-Math.PI/2),m(l-f,d-f,0),m(-l+f,d-f,Math.PI/2),m(-l+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-l,-d),b(l,-d);let y=24;for(let m=0;m<=y;m++){let w=m/y,I=l-w*i,h=d+f*(1-Math.pow(2*I/i,2));b(I,h)}break}case"thrust":{let f=i*.18,y=a*1.1;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-l,d);break}case"runway":{let f=i*.1,y=a*3;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-l,d);break}case"round":case"oval-cricket":{for(let y=0;y<40;y++){let m=y/40*vr;b(l*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rink-hockey":{for(let f of Cr(l,d,l*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of Or(l,d))b(f.x,f.y);break}}return g.map(f=>Ir(f.x,f.y,s,c,n,o))}function Cr(e,t,n,o){let i=[],r=(s,c,l)=>{for(let d=0;d<=8;d++){let g=l+d/8*(Math.PI/2);i.push({x:s+n*Math.cos(g),y:c+o*Math.sin(g)})}};return r(e-n,-t+o,-Math.PI/2),r(e-n,t-o,0),r(-e+n,t-o,Math.PI/2),r(-e+n,-t+o,Math.PI),i}function Or(e,t){let n=Math.max(0,e-t),o=[],i=20;for(let a=0;a<=i;a++){let r=-Math.PI/2+a/i*Math.PI;o.push({x:n+t*Math.cos(r),y:t*Math.sin(r)})}for(let a=0;a<=i;a++){let r=Math.PI/2+a/i*Math.PI;o.push({x:-n+t*Math.cos(r),y:t*Math.sin(r)})}return o}var Rr=2e6,Pr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,_r=/[\s"'<>`\\]/;function pn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Pr.test(e);if(_r.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ee(e){let t=e.trim();return pn(t)?t:null}function Ce(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var $e=Math.PI/180,Ar=9,ce=16;function vt(e,t,n,o){let i=n*$e,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function le(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return De(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let l=0;l<t;l++)r.push(vt(l*n,0,i,a));return r}let s=o/(t-1)*$e,c=n/(2*Math.sin(Math.abs(s)/2));for(let l=0;l<t;l++){let d=l*s,g=c*Math.sin(d),b=-c+c*Math.cos(d);r.push(vt(g,b,i,a))}return r}function wn(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Mr(e,t){let n=wn(e);return le(e).map((o,i)=>{let a=n.get(i),r=Ce(a),s=Y(e,i,a),c={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Ie(e,i,t,a),categoryKey:a?.categoryKey??e.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,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function H(e){let t=[];for(let n of Mr(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function jr(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(e.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function Lr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let y=o.get(d),m=Ce(y),w=y?.label??`${e.label}-${d+1}`,I=e.displayLabel??e.label;return{index:d,label:w,displayLabel:y?.displayLabel??`${I}-${d+1}`,x:g+(y?.dx??0),y:b+(y?.dy??0),categoryKey:y?.categoryKey??e.categoryKey,skipped:!!y?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:y?.wheelchairSpaceType,commercial:y?.commercial,glyph:y?.glyph,viewUrl:y?.viewFromSeatUrl,viewMeta:y?.viewFromSeatUrl?y.viewFromSeatMeta:void 0,labelStyle:y?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+ce,g=e.rotation*$e,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let w=0;w<n;w++){let I=g+w/n*2*Math.PI;t.push(i(w,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let f=b*$e,y=(2*Math.PI-f)/2,m=g+y;for(let w=0;w<n;w++){let I=m+w/(n-1)*f;t.push(i(w,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,r=e.height??50,s=jr(e),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,y;d==="top"?(f=-a/2+(b+.5)*a/g,y=-r/2-ce):d==="bottom"?(f=-a/2+(b+.5)*a/g,y=r/2+ce):d==="left"?(f=-a/2-ce,y=-r/2+(b+.5)*r/g):(f=a/2+ce,y=-r/2+(b+.5)*r/g);let m=vt(f,y,e.rotation,e.center);t.push(i(l++,m.x,m.y,d))}}return t}function te(e){return Lr(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Sn(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 yn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,s=t[i].x,c=t[i].y;r>e.y!=c>e.y&&e.x<(s-a)*(e.y-r)/(c-r)+a&&(n=!n)}return n}function kr(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.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 F(e,t,n){return yn(e,t)&&!(n??[]).some(o=>yn(e,o)||kr(e,o))}function xt(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 L(e){switch(e.type){case"row":{let t=le(e),n=wn(e),o=0,i=0,a=0;for(let r=0;r<t.length;r++){let s=n.get(r);s?.skip||(o+=t[r].x+(s?.dx??0),i+=t[r].y+(s?.dy??0),a++)}return a?{x:o/a,y:i/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return xt(e.points);case"section":return xt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?xt(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 mn(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Er(e,t){if(e.type!=="gaArea"||!mn(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((i,a)=>mn(i,o[a]))}function xn(e,t,n=e.filter(i=>i.type==="section"),o=L(t)){let i="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(i?n.find(r=>(r.logicalSectionId??r.id)===i&&(Er(t,r)||F(o,r.outline,r.holes))):void 0)??n.find(r=>F(o,r.outline,r.holes))}function k(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 B(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var Ke=40;function vn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,s=(c,l)=>{c<o&&(o=c),l<i&&(i=l),c>a&&(a=c),l>r&&(r=l)};for(let c of B(e))if(c.type==="row"){let l=new Map((c.overrides??[]).map(d=>[d.index,d]));le(c).forEach((d,g)=>{let b=l.get(g);b?.skip||s(d.x+(b?.dx??0),d.y+(b?.dy??0))})}else if(c.type==="gaArea")for(let l of c.points)s(l.x,l.y);else if(c.type==="section")for(let l of c.outline)s(l.x,l.y);else if(c.type==="decorImage")s(c.x,c.y),s(c.x+c.width,c.y+c.height);else if(c.type==="shape")if(c.points&&c.points.length)for(let l of c.points)s(l.x,l.y);else c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null&&(s(c.x,c.y),s(c.x+c.width,c.y+c.height));else if(c.type==="table"){let l=ce+Ar,d=c.shape==="round"?(c.radius??40)+l:Math.max((c.width??80)/2,(c.height??50)/2)+l;s(c.center.x-d,c.center.y-d),s(c.center.x+d,c.center.y+d)}else if(c.type==="booth"){let l=Math.max(c.width,c.height)/2;s(c.center.x-l,c.center.y-l),s(c.center.x+l,c.center.y+l)}else if(c.type==="text"){if(n)continue;let l=nn(c);s(c.position.x,c.position.y),s(c.position.x+l.width,c.position.y+l.height)}for(let c of[e.referenceImage,e.backgroundImage]){if(!c)continue;let{center:l,width:d}=c,g=d*3/4;s(l.x-d/2,l.y-g/2),s(l.x+d/2,l.y+g/2)}if(!isFinite(o)){let c=e.focalPoint??{x:0,y:0};return{x:c.x-200,y:c.y-200,width:400,height:400}}return{x:o-Ke,y:i-Ke,width:a-o+Ke*2,height:r-i+Ke*2}}function Be(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}var Tr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Rn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Re(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function It(e){let t=Re(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of Tr){let s=i?.[r];s!==void 0&&(a[r]=s)}n.push([Y(e,o,i),Ie(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function Fr(e){return JSON.parse(JSON.stringify(e))}function ze(e,t){let n=Fr(e);return t(n)&&It(n)===It(e)?n:e}function Nr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Re(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let i=t.get(o)?.labelStyle;if(!i)return!1;if(!n)n=i;else if(!Rn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Dr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Pn(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let r=Dr(a.slice(n.length+1));if(r===void 0)return;o.push(r)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let i=o[1]-o[0];if(!(i!==1&&i!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==i)return;return i===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Gr(e){if(e.seatCount<1)return!1;let t=Re(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(Y(e,i,t.get(i)));let o=Pn(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let i of e.overrides??[])delete i.label;return!0}function Kr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Re(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==se(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function He(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Rn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===Y(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===Ie(e,t.index)&&delete t.displayLabel}function _n(e){return Object.keys(e).every(t=>t==="index")}function $r(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)He(e,n);let t=e.overrides.filter(n=>!_n(n));return t.length?e.overrides=t:delete e.overrides,!0}function Br(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Re(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function An(e){if(e.type!=="row")return e;let t=ze(e,Nr);return t=ze(t,Gr),t=ze(t,Kr),t=ze(t,$r),Br(e,t)?t:e}function Mn(e){if(!e.overrides?.length)return e;let t=e.displayLabel??e.label,n=[];for(let i of e.overrides){let a={...i};a.label===`${e.label}-${a.index+1}`&&delete a.label,a.displayLabel===`${t}-${a.index+1}`&&delete a.displayLabel,a.categoryKey===e.categoryKey&&delete a.categoryKey,a.dx===0&&delete a.dx,a.dy===0&&delete a.dy,_n(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function In(e){return e.type==="row"?An(e):e.type==="table"?Mn(e):e}function zr(e){let t=e.objects.map(In),n=e.floors?.map(o=>({...o,objects:o.objects.map(In)}));return{...e,objects:t,...n?{floors:n}:{}}}var Cn=2,Ur=3,On=6;function Oe(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function Ue(e){return{...e,x:Oe(e.x,Cn),y:Oe(e.y,Cn)}}function Hr(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Ue(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Ue)),Array.isArray(t.points)&&(t.points=t.points.map(Ue)),typeof t.rotation=="number"&&(t.rotation=Oe(t.rotation,On)),typeof t.seatSpacing=="number"&&(t.seatSpacing=Oe(t.seatSpacing,On));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Ue(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let s=Oe(r,Ur);s===0?delete i[a]:i[a]=s}return i})),t}var Vr=36,Jr=160;function jn(e,t=360){let n=ve(Math.round(Number.isFinite(e)?e:1),1,40),o=ve(Number.isFinite(t)?t:360,120,360);return Math.round(ve(n*4*(360/o),Vr,Jr))}var Pe=[{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"}],yc=new Map(Pe.map(e=>[e.key,e]));var qr=[{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"}],mc=new Map(qr.map(e=>[e.key,e]));var de=8,Ct=24,Xr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],wc=new Set(Xr);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function j(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function M(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Yr(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;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 t){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=t.length-1;a>=0;a--){let r=t[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 Qr(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.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*t,y:o.y+a/r*t}})}function ne(e){let t=[];for(let o of e)o.type==="row"?t.push(...H(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...te(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Qr(Yr(t),22);return n.length>=3?n:null}function Ve(e,t){let n=C(e,t),o=k(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Ln=24,kn=80;function Ot(e,t){let n=e.normalize("NFKC").trim();if(n.length>Ln)throw new u("invalid_operation",`${t} displayed type must be at most ${Ln} characters`);return n}function Je(e,t){if(e.displayType===void 0)return!1;let n=Ot(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function ue(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>kn)throw new u("invalid_operation",`${t} displayed label must be at most ${kn} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function E(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function En(e,t){if(!Number.isFinite(e)||e<de||e>Ct)throw new u("invalid_operation",`${t} label size must be from ${de} to ${Ct}`)}function fe(e,t){e.size!==void 0&&e.size!==null&&En(e.size,t),e.color!==void 0&&e.color!==null&&E(e.color,`${t} label color`)}function qe(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&En(n.size,t),n.color!==void 0&&E(n.color,`${t} label color`))}function Xe(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=E(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function Rt(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.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 Pt(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function J(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var Q=Math.PI/180,q=Math.PI/180;function oe(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function _e(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var Wr=0,Ye=120,_t=4;function Zr(e){if(!Number.isFinite(e)||e<Wr||e>Ye)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ei(e,t){let n=k(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.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}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(Ye,(e.floors.length-1)*_t),r=Math.min(Ye,a+_t),s=M(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),_e(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:r}}function ti(e,t){let n=k(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.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 ni(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(i=>i.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});Zr(t.baseHeightM);let o=n.baseHeightM!==t.baseHeightM;return o&&(n.baseHeightM=t.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:t.baseHeightM}}function oi(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(i=>i.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[i]=e.floors;e.objects=i.objects,e.focalPoint=i.focalPoint,e.referenceImage=i.referenceImage,e.backgroundImage=i.backgroundImage,e.floors=void 0}else _e(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:k(e).length}}function ri(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:M(e,"zone",t.idFactory,new Set),label:Rt(e,t.label),color:E(t.color,"Zone color"),...t.focalPoint?{focalPoint:Pt(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function ii(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.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((e.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(e),r=new Map((a.zones??[]).map(c=>[c.id,c]));for(let c of t.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=Rt(a,c.patch.label,d.id)),c.patch.color!==void 0&&(d.color=E(c.patch.color,"Zone color")),c.patch.focalPoint!==void 0&&(d.focalPoint=Pt(c.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(c=>structuredClone(r.get(c)))}}function ai(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=k(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.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 e.zones.splice(n,1),e.zones.length||delete e.zones,_e(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var Qe=[{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 We(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&t.set(a,(t.get(a)??0)+r)};i(e.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??e.categoryKey);return t}var At="__sl_ga__";function Ae(e){return e.startsWith(At)}var si=At,X=1e5;function ci(e,t){return`${si}${encodeURIComponent(e)}__${t+1}`}function Mt(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){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>X||(n+=i.count,n>X))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===e.capacity}function Ze(e){let t=Math.min(X,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Mt(e)?e.inventorySegments.map(n=>({...n})):[]}function W(e){return Ze(e).flatMap(t=>Array.from({length:t.count},(n,o)=>ci(t.sourceAreaId,t.startIndex+o)))}function jt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=Ze(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,c)=>Math.max(s,c.startIndex+c.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var li="__ungrouped__";function di(e){return e.type==="row"?H(e).map(t=>t.label):e.type==="table"?te(e).map(t=>t.label):e.type==="booth"?Sn(e).map(t=>t.label):e.type==="gaArea"?W(e):[]}function ui(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function fi(e){return e.displayLabel||e.label||"Section"}function gi(e){let t=new Map;for(let n of B(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:fi(n),zone:n.zone})}return t}function bi(e,t){let n=B(e),o=n.filter(s=>s.type==="section"),i=new Map;for(let[s,c]of gi(e))i.set(s,{id:s,label:c.label,zone:c.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:li,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},r=new Map;for(let s of n){if(!ui(s))continue;let c=di(s);if(c.length===0)continue;let l;if(t)l=t.get(s.id);else{let g=xn(n,s,o);l=g?g.logicalSectionId??g.id:void 0}let d=l?i.get(l):a;d.seatCount+=c.length,d.objectIds.push(s.id),d.seatLabels.push(...c),r.set(s.id,d.id)}return{sections:[...i.values()],ungrouped:a.objectIds.length?a:null,objectToSection:r}}function Me(e){return bi(e,null)}var re={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 je(e,t,n,o,i,a,r=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function hi(e,t,n,o,i,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function Tn(e,t,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}function pi(e,t,n,o,i){let a=n*2,r=[];for(let s=0;s<a;s++){let c=s%2===0,l=c?["wheelchair"]:["companion"];r.push(c?{index:s,accessibility:l,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:l})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Fn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[re.balcony],sectionLabel:"Balcony",build:()=>[je("blk-b0","A",-45,18,24,"balcony",18),je("blk-b1","B",-15,20,24,"balcony",18),je("blk-b2","C",15,22,24,"balcony",18),je("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[re.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>je(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[re.standard],build:()=>[Tn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[re.premium],build:()=>Array.from({length:6},(e,t)=>hi(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[re.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"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[re.standard],build:()=>[Tn("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[re.standard],build:()=>[pi("blk-wc","A",4,40,"standard")]}];function U(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function Nn(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Dn="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",Gn=[{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:Dn},{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:Dn},{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 yi=new Map(Gn.map(e=>[e.key,e]));function Kn(e){return typeof e=="string"&&yi.has(e)}var Uc=Gn.map(e=>e.key);function Lt(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function $n(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=e.holes.map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=cn(e.outlinePath,t,n)),e.holes&&(e.holes=e.holes.map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function mi(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function Le(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function et(e,t,n){let o=Le(t,n,e);return Math.abs(o)>1e-7?!1:e.x>=Math.min(t.x,n.x)-1e-7&&e.x<=Math.max(t.x,n.x)+1e-7&&e.y>=Math.min(t.y,n.y)-1e-7&&e.y<=Math.max(t.y,n.y)+1e-7}function wi(e,t,n,o){let i=Le(e,t,n),a=Le(e,t,o),r=Le(n,o,e),s=Le(n,o,t);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&&et(n,e,t)||Math.abs(a)<=1e-7&&et(o,e,t)||Math.abs(r)<=1e-7&&et(e,n,o)||Math.abs(s)<=1e-7&&et(t,n,o)}function Si(e){return e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n.x*i.y-i.x*n.y},0)}function xi(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&wi(e[t],e[n],e[o],e[i]))return!0}}return!1}function Bn(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>mi(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Si(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:xi(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function Mi(e,t){let n=C(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(p=>p.type==="table"&&p.id===h)),a=o.filter((h,p)=>!i[p]);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(t.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&&j(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=E(r.fill,"Table surface color"));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 h=["top","bottom","left","right"],p=Object.keys(r.seatCountsBySide);if(p.length!==h.length||p.some(x=>!h.includes(x)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let x of h){let v=r.seatCountsBySide[x];if(!Number.isInteger(v)||v<0||v>40)throw new u("invalid_operation",`seatCountsBySide.${x} must be a whole number from 0 to 40`)}let S=h.reduce((x,v)=>x+r.seatCountsBySide[v],0);if(S<1||S>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==S)throw new u("invalid_operation",`seatCount must equal the ${S}-chair seatCountsBySide total`);r.seatCount=S,r.sides=h.filter(x=>r.seatCountsBySide[x]>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.automaticRadius!==void 0&&typeof r.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(r.shape==="rect"&&r.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");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=(h,p,S,x)=>{if(p!==void 0&&(!Number.isFinite(p)||p<S||p>x))throw new u("invalid_operation",`${String(h)} must be from ${S} to ${x}`)};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 h=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(p=>!h.has(p)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=ue(r,"Table"),g=Je(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!c&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let p=structuredClone(h);if(Object.assign(p,r),r.fill===null&&delete p.fill,p.shape==="round")delete p.seatCountsBySide,p.automaticRadius===!0?p.radius=jn(p.seatCount,p.seatArc):delete p.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${p.label}" is rectangular and cannot use automatic radius`,{tableId:p.id});delete p.automaticRadius}if(p.overrides&&r.seatCount!==void 0&&(p.overrides=p.overrides.filter(S=>S.index<p.seatCount),p.overrides.length||delete p.overrides),r.bookAsWhole===!1&&delete p.bookAsWhole,r.variableOccupancy===!1&&(delete p.variableOccupancy,delete p.minOccupancy,delete p.maxOccupancy),p.bookAsWhole||delete p.bookAsWhole,p.variableOccupancy||delete p.variableOccupancy,p.bookAsWhole&&p.variableOccupancy)throw new u("invalid_operation",`Table "${p.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:p.id});if((p.bookAsWhole||p.variableOccupancy)&&p.overrides?.length)throw new u("invalid_operation",`Table "${p.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:p.id,overriddenChairIndices:p.overrides.map(S=>S.index)});if(p.bookAsWhole)delete p.minOccupancy,delete p.maxOccupancy;else if(p.variableOccupancy){if(!Number.isInteger(p.minOccupancy)||!Number.isInteger(p.maxOccupancy)||p.minOccupancy<1||p.maxOccupancy<p.minOccupancy||p.maxOccupancy>p.seatCount)throw new u("invalid_operation",`Table "${p.label}" needs whole-number minimum and maximum guests from 1 to its ${p.seatCount}-chair capacity`,{tableId:p.id,seatCount:p.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:p.id});delete p.minOccupancy,delete p.maxOccupancy}if(g&&delete p.displayType,d&&delete p.displayLabel,p.shape==="rect"){if(p.width??=80,p.height??=50,p.seatCountsBySide){let S=["top","bottom","left","right"],x=S.reduce((v,P)=>v+p.seatCountsBySide[P],0);if(x!==p.seatCount)throw new u("invalid_operation",`Table "${p.label}" side counts total ${x}, but seatCount is ${p.seatCount}`,{tableId:p.id,seatCount:p.seatCount,seatCountsBySide:p.seatCountsBySide});p.sides=S.filter(v=>p.seatCountsBySide[v]>0)}}else p.radius??=40;if((p.bookAsWhole||p.variableOccupancy)&&Ae(p.label))throw new u("invalid_operation",`Grouped table label "${p.label}" uses SeatLayer's reserved GA namespace`,{tableId:p.id});return p}),f=new Map(b.map(h=>[h.id,h])),y=new Set(o),m=new Map;for(let h of k(e))for(let p of h.objects){let S=p.type==="table"?f.get(p.id)??p:p,x=[];S.type==="row"?x=H(S).map(v=>v.label):S.type==="table"?x=S.bookAsWhole||S.variableOccupancy?[S.label]:te(S).map(v=>v.label):S.type==="booth"?x=[S.label]:S.type==="gaArea"&&(x=W(S));for(let v of x){let P=m.get(v);if(P&&(y.has(P)||y.has(S.id)))throw new u("invalid_operation",`Inventory label "${v}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:v,conflictingObjectIds:[P,S.id]});m.set(v,P??S.id)}}let w=!1,I=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,p]of i.entries()){let S=b[h],x=JSON.stringify(p);for(let v of I)v in S||delete p[v];Object.assign(p,S),JSON.stringify(p)!==x&&(w=!0)}return{floorId:n.floorId,changed:w,tableIds:o}}function ji(e,t){let n=C(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(y=>y.type==="booth"&&y.id===f)),a=o.filter((f,y)=>!i[y]);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(t.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&&j(e,r.categoryKey);let s=(f,y,m,w)=>{if(y!==void 0&&(!Number.isFinite(y)||y<m||y>w))throw new u("invalid_operation",`${f} must be from ${m} to ${w}`)};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=Bn(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=ue(r,"Booth"),g=Je(r,"Booth"),b=!1;for(let f of i){let y=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)!==y&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Li(e,t){let n=C(e,t.floorId),o=[...new Set(t.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(t.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&&j(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>X))throw new u("invalid_operation",`capacity must be an integer from 1 to ${X}`);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=ue(r,"GA area"),c=Je(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&&jt(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:jt(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 tt(e,t){if(t.length<3)return 0;let n=i=>F(i,t,void 0),o=0;for(let i of e)n(L(i))&&(i.type==="row"?o+=H(i).length:i.type==="table"?o+=te(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=oe(i)));return o}function ki(e,t){let n=C(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(c=>c.id===s)),i=t.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(t.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+oe(c),0),remainingObjectCount:n.objects.length}}function Ei(e,t){let n=C(e,t.floorId),o=[...new Set(t.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(t.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=E(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=E(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.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!Kn(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),r.labelImportance===null?delete l.labelImportance:r.labelImportance!==void 0&&(l.labelImportance=r.labelImportance),JSON.stringify(l)!==d&&(Be(l),c=!0)}return{floorId:n.floorId,changed:c,textIds:o}}function Ti(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],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.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),s=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,c=gn(r.map(b=>({label:s(b)})),t.options),l=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=l===void 0||l===""||l==="Row"?t.displayType===void 0?void 0:null:l,g=!1;return r.forEach((b,f)=>{let y=c[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(b)!==y&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=y:b.displayLabel=y),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:s(b),...b.displayType?{displayType:b.displayType}:{}}))}}function Fi(e,t){let n=Fn.find(l=>l.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=C(e,t.floorId),i=new Set,a=n.build().map(l=>structuredClone(l));for(let l of a)l.id=M(e,l.type,t.idFactory,i),$n(l,t.center.x,t.center.y);for(let l of n.categories)e.categories.some(d=>d.key===l.key)||e.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=Nn(d.label);g!=null&&(l=Math.max(l,g+1))}for(let d of r)d.label=U(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&&t.wrapInSection!==!1){let l=ne(a);if(l){let d={type:"section",id:M(e,"sec",t.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 Ni(e){let t=structuredClone(e);if([t.start,t.control1,t.control2,t.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=De(t,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:t,length:i}}function Hn(e,t){let n=C(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=Ni(t.path),a=H(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=H(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 Di(e,t){let n=Hn(e,t);if(!n.changed)return n;let i=C(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(t.path),i.origin={...t.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function Gi(e,t){let n=e.map((o,i)=>[...o,t[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 Ki(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){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++)t[s][c]+=a[s]*a[c]}}let o=Gi(t,n);return o?{x:o[0],y:o[1]}:null}function zn(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function Vn(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.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=k(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Ki(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(f=>f.type==="row"&&F(L(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 y=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(y<=f.seatSpacing/2+1e-6){l.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*y))/Q,w=H(f),I=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/Q,p=(f.curve!==0?Math.sign(f.curve):w.length>1&&Math.sign(zn(Math.atan2(w[1].x-r.x,w[1].y-r.y)/Q-I))||1)*m*(f.seatCount-1);if(Math.abs(p)>320){l.push(f.id);continue}let S=-I,x=f.curve+(p-f.curve)*g,v=f.rotation+zn(S-f.rotation)*g,P={...f,curve:x,rotation:v},G=H(P).map((K,$)=>Math.hypot(K.x-w[$].x,K.y-w[$].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:p,resultCurve:x,fromRotation:f.rotation,resultRotation:v,rmsMovement:Math.sqrt(G.reduce((K,$)=>K+$**2,0)/G.length),maxMovement:Math.max(...G)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:c,skippedInvalidRowIds:l,averageMovement:b.length?b.reduce((f,y)=>f+y,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function $i(e,t){let n=Vn(e,t),o=C(e,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 Jn(e,t,n,o){let i=J(e,t,n),a=J(e,t,o),r=J(n,o,e),s=J(n,o,t);return i*a<-1e-9&&r*s<-1e-9}function Un(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>Jn(n,i,a,t[(r+1)%t.length]))})}function Bi(e){if(e.length<3||e.length>256||Math.abs(xe(e))<1||e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)))return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(!(n===t+1||t===0&&n===e.length-1)&&Jn(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function nt(e,t,n){let o=C(e,t),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 ot(e,t){let{target:n,object:o,outer:i}=nt(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Bi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!F(l,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Un(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=t.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||t.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<r.length;l++){if(l===t.holeIndex)continue;let d=r[l];if(Un(a,d)||F(a[0],d,void 0)||F(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"&&F(L(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:tt(n.objects.filter(l=>l.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function zi(e,t){let n=ot(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function qn(e,t){let{target:n,object:o}=nt(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[t.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&F(L(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:tt(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ui(e,t){let n=qn(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Hi(e){let t=ee(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Xn(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.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 Yn(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),i=Me(Ve(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),s=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),c=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of s){let y=r.get(f);if(y)if(y.type==="row"||y.type==="table")for(let m of We(y).keys())c.add(m);else(y.type==="booth"||y.type==="gaArea")&&c.add(y.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(y=>{let m=r.get(y);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:g,...g&&c.size===1?{categoryKey:[...c][0]}:!g&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?c.size!==1:!s.length&&d.size>1,viewApplicable:b}}function Vi(e,t){j(e,t.categoryKey);let n=Yn(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=C(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,s=new Set(n.logicalSectionIds);for(let c of o.objects)c.type!=="section"||!s.has(c.logicalSectionId??c.id)||c.editor?.defaultCategoryKey!==t.categoryKey&&(c.editor={...c.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let c of o.objects){if(!i.has(c.id)||c.type!=="row"&&c.type!=="table"&&c.type!=="booth"&&c.type!=="gaArea"||(c.categoryKey!==t.categoryKey&&(c.categoryKey=t.categoryKey,a=!0),c.type!=="row"&&c.type!=="table"||!c.overrides?.length))continue;let l=c.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});l.length?c.overrides=l:delete c.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Ji(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.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=Hi(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&&qe(a.labelPresentation,"Section"),a.labelStyle!==void 0&&fe(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.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=E(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 y=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 m=w=>{f.physical3dProvenance&&(delete f.physical3dProvenance[w],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,m("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,m("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,m("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)!==y&&(b=!0,g.add(f.id))}for(let f of d){let y=JSON.stringify(f),m=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!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let w=Xe(f.labelPresentation,a.labelStyle);w?f.labelPresentation=w:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==y&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function Qn(e,t){let n=C(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.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"&&F(L(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+oe(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function qi(e,t){let n=Qn(e,t),i=C(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function Wn(e,t){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let s=L(e);o=c=>({x:s.x+(c.x-s.x)*t.factor,y:s.y+(c.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let c=t.degrees*Math.PI/180,l=Math.cos(c),d=Math.sin(c),g=L(e);o=b=>{let f=b.x-g.x,y=b.y-g.y;return{x:g.x+f*l-y*d,y:g.y+f*d+y*l}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=mt(e.outlinePath,o,i,a)),e.holes&&(e.holes=e.holes.map(s=>s.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function Xi(e,t){let n=C(e,t.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Wn(o,t.transform)}}function Yi(e,t){let n=C(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Ge(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=yt(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 Qi(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function Wi(e,t){return Zn(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function Zn(e,t){let n=C(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.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(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let c=n.objects.find(h=>h.type==="section"&&h.id===s);if(!c||!Qi(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(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??c.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?c.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),w=m?.some(h=>Math.abs(h)>.5)===!0,I=f>.5||w?ln(b,{cornerSmoothing:f,...w?{edgeCurvature:m}:{}}):null;I?(c.sourceOutline=b,c.outlinePath=I,c.outline=yt(I),f>.5?c.cornerSmoothing=f:delete c.cornerSmoothing,w?c.edgeCurvature=[...m]:delete c.edgeCurvature):(c.outline=b,delete c.outlinePath,delete c.sourceOutline,delete c.cornerSmoothing,delete c.edgeCurvature);for(let h=0;h<(c.holes?.length??0);h+=1)ot(e,{floorId:n.floorId,objectId:c.id,points:c.holes[h],holeIndex:h});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 Et=.15,Tt=1.6;var Zi=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Nt(e){let t=Zi.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(i=>i+i).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Dt(e,t){let n=a=>{let r=Nt(a);if(!r)return null;let s=h=>{let p=h/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4},c=s(r[0]),l=s(r[1]),d=s(r[2]),g=(.4124*c+.3576*l+.1805*d)/.95047,b=.2126*c+.7152*l+.0722*d,f=(.0193*c+.1192*l+.9505*d)/1.08883,y=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=y(g),w=y(b),I=y(f);return[116*w-16,500*(m-w),200*(w-I)]},o=n(e),i=n(t);return o&&i?Math.hypot(o[0]-i[0],o[1]-i[1],o[2]-i[2]):null}function Ft(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function eo(e){return .2126*Ft(e[0])+.7152*Ft(e[1])+.0722*Ft(e[2])}function rt(e,t){let n=Nt(e),o=Nt(t);if(!n||!o)return null;let i=eo(n),a=eo(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var to=["butt","round","square"],no=["miter","round","bevel"],oo=["none","arrow"];function Gt(e){return e==="line"||e==="polyline"}var ro=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Rl=ro.map(e=>e.key),ea=new Map(ro.map(e=>[e.key,e]));function ke(e){return typeof e=="string"&&ea.has(e)}var ta=new Set(["companion","child","senior","student","membership","custom"]);function ge(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.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.referenceDirectSeatImport!==void 0){let l=i.referenceDirectSeatImport;if(l.assetId!==l.assetId.trim()||l.assetId.length>160||!l.assetId||l.familyId!==l.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(l.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{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.seatGlyph!=null&&!ke(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,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(),y=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(y))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&&!ta.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 m=g.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),w=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(I=>!I||I.length>160)||new Set(m).size!==m.length)||w&&(!w.length||w.some(I=>!Pe.some(h=>h.key===I))||new Set(w).size!==w.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...m?{seatLabels:m}:{},...w?{accessibility:[...w]}:{}},!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(y)}}}return o}function ao(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.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})),delete s.referenceDirectSeatImport}let i=ge(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function na(e,t){let n=structuredClone(e.categories),o=n.find(r=>r.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let i=ge(n),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,category:e.categories.find(r=>r.key===t.categoryKey),categories:e.categories}}function oa(e,t){let n=t.categoryKeys.map(c=>c.trim()),o=e.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:e.categories};let s=new Map(e.categories.map(c=>[c.key,c]));return e.categories=ge(n.map((c,l)=>{let d=structuredClone(s.get(c));return c!==o[l]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var Kt=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function io(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[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 ra(e,t){let n=io(e),o=io(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var ia=3600;function so(e,t,n=Kt){return n.find(i=>e.every(a=>ra(i,a)>=ia))??n[t%n.length]}function aa(e,t){let n=t?.palette??Kt;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return ao(e,{updates:i}),{changed:e.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:e.categories}}function sa(e,t){let n=t.color.trim().toLowerCase(),o=t.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(e.categories),a=i.find(c=>c.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=ge(i),s=JSON.stringify(r)!==JSON.stringify(e.categories);return s&&(e.categories=r),{changed:s,category:e.categories.find(c=>c.key===t.categoryKey),categories:e.categories}}function co(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let c=t.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:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=ge([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var ca=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],la={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function da(e,t){let n=la[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var ua=26;function fa(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%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 ga(e,t,n){let o=r=>e.every(s=>{let c=Dt(r,s);return c==null||c>=ua}),i=r=>{let s=rt(r,"#12151d"),c=rt(r,"#ffffff");return(s??0)>=3||(c??0)>=3},a=t.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=fa(r,.62,s);if(o(c)&&i(c))return c}return n}function lo(e,t){let n=Qe.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function ba(e){let t=new Map;for(let n of k(e))for(let o of n.objects){let i=Qe.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of We(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=t.get(r)??new Set;s.add(i.objectType),t.set(r,s)}}return t}function ha(e,t){let n=new Set(e.categories.map(i=>i.label.toLowerCase())),o=t;for(let i=2;n.has(o.toLowerCase());i+=1)o=`${t} ${i}`;return o}function uo(e,t,n){let o=ba(e),i=l=>{let d=o.get(l);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(l=>l.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let l=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(l)return{kind:"existing",categoryKey:l.key,label:l.label}}let r=Qe.find(l=>l.objectType===n),s=a?lo(a.label,n):n==="gaArea"?"General Admission":r.creationWord,c=e.categories.find(l=>l.label.toLowerCase()===s.toLowerCase()&&i(l.key));return c?{kind:"existing",categoryKey:c.key,label:c.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:ha(e,s)}}function pa(e,t,n,o){let i=uo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return ya(e,n,a,i.label,o)}function ya(e,t,n,o,i){let a=i.palette??ca,r=e.categories.map(d=>d.color),s=i.suggestColor?.(r.map(d=>d.toLowerCase()))??so(r,e.categories.length),c=ga(r,da(t,a),s),l=co(e,{label:o,color:c,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=l.categories,l.category.key}function ma(e,t){let n=new Set;for(let o of k(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function wa(e,t){let n=e.categories.find(a=>a.key===t.categoryKey);if(!n)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});if(e.categories.length<=1)throw new u("invalid_operation","A chart must retain at least one category");let o=ma(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let i=ge(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var Sa=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],xa=["seat","deck","shell","fascia"];function va(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),i={...e.theme??{}};for(let a of Sa){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=E(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<Et||n.seatScale>Tt)throw new u("invalid_operation",`Theme seatScale must be from ${Et} to ${Tt}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=ee(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster 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}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let s of xa){let c=n.venue3d[s];c===null?delete a[s]:c!==void 0&&(a[s]=E(c,`3D venue ${s}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Ia(e,t){let n=t.url===null?null:ee(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(g=>g.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let c=(s.viewFromSeatUrl??void 0)===o,l=o?t.metadata===null?void 0:t.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:t.floorId,url:s.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function Ca(e,t){let n=Ve(e,t.floorId),o=vn(n),i=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:i==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function it(e,t){j(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.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(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.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:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.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(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function Oa(e,t,n){let o=n*Q;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Ra(e,t,n,o){let i=Math.abs(o-n)*Q,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let g=e.aisleGaps[l];if(!g)return[];let b=g/t/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])=>t*i*(d-l)>=e.seatPitch*.75)}function Pa(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((c,l)=>c+l,0),a=e.map(c=>o*c/i),r=a.map(c=>2+Math.floor(c)),s=t-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 at(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,c=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,l=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(l-c)!==Math.sign(e.endAngle-e.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=Ra(e,r,c,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([y,m])=>r*Math.abs(l-c)*Q*(m-y)),b=e.fit==="fixed-count"?Pa(g,e.seatsPerRow):g.map(y=>Math.max(2,Math.round(y/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([y,m],w)=>{let I=c+(l-c)*y,h=c+(l-c)*m;e.facing==="outward"&&([I,h]=[h,I]);let p=b[w];if(p>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let S=Math.abs(h-I)*Q/(p-1),x=2*r*Math.sin(S/2),v={type:"row",id:n(i,w),label:U(e.rowLabelStart+i),origin:Oa(e.center,r,I),rotation:-I,curve:h-I,seatCount:p,seatSpacing:x,categoryKey:e.categoryKey,seatLabelStart:f,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:i,segmentIndex:w}};o.push(v),f+=p})}return o}function $t(e,t){let n=it(e,t),o=C(e,t.floorId),i=at(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 _a(e,t){let n=it(e,t),o=C(e,t.floorId),i=new Set,a=M(e,"fan",t.idFactory,i),r=at(n,a,()=>M(e,"r",t.idFactory,i)),s=$t(e,t),c=null,l=t.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=ne(r);g&&(c=M(e,"sec",t.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 fo(e,t){let n=C(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.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:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.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=it(e,s),l=new Set(at(c,t.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:t.groupId});return s}function Aa(e,t){fo(e,{floorId:t.floorId,groupId:t.groupId});let n=it(e,t),o=C(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),s=new Set,c=at(n,t.groupId,(m,w)=>r.get(`${m}:${w}`)??M(e,"r",t.idFactory,s)),l=$t(e,t),d=t.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 m=ne(c);m&&(g={type:"section",id:a?.id??M(e,"sec",t.idFactory,s),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,w)=>b.has(m.id)?w:1/0)),y=o.objects.filter(m=>!b.has(m.id));return y.splice(Number.isFinite(f)?f:y.length,0,...c,...g?[g]:[]),o.objects.splice(0,o.objects.length,...y),{floorId:o.floorId,rowIds:c.map(m=>m.id),sectionId:g?.id??null,groupId:t.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 Ma(e){let t=new Set(B(e).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;t.has(U(n));)n+=1;let o=U(n);return t.add(o),n+=1,o}}function go(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function ja(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.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(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=C(e,t.floorId),a=new Set,r=Ma(e),s=Lt(t.rotation??0),c=t.curve??0,l=t.style,d=l?M(e,"rowblock",t.idFactory,a):void 0,g=l?go({style:l,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.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},y=Array.from({length:t.rowCount},(I,h)=>{let p=l==="intertwined"&&h%2===1?o/2:0,S={type:"row",id:M(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+f.x*h*n+b.x*p,y:t.origin.y+f.y*h*n+b.y*p},rotation:s,curve:c,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&g&&(S.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:c,signature:g}),S});i.objects.push(...y);let m=null,w=t.sectionLabel?.trim();if(w){let I=ne(y);if(I){let h={type:"section",id:M(e,"sec",t.idFactory,a),label:w,outline:I};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:y.map(I=>I.id),sectionId:m,createdIds:[...y.map(I=>I.id),...m?[m]:[]]}}function bo(e,t){let n=new Set(B(e).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(`${t}${o}`);)o+=1;let i=`${t}${o}`;return n.add(i),o+=1,i}}function La(e,t){let n=new Set(B(e).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var ka=456;function ho(e){let t=Math.sqrt(Math.max(1,e)*ka);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ea(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=C(e,t.floorId),o=new Set,{width:i,height:a}=ho(t.capacity),r=La(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:M(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function Ta(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.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(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"T"),s=[];for(let c=0;c<t.tableRows;c+=1)for(let l=0;l<t.tableColumns;l+=1)s.push({type:"table",id:M(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.tableColumns-1)/2)*n,y:t.center.y+(c-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.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 Fa(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.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(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"B"),s=[];for(let c=0;c<t.boothRows;c+=1)for(let l=0;l<t.boothColumns;l+=1)s.push({type:"booth",id:M(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.boothColumns-1)/2)*n,y:t.center.y+(c-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function Na(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.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=(t.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=t.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":t.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 Da(e,t){let n=C(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),i=t.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 Ga(e,t){let n=C(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.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(t.boundaries&&(t.boundaries.length!==o.length-1||t.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=t.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),t.boundaries&&s>0&&(c.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(c.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete c.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(c.viewFromSeatUrl=t.viewFromSeatUrl),!c.viewFromSeatUrl||t.viewFromSeatMeta===null?delete c.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?c.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&c.viewFromSeatUrl!==l&&delete c.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ka(e,t){let n=C(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,z)=>R.rowBlockGeneration.rowIndex-z.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((R,z)=>{let A=R.rowBlockGeneration;return A.kind!=="row-block-v1"||A.rowIndex!==z||A.signature!==i.signature||JSON.stringify(A)!==JSON.stringify({...i,rowIndex:z})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,s=t.rowCount??i.rowCount,c=t.seatsPerRow??i.seatsPerRow,l=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?Lt(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.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(R=>Number.isFinite(R)&&R>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 y=go({style:r,origin:f,rotation:b,rowCount:s,seatsPerRow:c,rowGap:l,seatSpacing:d,curve:g}),m={x:Math.cos(b*q),y:Math.sin(b*q)},w={x:-m.y,y:m.x},I=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),h=new Set,p=new Set(n.objects.filter(R=>R.type==="row").filter(R=>!o.includes(R)).map(R=>R.label)),S=n.objects.filter(R=>R.type==="row").length,x=()=>{for(;p.has(U(S));)S+=1;let R=U(S);return p.add(R),S+=1,R},v=[],P=[];for(let R=0;R<s;R+=1){let z=r==="intertwined"&&R%2===1?d/2:0,A=I.get(R);A||(A={type:"row",id:M(e,"r",t.idFactory,h),label:x(),origin:{...f},rotation:b,curve:g,seatCount:c,seatSpacing:d,categoryKey:o[0].categoryKey},P.push(A.id)),A.origin={x:f.x+w.x*R*l+m.x*z,y:f.y+w.y*R*l+m.y*z},A.rotation=b,A.curve=g,A.seatCount=c,A.seatSpacing=d,delete A.path,delete A.arcFanGeneration,A.overrides&&(A.overrides=A.overrides.filter(Se=>Se.index<c),A.overrides.length||delete A.overrides),A.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:R,rowCount:s,seatsPerRow:c,origin:{...f},rotation:b,rowGap:l,seatSpacing:d,curve:g,signature:y},v.push(A)}let N=o.slice(s).map(R=>R.id),G=Math.min(...o.map(R=>n.objects.indexOf(R))),K=new Set(o.map(R=>R.id)),$=n.objects.filter(R=>!K.has(R.id));return $.splice(G,0,...v),n.objects.splice(0,n.objects.length,...$),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(R=>R.id),createdRowIds:P,removedRowIds:N,changed:a!==JSON.stringify(v)||P.length>0||N.length>0}}function Bt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function zt(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Ut(e){return zt(Bt(e),40)}function po(e,t=39){return zt(Bt(e),Math.max(1,t))}function be(e,t=80){return zt(Bt(e),Math.max(1,t))}function yo(e){return be(e).toLocaleLowerCase("en")}function Ht(e){return yo(e)}function mo(e){return new Map((e??[]).map(t=>[t.index,t]))}function $a(e){let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(Y(e,o,i))}return n}function Ba(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(i?.label??`${e.label}-${o+1}`)}return n}function za(e){return e.type==="row"?[e.label,...$a(e)]:e.type==="table"?[e.label,...Ba(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...W(e)]:[]}function wo(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of za(o)){let a=Ht(i);a&&n.add(a)}return n}function Ua(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Ht(e)];for(let i=0;i<t;i+=1)o.push(Ht(Y(n,i)));return o.filter(Boolean)}function So(e,t,n){let o=Ua(t,n);if(!o.length||o.some(i=>e.has(i)||Ae(i)))return!1;for(let i of o)e.add(i);return!0}var Ha=1e-6,Va=160,Ja=.001,qa=1e-5;function he(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>Va)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function xo(e){return typeof e=="string"&&po(e)||void 0}function vo(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(Vt(e.origin)&&Vt(t.start)&&Vt(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},i=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Ja+Math.max(1,i)*qa;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||i<=Ha)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,c=Math.abs(((e.rotation-s)%360+540)%360-180),l=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return c<=l}function Vt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var Xa=300;function Ya(e){let t=new Set(B(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(U(n));)n+=1;let i=U(n);return n+=1,t.add(i),i};return i=>{let a=Ut(i),r=0;return()=>{for(;a&&r<4096;r+=1){let s=`${a}-${U(r)}`;if(!t.has(s))return t.add(s),r+=1,s}return o()}}}function Qa(e){let t=wo(B(e));return(n,o)=>{let i=be(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,s=r?`${be(i,80-r.length)}${r}`:i;if(s&&So(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function Wa(e){return{ordinaryFor:Ya(e),direct:Qa(e)}}function Io(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Za(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[s,c]of r.rows.entries()){let l=he(`${r.sourceGroupId}:${s}`),d=l&&he(c.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:c)}let i=new Map;for(let r of e){let s=he(r.referenceScan?.directSourceRowId);if(!s){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let c=i.get(s)??[];c.push(r),i.set(s,c)}let a=new Map;for(let[r,s]of i){let c=s.filter(b=>b.overrides?.length);if(!c.length)continue;let l=o.get(r),d=c[0],g=d.overrides;if(s.length!==1||c.length!==1||!g||!l||!vo(d,l))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:s.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function Co(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!(o.type==="row"&&o.referenceScan?.assetId===t&&(!n||o.referenceScan.sectionId===n)))}function es(e,t,n,o,i,a,r){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=Co(t,n,r).filter(g=>F(L(g),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let c=[],l=0;for(let[d,g]of e.rows.entries()){let b=Math.min(Xa,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,y=g.end.y-g.start.y,m=Math.hypot(f,y),w=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(w)||w<=0)continue;let I=m>0?Math.atan2(y,f)*180/Math.PI:0,h=e.sourceGroupId?he(`${e.sourceGroupId}:${d}`):void 0,p=h&&he(g.directSourceRowId)===h?h:void 0,S=p?xo(g.directReviewedSuffix):void 0,x=e.sourceGroupId&&g.rowLabel?be(g.rowLabel):"",v=e.sourceGroupId&&g.rowDisplayLabel?be(g.rowDisplayLabel):"",P=!!e.sourceGroupId&&g.rowDisplayLabel==="";c.push({label:x?a(x,b):i(),displayLabel:v||(P?"":String(d+1)),origin:{x:g.start.x,y:g.start.y},rotation:I,seatCount:b,seatSpacing:w,...p?{directSourceRowId:p}:{},...S?{directReviewedSuffix:S}:{}}),l+=b}return{skip:null,rows:c,seats:l}}function ts(e,t,n){j(e,n.categoryKey);let o=C(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=n.categoryKeyForSection?.(h)??n.categoryKey;j(e,p),r.set(h,p)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&s){let h=Co(o.objects,i,a.id).filter(p=>F(L(p),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:h.map(p=>p.id)}]}}let c=o.objects.filter(h=>Io(h,i,a?.id)),l=Za(c,t,a?.id),d=[],g=o.objects.filter(h=>Io(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],y=[],m=new Set,w=0,I=Wa(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=es(h,o.objects,i,t.seatPitch,I.ordinaryFor(h.name),I.direct,a?.id);if(p.skip){f.push(p.skip);continue}let S=p.rows.map(x=>({type:"row",id:M(e,"r",n.idFactory,m),referenceScan:{assetId:i,...h.sectionId?{sectionId:h.sectionId}:{},...x.directSourceRowId?{directSourceRowId:x.directSourceRowId}:{},...x.directReviewedSuffix?{directReviewedSuffix:x.directReviewedSuffix}:{}},label:x.label,...x.displayLabel!==void 0?{displayLabel:x.displayLabel}:{},origin:x.origin,rotation:x.rotation,curve:0,seatCount:x.seatCount,seatSpacing:x.seatSpacing,categoryKey:r.get(h)??n.categoryKey,...x.directSourceRowId&&l.has(x.directSourceRowId)?{overrides:structuredClone(l.get(x.directSourceRowId))}:{}}));o.objects.push(...S);for(let x of S)y.push(x.id);b.push({sectionId:h.sectionId,name:h.name,seats:p.seats,rows:S.length}),w+=p.seats}return{floorId:o.floorId,assetId:i,createdRowIds:y,removedRowIds:d,totalSeats:w,perSection:b,skipped:f}}function Ro(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.objectIds)];if(!i.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=i.map(m=>o.objects.find(w=>(w.type==="table"||w.type==="booth")&&w.id===m)),r=i.filter((m,w)=>!a[w]);if(r.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:r});let s=a[0].type;if(a.some(m=>m.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[m,w,I]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(w)||w<1||w>I)throw new u("invalid_operation",`${m} must be a whole number from 1 to ${I}`);for(let[m,w]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(w)||w<30||w>2e3)throw new u("invalid_operation",`${m} must be from 30 to 2000 chart units`);let c=t.rows*t.columns;if(c<2)throw new u("invalid_operation","Choose at least two grid cells");let l=i.length*(c-1);if(l>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((m,w)=>m+(w.type==="table"?w.seatCount:1),0),b=(e.floors?.length?e.floors.flatMap(m=>m.objects):e.objects).reduce((m,w)=>m+(w.type==="row"||w.type==="table"?w.seatCount:w.type==="gaArea"?Math.max(0,Math.floor(w.capacity)):w.type==="booth"?1:0),0),f=d*(c-1),y=n.maxInventory??1e5;if(b+f>y)throw new u("invalid_operation",`Grid inventory would exceed the ${y} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:i,sourceCount:i.length,cells:c,createdCount:l,addedInventory:f,resultingInventory:b+f,provenanceRemovedCount:a.filter(m=>!!m.referenceInventorySource).length*(c-1)}}}function ns(e,t,n={}){return Ro(e,t,n).preview}function os(e,t,n={}){let{target:o,sources:i,preview:a}=Ro(e,t,n),r=new Set,s=new Set((e.floors?.length?e.floors.flatMap(g=>g.objects):e.objects).flatMap(g=>"label"in g&&g.label?[g.label]:[])),c=[],l=(g,b)=>{let f=Math.max(2,b),y=w=>{let I=`-${w}`;return`${g.slice(0,Math.max(1,80-I.length))}${I}`},m=y(f);for(;s.has(m);)m=y(++f);return s.add(m),m},d=1;for(let g=0;g<t.rows;g++)for(let b=0;b<t.columns;b++)if(!(g===0&&b===0)){d+=1;for(let f of i){let y=structuredClone(f);y.id=M(e,y.type,t.idFactory,r),y.label=l(f.label,d),y.center={x:f.center.x+b*t.stepX,y:f.center.y+g*t.stepY},delete y.referenceInventorySource,c.push(y)}}return o.objects.push(...c),{...a,createdIds:c.map(g=>g.id)}}function rs(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=E(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var is=new Set(Pe.map(e=>e.key));function Ee(e){return`${e.rowId}:${e.index}`}function as(e){let t=e.lastIndexOf(":"),n=t>0?e.slice(0,t):"",o=t>0?Number(e.slice(t+1)):Number.NaN;if(!n||!Number.isInteger(o)||o<0)throw new u("invalid_operation",`Invalid stable seat id: ${e}`,{seatId:e});return{rowId:n,index:o}}function ss(e,t){e.label||delete e.label,e.displayLabel||delete e.displayLabel,e.dx||delete e.dx,e.dy||delete e.dy,e.skip||delete e.skip,e.categoryKey||delete e.categoryKey,ke(e.glyph)||delete e.glyph;let n=Ce(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),i={};typeof e.commercial.restrictedView=="boolean"&&(i.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(i.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(i.premium=e.commercial.premium),o&&(i.note=o),Object.keys(i).length?e.commercial=i:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&He(t,e)}function cs(e){return Object.keys(e).every(t=>t==="index")}function Po(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(e,t),i=[],a=new Set,r=new Map;for(let s of n){let c=Ee(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 Jt(e,t){let n=Po(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.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&&t.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(t.patch.categoryKey&&j(e,t.patch.categoryKey),t.patch.glyph!=null&&!ke(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(r=>!is.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.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=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,c=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(s&&c)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Ee(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=ee(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&fe(t.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=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(y=>y!=="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 y=rs(d.labelStyle,f);y?d.labelStyle=y:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),ss(d,s),cs(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(Ee)}}function ls(e,t){let n=Po(e,t.floorId,t.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(Ee)}}function ds(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(p=>p.type==="row"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&j(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,p=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!p.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${p.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.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}=t.patch,f=d===void 0?{}:{displayLabel:d},y=ue(f,"Row"),m=g===void 0?void 0:Ot(g,"Row");if(r!==void 0&&fe(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&&qe(b.labelPresentation,"Row");let w=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),I=!1;for(let h of i){let p=JSON.stringify(h),S=w(h),x=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?L(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(v=>v.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),x){let v=L(h);h.origin={x:h.origin.x+x.x-v.x,y:h.origin.y+x.y-v.y}}if(JSON.stringify(h)!==p&&(I=!0),w(h)!==S&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=Xe(h.labelPresentation,r);P?h.labelPresentation=P:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(s!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(c!==void 0||l!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};c===null?delete P.rotation:c!==void 0&&(P.rotation=c),l!==void 0&&(P.style=l),h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(m!==void 0){let v=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==v&&(I=!0)}if(d!==void 0){let v=h.displayLabel;y?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==v&&(I=!0)}}return{floorId:n.floorId,changed:I,rowIds:o}}var us=3;function st(e){return(e%360+360)%360}function fs(e){let t=e.rotation*q;return{x:Math.cos(t),y:Math.sin(t)}}function gs(e,t){let n=Math.abs(st(e-t));return n>180&&(n=360-n),n}function pe(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function _o(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*q;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function bs(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=i=>({x:i.x+t,y:i.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function Ao(e,t){let n=_o(e),o={x:-n.y,y:n.x},i=L(e[0]),a=e.map(c=>({row:c,coord:pe(L(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*t-c.coord;Math.abs(d)>1e-6&&(bs(c.row,o.x*d,o.y*d),delete c.row.arcFanGeneration,delete c.row.rowBlockGeneration,s=!0)}),s}function hs(e,t){let n={x:-t.y,y:t.x},o=L(e[0]),i=e.map(r=>pe(L(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 ps(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=le(e),n=t[0],o=t[t.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,r/(e.seatCount-1))),r>1e-6&&(e.rotation=st(Math.atan2(a,i)/q)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function ys(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${t}${o}`.slice(0,80);if(!n.has(i))return i}return`${t}-${Date.now().toString(36)}`}function ms(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(x=>n.objects.find(v=>v.type==="row"&&v.id===x)),a=o.filter((x,v)=>!i[v]);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(x=>x.path||x.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(x=>x.id)});let c=r[0],l=r.find(x=>gs(x.rotation,c.rotation)>us);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=fs(c),g={x:-d.y,y:d.x},b=Math.max(8,c.seatSpacing*.6),f=r.find(x=>Math.abs(pe(x.origin,c.origin,g))>b);if(f){let x=Math.round(Math.abs(pe(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 ${x} units from the first.`,{rowIds:[c.id,f.id]})}let y=r.slice().sort((x,v)=>pe(x.origin,c.origin,d)-pe(v.origin,c.origin,d)),m=y.reduce((x,v)=>x+v.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let w=y[0],I=[],h=0;for(let x of y){if(x.overrides)for(let v of x.overrides)I.push({...structuredClone(v),index:v.index+h});h+=x.seatCount}w.seatCount=m,w.curve=0,delete w.path,I.length?w.overrides=I:delete w.overrides,delete w.arcFanGeneration,delete w.rowBlockGeneration;let p=y.slice(1).map(x=>x.id),S=new Set(p);for(let x=n.objects.length-1;x>=0;x--)S.has(n.objects[x].id)&&n.objects.splice(x,1);return{floorId:n.floorId,changed:!0,rowId:w.id,removedRowIds:p,seatCount:m}}function ws(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="row"&&f.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.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=t.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=le(o),s=i>1?o.curve/(i-1):0,c=i-a,l={type:"row",id:M(e,"r",t.idFactory,new Set),label:ys(n.objects,o.label),origin:{...r[a]},rotation:st(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 Ss(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.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=Ao(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function xs(e,t){let n=C(e,t.floorId),o=[...new Set(t.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)ps(b);let l=_o(r),d=st(Math.atan2(l.y,l.x)/q);for(let b of r)b.rotation=d;let g=hs(r,l);return Ao(r,g),{floorId:n.floorId,changed:s()!==c,rowIds:o,gap:g}}var lt=rr(require("polygon-clipping"),1),Mo=100,jo=512,qt=8192,Go=64,Lo=1e7,T=1e-7;function Ko(e,t){return Math.abs(e.x-t.x)<=T&&Math.abs(e.y-t.y)<=T}function $o(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ko(t[0],t[t.length-1]);)t.pop();return t}function Te(e,t,n){let o=J(t,n,e);return Math.abs(o)>T?!1:e.x>=Math.min(t.x,n.x)-T&&e.x<=Math.max(t.x,n.x)+T&&e.y>=Math.min(t.y,n.y)-T&&e.y<=Math.max(t.y,n.y)+T}function Bo(e,t,n,o){let i=J(e,t,n),a=J(e,t,o),r=J(n,o,e),s=J(n,o,t);return(i>T&&a<-T||i<-T&&a>T)&&(r>T&&s<-T||r<-T&&s>T)?!0:Math.abs(i)<=T&&Te(n,e,t)||Math.abs(a)<=T&&Te(o,e,t)||Math.abs(r)<=T&&Te(e,n,o)||Math.abs(s)<=T&&Te(t,n,o)}function vs(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&Bo(e[t],e[n],e[o],e[i]))return!0}}return!1}function ko(e,t){return e.some((n,o)=>t.some((i,a)=>Bo(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function Xt(e,t){return!t.some((n,o)=>Te(e,n,t[(o+1)%t.length]))&&F(e,t,void 0)}function dt(e,t,n){let o=$o(e);if(o.length<3||o.length>jo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>Lo||Math.abs(i.y)>Lo||Ko(i,o[(a+1)%o.length]))||Math.abs(xe(o))<=T||vs(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${jo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Is(e){let t=dt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Go)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>dt(i,"cutout",e.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=>Xt(s,t))||ko(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(ko(a,o[s])||Xt(a[0],o[s])||Xt(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function ct(e){return e.map(t=>[t.x,t.y])}function Eo(e){return $o(e.map(([t,n])=>({x:t,y:n})))}function To(e){return Math.abs(e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n[0]*i[1]-i[0]*n[1]},0))/2}function Cs(e){return e.reduce((t,n)=>t+(To(n[0]??[])-n.slice(1).reduce((o,i)=>o+To(i),0)),0)}function Yt(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Yt).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Yt(t[n])}`).join(",")}}`}function Fo(e,t,n){let o=e[t];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 ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return i}function No(e){return Yt({categoryKey:e.categoryKey,displayLabel:Fo(e,"displayLabel",80),displayType:Fo(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function Do(e,t){let n=Math.min(...e.points.map(i=>i.y)),o=Math.min(...e.points.map(i=>i.x));return[n,o,t]}function Os(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function zo(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.gaAreaIds)];if(i.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(i.length>Mo)throw new u("invalid_operation",`Join Areas supports at most ${Mo} areas at once`);let a=i.map(O=>o.objects.find(_=>_.type==="gaArea"&&_.id===O)),r=i.filter((O,_)=>!a[_]);if(r.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:r});let s=a;j(e,s[0].categoryKey);let c=No(s[0]),l=s.find(O=>No(O)!==c);if(l)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:[s[0].id,l.id]});let d=Me(e).objectToSection,g=d.get(s[0].id)??"__ungrouped__",b=s.find(O=>(d.get(O.id)??"__ungrouped__")!==g);if(b)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,b.id],sectionIds:[g,d.get(b.id)??"__ungrouped__"]});let f=s.reduce((O,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>X)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return O+_.capacity},0);if(f>X)throw new u("invalid_operation",`Joined GA capacity would be ${f}, over the ${X}-unit area limit`,{capacity:f});let y=B(e).reduce((O,_)=>O+oe(_),0),m=n.maxInventory??1e5;if(y>m)throw new u("invalid_operation",`Chart inventory exceeds the ${m}-unit publication limit`,{inventory:y});let w=s.map(Is),I=w.reduce((O,_)=>O+_.outer.length+_.holes.reduce((V,Z)=>V+Z.length,0),0);if(I>qt)throw new u("invalid_operation",`Join Areas supports at most ${qt} source vertices`,{vertexCount:I});let h;try{let O=w.map(Z=>[ct(Z.outer)]);if(h=lt.default.union(O[0],...O.slice(1)),h.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:h.length});let _=w.flatMap(Z=>Z.holes.map(bt=>[ct(bt)]));_.length&&(h=lt.default.difference(h,..._));let V=w.findIndex(Z=>{let bt=[ct(Z.outer),...Z.holes.map(ct)];return Cs(lt.default.intersection(bt,h))<=T});if(V>=0)throw new u("invalid_operation",`GA area ${s[V].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[V].id})}catch(O){throw O instanceof u?O:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:O instanceof Error?O.message:"polygon_union_failed"})}if(h.length!==1||!h[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:h.length});let p=Eo(h[0][0]),S=h[0].slice(1).map(Eo),x=p.length+S.reduce((O,_)=>O+_.length,0);if(S.length>Go||x>qt)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:S.length,vertexCount:x});dt(p,"outline",s[0].id),S.forEach(O=>dt(O,"cutout",s[0].id));let v=new Map(o.objects.map((O,_)=>[O.id,_])),P=s.slice().sort((O,_)=>Os(Do(O,v.get(O.id)??Number.MAX_SAFE_INTEGER),Do(_,v.get(_.id)??Number.MAX_SAFE_INTEGER))),N=P[0],G=structuredClone(e),K=C(G,o.floorId),$=K.objects.find(O=>O.type==="gaArea"&&O.id===N.id);$.points=structuredClone(p),S.length?$.holes=structuredClone(S):delete $.holes;let R=new Set(P.slice(1).map(O=>O.id));for(let O=K.objects.length-1;O>=0;O-=1)R.has(K.objects[O].id)&&K.objects.splice(O,1);let z=Me(G).objectToSection.get(N.id)??"__ungrouped__";if(z!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:N.id,beforeSectionId:g,afterSectionId:z});let A=[],Se=new Set;for(let O of P){if(!Mt(O))throw new u("invalid_operation",`GA area ${O.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:O.id});let _=W(O);if(_.length!==O.capacity||_.some(V=>Se.has(V)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:O.id});_.forEach(V=>Se.add(V)),A.push(...Ze(O))}if(A.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let Yo=new Set(s.map(O=>O.id));for(let O of B(e).filter(_=>_.type==="gaArea"&&!Yo.has(_.id))){let _=W(O).find(V=>Se.has(V));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:O.id})}let Qo=P.slice(1).map(O=>O.id);return{floorId:o.floorId,areaId:N.id,survivorLabel:N.label,removedAreaIds:Qo,sourceAreaCount:P.length,capacity:f,inventorySegmentCount:A.length,outerVertexCount:p.length,holeCount:S.length,sectionId:g,points:p,...S.length?{holes:S}:{},segments:A}}function Rs(e,t,n={}){let{segments:o,...i}=zo(e,t,n);return i}function Ps(e,t,n={}){let o=zo(e,t,n),i=C(e,o.floorId),a=i.objects.find(l=>l.type==="gaArea"&&l.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes,a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments);let r=new Set(o.removedAreaIds);for(let l=i.objects.length-1;l>=0;l-=1)r.has(i.objects[l].id)&&i.objects.splice(l,1);let{segments:s,...c}=o;return{...c,changed:!0}}function _s(e,t){let n=C(e,t.floorId),o=[...new Set(t.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(t.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.labelStyle!==void 0){let l=i.filter(d=>d.role!=="stage");if(l.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:l.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<de||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${de} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=E(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");for(let d of["bold","italic","underline"]){let g=r.labelStyle[d];if(g!=null&&typeof g!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=E(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:E(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&&!to.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!no.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&&!oo.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=>!Gt(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.labelStyle!==void 0){let g={...l.labelStyle};r.labelStyle.size===null?delete g.size:r.labelStyle.size!==void 0&&(g.size=r.labelStyle.size),r.labelStyle.color===null?delete g.color:r.labelStyle.color!==void 0&&(g.color=r.labelStyle.color),r.labelStyle.fontFamily===null?delete g.fontFamily:r.labelStyle.fontFamily!==void 0&&(g.fontFamily=r.labelStyle.fontFamily),r.labelStyle.bold===null?delete g.bold:r.labelStyle.bold!==void 0&&(g.bold=r.labelStyle.bold),r.labelStyle.italic===null||r.labelStyle.italic===!1?delete g.italic:r.labelStyle.italic===!0&&(g.italic=!0),r.labelStyle.underline===null||r.labelStyle.underline===!1?delete g.underline:r.labelStyle.underline===!0&&(g.underline=!0),Object.keys(g).length?l.labelStyle=g:delete l.labelStyle}if(r.fill===null?delete l.fill:r.fill!==void 0&&(l.fill=r.fill),r.kind!==void 0&&(l.kind=r.kind,Gt(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&&(Be(l),c=!0)}return{floorId:n.floorId,changed:c,shapeIds:o}}function Ho(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.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 As(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.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"?Ho(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(w=>!Number.isFinite(w.x)||!Number.isFinite(w.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=l.map(w=>w.x),g=l.map(w=>w.y),b=Math.min(...d),f=Math.max(...d),y=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(y+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-y)}})();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 Ms(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.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(bn.map(s=>s.key)),a=t.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:Ho(c)}}),r=!1;for(let s of a)s.box&&(s.shape.points=hn({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}))}}function Vo(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of k(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function ut(e){return Array.isArray(e)?e.map(ut):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,ut(n)]))}function Ls(e,t){return JSON.stringify(ut(e))===JSON.stringify(ut(t))}function Qt(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function ks(e){return e?e.status==="retracted"?"retract":Qt(e)?"approve":"set":"clear"}function Jo(e,t){let n=Vo(e),o=Vo(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let s=n.get(r),c=o.get(r);if(s&&c&&Ls(s.evidence,c.evidence))continue;let l=c?.target??s?.target;l&&a.push({...l,operation:ks(c?.evidence),...s?{before:s.evidence}:{},...c?{after:c.evidence}:{}})}return a}function Es(e,t){return Jo(e,t).some(n=>Qt(n.before)||Qt(n.after))}var Ts=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Fs=new Set(["generated","geometry-verified","configuration-verified"]),Ns=new Set(["none","comparable-build-reference","actual-build-checked"]),Ds=new Set(["clear","partial","obstructed"]);function Wt(e){return e.toISOString().slice(0,10)}function Zt(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function me(e,t,n){if(!Zt(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function ye(e,t,n){if(e!==void 0)return me(e,t,n)}function ft(e,t,n){let o=n?[C(e,n)]:k(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function qo(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Fe(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return qo(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(i=>i.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=ft(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function gt(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=qo(e,t.floorId);return n?i.confidenceEvidence=n:delete i.confidenceEvidence,{floorId:i.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let i=ft(e,t.objectId,t.floorId);return Jt(e,{floorId:i.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:i.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function Gs(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!Zt(e.label,80)||!Zt(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!Ds.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>me(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function Xo(e,t=new Date){if(e.schema!==void 0&&e.schema!=="seatlayer.seat-confidence/1")throw new u("invalid_operation","Confidence evidence schema must be seatlayer.seat-confidence/1");if(!Ts.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Fs.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Ns.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=ye(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let i=e.limitations?.map(d=>me(d,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=ye(e.assessedAt,40,"assessedAt")??Wt(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=ye(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Wt(new Date(r+365*24*60*60*1e3))),c=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(c)||c<r||c>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=ye(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");return{schema:"seatlayer.seat-confidence/1",evidenceId:me(e.evidenceId,120,"evidenceId"),modelVersion:me(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...l?{approvedByRole:l}:{},...ye(e.sourceLabel,120,"sourceLabel")?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:Gs(e.modeledTarget)}:{}}}function we(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function Ks(e,t){let n=Xo(t.evidence,t.now),o=JSON.stringify(Fe(e,t)??null),i=gt(e,t,n),a=JSON.stringify(Fe(e,t)??null);return we(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function $s(e,t){let n=Fe(e,t);if(!n)return we(t,{changed:!1});let o=gt(e,t,void 0);return we(t,{changed:!0,...o,evidenceId:n.evidenceId})}function Bs(e,t){let n=Fe(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=me(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=ye(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!i)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let r={...n,status:"approved",approvedByRole:o,assessedAt:Wt(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(r.basisSha256=s);let c=JSON.stringify(n),l=gt(e,t,r);return we(t,{changed:c!==JSON.stringify(r),...l,evidenceId:r.evidenceId,status:"approved"})}function zs(e,t){let n=Fe(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return we(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=gt(e,t,o);return we(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
1
+ "use strict";var Zo=Object.create;var De=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty;var rr=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})},tn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of tr(t))!or.call(e,i)&&i!==n&&De(e,i,{get:()=>t[i],enumerable:!(o=er(t,i))||o.enumerable});return e};var ir=(e,t,n)=>(n=e!=null?Zo(nr(e)):{},tn(t||!e||!e.__esModule?De(n,"default",{value:e,enumerable:!0}):n,e)),ar=e=>tn(De({},"__esModule",{value:!0}),e);var Hs={};rr(Hs,{COLORBLIND_SAFE_PALETTE:()=>$t,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>At,DEFAULT_SECTION_CORNER_SMOOTHING:()=>St,MAX_BUYER_IMAGE_URL_LENGTH:()=>Pr,MAX_FLOOR_BASE_HEIGHT_M:()=>Qe,addArcFanRows:()=>Aa,addBookableGridArray:()=>rs,addBoothArray:()=>Na,addChartCategory:()=>lo,addChartFloor:()=>ti,addChartZone:()=>ii,addGAArea:()=>Ta,addRowBlock:()=>La,addTableArray:()=>Fa,applyPolygonHole:()=>Ui,applyReferenceScanRows:()=>ns,applySectionCornerSmoothing:()=>Zi,applySectionOutlineShaping:()=>eo,applySectionRowFit:()=>Bi,approveConfidenceEvidence:()=>zs,arcFanInputForGroup:()=>go,assignSectionInventoryCategory:()=>qi,automaticPlacementCenter:()=>Oa,clearConfidenceEvidence:()=>Bs,compactChartDoc:()=>Ur,compactRowOverrides:()=>Mn,compactTableOverrides:()=>jn,confidenceEvidenceChangeRequiresPublish:()=>Ts,confidenceEvidenceChanges:()=>Jo,confirmReferenceCategoryOutputColor:()=>ca,convertGeneratedSectionToPolygon:()=>Xi,countCoveredInventory:()=>nt,detectSeatLabelRun:()=>_n,dropRedundantSeatOverrideFields:()=>Ve,familyCategoryLabel:()=>uo,gaAreaFootprint:()=>po,groupRowsAsSegmented:()=>Da,insertSeatingBlock:()=>Ni,isSafeBuyerImageUrl:()=>yn,joinGAAreas:()=>_s,mergeRows:()=>ws,mirrorFirstFloor:()=>Ae,normalizeBuyerImageUrl:()=>ee,normalizeDraftEvidence:()=>Yo,parseSeatRefId:()=>ss,pickColorblindSafeCategoryColor:()=>co,planCreationCategory:()=>fo,previewArcFanRows:()=>Bt,previewBookableGridArray:()=>os,previewGeneratedSectionPolygonConversion:()=>Wn,previewJoinGAAreas:()=>Ps,previewPolygonHole:()=>rt,previewRemovePolygonHole:()=>Xn,previewRowCubicPath:()=>Vn,previewSectionRowFit:()=>qn,reassignColorblindSafeCategoryColors:()=>sa,relabelChartRows:()=>Fi,removeChartCategory:()=>Sa,removeChartFloor:()=>ri,removeChartObjects:()=>Ei,removeChartZone:()=>si,removePolygonHole:()=>Hi,renameChartFloor:()=>ni,renameDirectSeatImportCategory:()=>oa,reorderChartCategories:()=>ra,replaceArcFanRows:()=>Ma,replaceRowBlock:()=>$a,resetSeatOverrides:()=>ds,resizeShapes:()=>Ms,resolveCreationCategory:()=>ya,retractConfidenceEvidence:()=>Us,roundBuyerCoordinates:()=>Vr,seatRefId:()=>Te,seatSemanticsSignature:()=>Ct,sectionInventorySelectionSummary:()=>Qn,setConfidenceEvidence:()=>$s,setRowBlockSpacing:()=>xs,splitRow:()=>Ss,straightenAndSpaceRows:()=>vs,transformSectionBoundary:()=>Yi,transformSectionBoundaryObject:()=>Zn,ungroupSegmentedRow:()=>Ga,updateBooths:()=>Li,updateCategoryDefinitions:()=>so,updateChartFloorBaseHeight:()=>oi,updateChartTheme:()=>Ia,updateChartZones:()=>ai,updateGAAreas:()=>ki,updateRowCubicPath:()=>Gi,updateRows:()=>us,updateSeatOverrides:()=>Jt,updateSectionExactPath:()=>Qi,updateSectionMetadata:()=>Ji,updateSegmentedRow:()=>Ka,updateShapes:()=>As,updateStageKinds:()=>js,updateTables:()=>ji,updateTextObjects:()=>Ti,updateViewFromSeatFallback:()=>Ca});module.exports=ar(Hs);var nn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function sr(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/nn(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let s of a.split(/\s+/)){let l=s.length;r&&r+1+l<=o?r+=1+l:(i+=Math.max(1,Math.ceil(l/o)),r=l%o)}}return Math.max(1,i)}function on(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*nn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=sr(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var Js=Math.PI/180;function D(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function pt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function rn(e,t){let n=1-t,o=n*n*n,i=3*n*n*t,a=3*n*t*t,r=t*t*t;return{x:o*e.start.x+i*e.control1.x+a*e.control2.x+r*e.end.x,y:o*e.start.y+i*e.control1.y+a*e.control2.y+r*e.end.y}}function Ge(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[rn(e,.5)];let o=Array.from({length:n+1},(l,c)=>rn(e,c/n)),i=new Float64Array(o.length);for(let l=1;l<o.length;l+=1){let c=o[l].x-o[l-1].x,d=o[l].y-o[l-1].y;i[l]=i[l-1]+Math.hypot(c,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],s=1;for(let l=0;l<t;l+=1){let c=a*l/(t-1);for(;s<i.length-1&&i[s]<c;)s+=1;let d=i[s-1],f=i[s],b=f===d?0:(c-d)/(f-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 ve(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 Ie(e,t,n){return Math.max(t,Math.min(n,e))}function cr(e){return Ie(e,0,1)}function an(e){let t=cr(e);return t*t*(3-2*t)}var ae=Math.PI*2;function se(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function lr(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ae;for(;o>=ae;)o-=ae}else{for(;o>0;)o-=ae;for(;o<=-ae;)o+=ae}return o}function Ke(e){if(e.version!==1||e.closed!==!0||!se(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||!se(n.end))return!1;if(n.kind==="line"){if(D(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!se(n.control1)||!se(n.control2)||D(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!se(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(D(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(D(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||D(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return D(t,e.start)<=1e-4}function dr(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 mt(e,t=2){if(!Ke(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.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),l=lr(r,s,a.clockwise),c=Math.max(2,Math.ceil(Math.abs(l)*a.radius/n));for(let d=1;d<=c;d+=1){let f=r+l*d/c;o.push({x:a.center.x+Math.cos(f)*a.radius,y:a.center.y+Math.sin(f)*a.radius})}}else{let r=D(i,a.control1)+D(a.control1,a.control2)+D(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let l=1;l<=s;l+=1)o.push(dr(i,a,l/s))}i=a.end}return D(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function ln(e,t,n){return wt(e,i=>({x:i.x+t,y:i.y+n}))}function wt(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(i=>i.kind==="line"?{...i,end:t(i.end)}:i.kind==="arc"?{...i,center:t(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:t(i.end)}:{...i,control1:t(i.control1),control2:t(i.control2),end:t(i.end)})}}var St=45,yt=150,ur=60;function fr(e){let t=St/100;if(e<=t)return yt;let n=Math.min(1,(e-t)/(1-t));return yt-n*(yt-ur)}var sn=.5523;function cn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function gr(e){let t=[],n=[];for(e.forEach((o,i)=>{se(o)&&(t.length&&cn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&cn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var br=.5,hr=4/3;function pr(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,s=o/a,l=n*hr;return{kind:"bezier",control1:{x:e.x+o/3+r*l,y:e.y+i/3+s*l},control2:{x:e.x+o*2/3+r*l,y:e.y+i*2/3+s*l},end:{...t}}}function dn(e,t){let{points:n,sourceIndex:o}=gr(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let S=0;S<i;S+=1){let x=r[o[S]];s[S]=Number.isFinite(x)?Math.min(100,Math.max(-100,x))/100:0}let l=s.some(S=>Math.abs(S)>1e-6);if(a<=0&&!l)return null;let c=t.wideAngleThresholdDeg??fr(a),d=[];for(let S=0;S<i;S+=1)d[S]=D(n[S],n[(S+1)%i]);let f=new Array(i).fill(0);for(let S=0;S<i;S+=1){let x=n[(S-1+i)%i],v=n[S],P=n[(S+1)%i],N={x:x.x-v.x,y:x.y-v.y},G={x:P.x-v.x,y:P.y-v.y},K=Math.hypot(N.x,N.y),$=Math.hypot(G.x,G.y);if(K<=1e-9||$<=1e-9)continue;let R=Math.min(1,Math.max(-1,(N.x*G.x+N.y*G.y)/(K*$))),z=Math.acos(R)*180/Math.PI;if(z<c)continue;let A=an((z-c)/(180-c));f[S]=a*A*.5*Math.min(K,$)}for(let S=0;S<i;S+=1){let x=(S+1)%i,v=f[S]+f[x];if(v>d[S]&&v>1e-9){let P=d[S]/v;f[S]*=P,f[x]*=P}}let b=new Array(i),g=new Array(i);for(let S=0;S<i;S+=1){let x=n[(S-1+i)%i],v=n[S],P=n[(S+1)%i];if(f[S]<=1e-6){b[S]={...v},g[S]={...v};continue}let N=D(v,x)||1,G=D(v,P)||1;b[S]={x:v.x+(x.x-v.x)/N*f[S],y:v.y+(x.y-v.y)/N*f[S]},g[S]={x:v.x+(P.x-v.x)/G*f[S],y:v.y+(P.y-v.y)/G*f[S]}}if(f.every(S=>S<=1e-6)&&!l)return null;let y=[],m={...g[0]},w=m,I=(S,x)=>{if(D(w,S)<=1e-9)return;let v=s[x];Math.abs(v)>1e-6?y.push(pr(w,S,v*br*d[x])):y.push({kind:"line",end:{...S}}),w=S};for(let S=1;S<=i;S+=1){let x=S%i,v=n[x];I(b[x],(S-1)%i),f[x]>1e-6&&D(b[x],g[x])>1e-9&&(y.push({kind:"bezier",control1:pt(b[x],v,sn),control2:pt(g[x],v,sn),end:{...g[x]}}),w=g[x])}if(!y.length)return null;let h=y[y.length-1];D(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:y.push({kind:"line",end:{...m}}));let p={version:1,closed:!0,start:m,segments:y};return Ke(p)?p:null}var un="ABCDEFGHIJKLMNOPQRSTUVWXYZ",yr="ABCDEFGHJKLMNPQRSTUVWXYZ",mr="abcdefghijklmnopqrstuvwxyz";function fn(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function wr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?yr:un;return fn(o,i)}function xt(e,t=!1){let n=t?mr:un;return fn(Math.max(0,Math.floor(e)-1),n)}var Sr=[[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 gn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of Sr)for(;t>=o;)n+=i,t-=o;return n}function bn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:wr(a,t)}})}function xr(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 ce(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,l=e.seatCount;if(a==="updown"||a==="updown-descending"){let g=Math.ceil(l/2),y=a==="updown"?t<g?n+2*t:n-1+2*(l-t):t<g?n+2*(g-1-t):n+1+2*(t-g);return`${r}${y}`}let c=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(l-1)*c:n,f=o==="center"?xr(l)[t]:o==="rtl"?l-1-t:t,b;switch(a){case"odd":{let g=d%2===1?d:d+1;b=String(g+f*2);break}case"even":{let g=d%2===0?d:d+1;b=String(g+f*2);break}case"roman":b=gn(d+f*i);break;case"letters-upper":b=xt(d+f*i,!1);break;case"letters-lower":b=xt(d+f*i,!0);break;default:b=String(d+f*i);break}return`${r}${b}`}function vr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Y(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${ce(e,t)}`}function Ce(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return ce(e,t);if(!n)return`${e.displayLabel||e.label}-${ce(e,t)}`;let i=vr(n),a=n.displayOffset+t;return`${n.displayLabel}-${ce(i,a)}`}var hn=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."}];var Ir=Math.PI*2;function Cr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function pn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,s=Math.cos(r),l=Math.sin(r),c=i/2,d=a/2,f=[],b=(g,y)=>{f.push({x:g,y})};switch(t){case"rect":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"rounded":{let g=Math.min(i,a)*.18,y=5,m=(w,I,h)=>{for(let p=0;p<=y;p++){let S=h+p/y*(Math.PI/2);b(w+g*Math.cos(S),I+g*Math.sin(S))}};m(c-g,-d+g,-Math.PI/2),m(c-g,d-g,0),m(-c+g,d-g,Math.PI/2),m(-c+g,-d+g,Math.PI);break}case"arc":{let g=a*.45;b(-c,-d),b(c,-d);let y=24;for(let m=0;m<=y;m++){let w=m/y,I=c-w*i,h=d+g*(1-Math.pow(2*I/i,2));b(I,h)}break}case"thrust":{let g=i*.18,y=a*1.1;b(-c,-d),b(c,-d),b(c,d),b(g,d),b(g,d+y),b(-g,d+y),b(-g,d),b(-c,d);break}case"runway":{let g=i*.1,y=a*3;b(-c,-d),b(c,-d),b(c,d),b(g,d),b(g,d+y),b(-g,d+y),b(-g,d),b(-c,d);break}case"round":case"oval-cricket":{for(let y=0;y<40;y++){let m=y/40*Ir;b(c*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"rink-hockey":{for(let g of Or(c,d,c*(8.5/60),d*(8.5/30)))b(g.x,g.y);break}case"track-athletics":{for(let g of Rr(c,d))b(g.x,g.y);break}}return f.map(g=>Cr(g.x,g.y,s,l,n,o))}function Or(e,t,n,o){let i=[],r=(s,l,c)=>{for(let d=0;d<=8;d++){let f=c+d/8*(Math.PI/2);i.push({x:s+n*Math.cos(f),y:l+o*Math.sin(f)})}};return r(e-n,-t+o,-Math.PI/2),r(e-n,t-o,0),r(-e+n,t-o,Math.PI/2),r(-e+n,-t+o,Math.PI),i}function Rr(e,t){let n=Math.max(0,e-t),o=[],i=20;for(let a=0;a<=i;a++){let r=-Math.PI/2+a/i*Math.PI;o.push({x:n+t*Math.cos(r),y:t*Math.sin(r)})}for(let a=0;a<=i;a++){let r=Math.PI/2+a/i*Math.PI;o.push({x:-n+t*Math.cos(r),y:t*Math.sin(r)})}return o}var Pr=2e6,_r=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Ar=/[\s"'<>`\\]/;function yn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return _r.test(e);if(Ar.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ee(e){let t=e.trim();return yn(t)?t:null}function Oe(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Be=Math.PI/180,Mr=9,le=16;function It(e,t,n,o){let i=n*Be,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function de(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return Ge(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let c=0;c<t;c++)r.push(It(c*n,0,i,a));return r}let s=o/(t-1)*Be,l=n/(2*Math.sin(Math.abs(s)/2));for(let c=0;c<t;c++){let d=c*s,f=l*Math.sin(d),b=-l+l*Math.cos(d);r.push(It(f,b,i,a))}return r}function Sn(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function jr(e,t){let n=Sn(e);return de(e).map((o,i)=>{let a=n.get(i),r=Oe(a),s=Y(e,i,a),l={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Ce(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(l).some(c=>c!==void 0&&c!==!1&&c!=="")?l:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function H(e){let t=[];for(let n of jr(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function Lr(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(e.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function kr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,f,b,g)=>{let y=o.get(d),m=Oe(y),w=y?.label??`${e.label}-${d+1}`,I=e.displayLabel??e.label;return{index:d,label:w,displayLabel:y?.displayLabel??`${I}-${d+1}`,x:f+(y?.dx??0),y:b+(y?.dy??0),categoryKey:y?.categoryKey??e.categoryKey,skipped:!!y?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:y?.wheelchairSpaceType,commercial:y?.commercial,glyph:y?.glyph,viewUrl:y?.viewFromSeatUrl,viewMeta:y?.viewFromSeatUrl?y.viewFromSeatMeta:void 0,labelStyle:y?.labelStyle,...g?{side:g}:{}}};if(e.shape==="round"){let d=(e.radius??40)+le,f=e.rotation*Be,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let w=0;w<n;w++){let I=f+w/n*2*Math.PI;t.push(i(w,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let g=b*Be,y=(2*Math.PI-g)/2,m=f+y;for(let w=0;w<n;w++){let I=m+w/(n-1)*g;t.push(i(w,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,r=e.height??50,s=Lr(e),l=["top","bottom","left","right"],c=0;for(let d of l){let f=s[d];for(let b=0;b<f;b++){let g,y;d==="top"?(g=-a/2+(b+.5)*a/f,y=-r/2-le):d==="bottom"?(g=-a/2+(b+.5)*a/f,y=r/2+le):d==="left"?(g=-a/2-le,y=-r/2+(b+.5)*r/f):(g=a/2+le,y=-r/2+(b+.5)*r/f);let m=It(g,y,e.rotation,e.center);t.push(i(c++,m.x,m.y,d))}}return t}function ne(e){return kr(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function xn(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 mn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,s=t[i].x,l=t[i].y;r>e.y!=l>e.y&&e.x<(s-a)*(e.y-r)/(l-r)+a&&(n=!n)}return n}function Er(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.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 te(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function F(e,t,n){return mn(e,t)&&!te(n).some(o=>mn(e,o)||Er(e,o))}function vt(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 L(e){switch(e.type){case"row":{let t=de(e),n=Sn(e),o=0,i=0,a=0;for(let r=0;r<t.length;r++){let s=n.get(r);s?.skip||(o+=t[r].x+(s?.dx??0),i+=t[r].y+(s?.dy??0),a++)}return a?{x:o/a,y:i/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return vt(e.points);case"section":return vt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?vt(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 wn(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Tr(e,t){if(e.type!=="gaArea"||!wn(e.points,t.outline))return!1;let n=te(e.holes),o=te(t.holes);return n.length===o.length&&n.every((i,a)=>wn(i,o[a]))}function vn(e,t,n=e.filter(i=>i.type==="section"),o=L(t)){let i="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(i?n.find(r=>(r.logicalSectionId??r.id)===i&&(Tr(t,r)||F(o,r.outline,r.holes))):void 0)??n.find(r=>F(o,r.outline,r.holes))}function k(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 B(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var $e=40;function In(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,s=(c,d)=>{c<o&&(o=c),d<i&&(i=d),c>a&&(a=c),d>r&&(r=d)},l=c=>{if(Array.isArray(c))for(let d of c)!d||typeof d!="object"||s(d.x,d.y)};for(let c of B(e))if(c.type==="row"){let d=new Map((c.overrides??[]).map(f=>[f.index,f]));de(c).forEach((f,b)=>{let g=d.get(b);g?.skip||s(f.x+(g?.dx??0),f.y+(g?.dy??0))})}else if(c.type==="gaArea")l(c.points);else if(c.type==="section")l(c.outline);else if(c.type==="decorImage")s(c.x,c.y),s(c.x+c.width,c.y+c.height);else if(c.type==="shape")c.points&&c.points.length?l(c.points):c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null&&(s(c.x,c.y),s(c.x+c.width,c.y+c.height));else if(c.type==="table"){let d=le+Mr,f=c.shape==="round"?(c.radius??40)+d:Math.max((c.width??80)/2,(c.height??50)/2)+d;s(c.center.x-f,c.center.y-f),s(c.center.x+f,c.center.y+f)}else if(c.type==="booth"){let d=Math.max(c.width,c.height)/2;s(c.center.x-d,c.center.y-d),s(c.center.x+d,c.center.y+d)}else if(c.type==="text"){if(n)continue;let d=on(c);s(c.position.x,c.position.y),s(c.position.x+d.width,c.position.y+d.height)}for(let c of[e.referenceImage,e.backgroundImage]){if(!c)continue;let{center:d,width:f}=c;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(f))continue;let b=f*3/4;s(d.x-f/2,d.y-b/2),s(d.x+f/2,d.y+b/2)}if(!isFinite(o)){let c=e.focalPoint??{x:0,y:0};return{x:c.x-200,y:c.y-200,width:400,height:400}}return{x:o-$e,y:i-$e,width:a-o+$e*2,height:r-i+$e*2}}function ze(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}var Fr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Pn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Pe(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Ct(e){let t=Pe(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of Fr){let s=i?.[r];s!==void 0&&(a[r]=s)}n.push([Y(e,o,i),Ce(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function Nr(e){return JSON.parse(JSON.stringify(e))}function Ue(e,t){let n=Nr(e);return t(n)&&Ct(n)===Ct(e)?n:e}function Dr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Pe(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let i=t.get(o)?.labelStyle;if(!i)return!1;if(!n)n=i;else if(!Pn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Gr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function _n(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let r=Gr(a.slice(n.length+1));if(r===void 0)return;o.push(r)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let i=o[1]-o[0];if(!(i!==1&&i!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==i)return;return i===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Kr(e){if(e.seatCount<1)return!1;let t=Pe(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(Y(e,i,t.get(i)));let o=_n(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let i of e.overrides??[])delete i.label;return!0}function $r(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Pe(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==ce(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Ve(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Pn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===Y(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===Ce(e,t.index)&&delete t.displayLabel}function An(e){return Object.keys(e).every(t=>t==="index")}function Br(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Ve(e,n);let t=e.overrides.filter(n=>!An(n));return t.length?e.overrides=t:delete e.overrides,!0}function zr(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Pe(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function Mn(e){if(e.type!=="row")return e;let t=Ue(e,Dr);return t=Ue(t,Kr),t=Ue(t,$r),t=Ue(t,Br),zr(e,t)?t:e}function jn(e){if(!e.overrides?.length)return e;let t=e.displayLabel??e.label,n=[];for(let i of e.overrides){let a={...i};a.label===`${e.label}-${a.index+1}`&&delete a.label,a.displayLabel===`${t}-${a.index+1}`&&delete a.displayLabel,a.categoryKey===e.categoryKey&&delete a.categoryKey,a.dx===0&&delete a.dx,a.dy===0&&delete a.dy,An(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function Cn(e){return e.type==="row"?Mn(e):e.type==="table"?jn(e):e}function Ur(e){let t=e.objects.map(Cn),n=e.floors?.map(o=>({...o,objects:o.objects.map(Cn)}));return{...e,objects:t,...n?{floors:n}:{}}}var On=2,Hr=3,Rn=6;function Re(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function He(e){return{...e,x:Re(e.x,On),y:Re(e.y,On)}}function Vr(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=He(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(He)),Array.isArray(t.points)&&(t.points=t.points.map(He)),typeof t.rotation=="number"&&(t.rotation=Re(t.rotation,Rn)),typeof t.seatSpacing=="number"&&(t.seatSpacing=Re(t.seatSpacing,Rn));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:He(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let s=Re(r,Hr);s===0?delete i[a]:i[a]=s}return i})),t}var qr=36,Jr=160;function Ln(e,t=360){let n=Ie(Math.round(Number.isFinite(e)?e:1),1,40),o=Ie(Number.isFinite(t)?t:360,120,360);return Math.round(Ie(n*4*(360/o),qr,Jr))}var _e=[{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"}],mc=new Map(_e.map(e=>[e.key,e]));var Xr=[{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"}],wc=new Map(Xr.map(e=>[e.key,e]));var ue=8,Ot=24,Yr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Sc=new Set(Yr);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function j(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function M(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Qr(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;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 t){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=t.length-1;a>=0;a--){let r=t[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 Wr(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.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*t,y:o.y+a/r*t}})}function oe(e){let t=[];for(let o of e)o.type==="row"?t.push(...H(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ne(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Wr(Qr(t),22);return n.length>=3?n:null}function qe(e,t){let n=C(e,t),o=k(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var kn=24,En=80;function Rt(e,t){let n=e.normalize("NFKC").trim();if(n.length>kn)throw new u("invalid_operation",`${t} displayed type must be at most ${kn} characters`);return n}function Je(e,t){if(e.displayType===void 0)return!1;let n=Rt(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function fe(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>En)throw new u("invalid_operation",`${t} displayed label must be at most ${En} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function E(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function Tn(e,t){if(!Number.isFinite(e)||e<ue||e>Ot)throw new u("invalid_operation",`${t} label size must be from ${ue} to ${Ot}`)}function ge(e,t){e.size!==void 0&&e.size!==null&&Tn(e.size,t),e.color!==void 0&&e.color!==null&&E(e.color,`${t} label color`)}function Xe(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&Tn(n.size,t),n.color!==void 0&&E(n.color,`${t} label color`))}function Ye(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=E(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function Pt(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.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 _t(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function q(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var Q=Math.PI/180,J=Math.PI/180;function re(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function Ae(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var Zr=0,Qe=120,At=4;function ei(e){if(!Number.isFinite(e)||e<Zr||e>Qe)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ti(e,t){let n=k(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.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(l=>l.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(Qe,(e.floors.length-1)*At),r=Math.min(Qe,a+At),s=M(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),Ae(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:r}}function ni(e,t){let n=k(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.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 oi(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(i=>i.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});ei(t.baseHeightM);let o=n.baseHeightM!==t.baseHeightM;return o&&(n.baseHeightM=t.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:t.baseHeightM}}function ri(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(i=>i.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[i]=e.floors;e.objects=i.objects,e.focalPoint=i.focalPoint,e.referenceImage=i.referenceImage,e.backgroundImage=i.backgroundImage,e.floors=void 0}else Ae(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:k(e).length}}function ii(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:M(e,"zone",t.idFactory,new Set),label:Pt(e,t.label),color:E(t.color,"Zone color"),...t.focalPoint?{focalPoint:_t(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function ai(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(l=>l.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((e.zones??[]).map(l=>[l.id,l])),i=n.filter(l=>!o.has(l));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(e),r=new Map((a.zones??[]).map(l=>[l.id,l]));for(let l of t.updates){if(!Object.keys(l.patch).length)throw new u("invalid_operation",`Zone ${l.zoneId} has no changes`);let d=r.get(l.zoneId);l.patch.label!==void 0&&(d.label=Pt(a,l.patch.label,d.id)),l.patch.color!==void 0&&(d.color=E(l.patch.color,"Zone color")),l.patch.focalPoint!==void 0&&(d.focalPoint=_t(l.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(l=>structuredClone(r.get(l)))}}function si(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=k(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.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 e.zones.splice(n,1),e.zones.length||delete e.zones,Ae(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var We=[{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 Ze(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&t.set(a,(t.get(a)??0)+r)};i(e.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??e.categoryKey);return t}var Mt="__sl_ga__";function Me(e){return e.startsWith(Mt)}var ci=Mt,X=1e5;function li(e,t){return`${ci}${encodeURIComponent(e)}__${t+1}`}function jt(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){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>X||(n+=i.count,n>X))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===e.capacity}function et(e){let t=Math.min(X,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:jt(e)?e.inventorySegments.map(n=>({...n})):[]}function W(e){return et(e).flatMap(t=>Array.from({length:t.count},(n,o)=>li(t.sourceAreaId,t.startIndex+o)))}function Lt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=et(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,l)=>Math.max(s,l.startIndex+l.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var di="__ungrouped__";function ui(e){return e.type==="row"?H(e).map(t=>t.label):e.type==="table"?ne(e).map(t=>t.label):e.type==="booth"?xn(e).map(t=>t.label):e.type==="gaArea"?W(e):[]}function fi(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function gi(e){return e.displayLabel||e.label||"Section"}function bi(e){let t=new Map;for(let n of B(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:gi(n),zone:n.zone})}return t}function hi(e,t){let n=B(e),o=n.filter(s=>s.type==="section"),i=new Map;for(let[s,l]of bi(e))i.set(s,{id:s,label:l.label,zone:l.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:di,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},r=new Map;for(let s of n){if(!fi(s))continue;let l=ui(s);if(l.length===0)continue;let c;if(t)c=t.get(s.id);else{let f=vn(n,s,o);c=f?f.logicalSectionId??f.id:void 0}let d=c?i.get(c):a;d.seatCount+=l.length,d.objectIds.push(s.id),d.seatLabels.push(...l),r.set(s.id,d.id)}return{sections:[...i.values()],ungrouped:a.objectIds.length?a:null,objectToSection:r}}function je(e){return hi(e,null)}var ie={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 Le(e,t,n,o,i,a,r=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function pi(e,t,n,o,i,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function Fn(e,t,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}function yi(e,t,n,o,i){let a=n*2,r=[];for(let s=0;s<a;s++){let l=s%2===0,c=l?["wheelchair"]:["companion"];r.push(l?{index:s,accessibility:c,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:c})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Nn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[ie.balcony],sectionLabel:"Balcony",build:()=>[Le("blk-b0","A",-45,18,24,"balcony",18),Le("blk-b1","B",-15,20,24,"balcony",18),Le("blk-b2","C",15,22,24,"balcony",18),Le("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[ie.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>Le(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[ie.standard],build:()=>[Fn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[ie.premium],build:()=>Array.from({length:6},(e,t)=>pi(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[ie.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"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[ie.standard],build:()=>[Fn("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[ie.standard],build:()=>[yi("blk-wc","A",4,40,"standard")]}];function U(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function Dn(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Gn="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",Kn=[{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:Gn},{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:Gn},{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 mi=new Map(Kn.map(e=>[e.key,e]));function $n(e){return typeof e=="string"&&mi.has(e)}var Hc=Kn.map(e=>e.key);function kt(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Bn(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=te(e.holes).map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=ln(e.outlinePath,t,n)),e.holes&&(e.holes=te(e.holes).map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function wi(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function ke(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function tt(e,t,n){let o=ke(t,n,e);return Math.abs(o)>1e-7?!1:e.x>=Math.min(t.x,n.x)-1e-7&&e.x<=Math.max(t.x,n.x)+1e-7&&e.y>=Math.min(t.y,n.y)-1e-7&&e.y<=Math.max(t.y,n.y)+1e-7}function Si(e,t,n,o){let i=ke(e,t,n),a=ke(e,t,o),r=ke(n,o,e),s=ke(n,o,t);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&&tt(n,e,t)||Math.abs(a)<=1e-7&&tt(o,e,t)||Math.abs(r)<=1e-7&&tt(e,n,o)||Math.abs(s)<=1e-7&&tt(t,n,o)}function xi(e){return e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n.x*i.y-i.x*n.y},0)}function vi(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&Si(e[t],e[n],e[o],e[i]))return!0}}return!1}function zn(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>wi(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(xi(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:vi(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function ji(e,t){let n=C(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(p=>p.type==="table"&&p.id===h)),a=o.filter((h,p)=>!i[p]);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(t.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&&j(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=E(r.fill,"Table surface color"));let s=r.seatCount!==void 0,l=r.seatCountsBySide!==void 0;if(l){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 h=["top","bottom","left","right"],p=Object.keys(r.seatCountsBySide);if(p.length!==h.length||p.some(x=>!h.includes(x)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let x of h){let v=r.seatCountsBySide[x];if(!Number.isInteger(v)||v<0||v>40)throw new u("invalid_operation",`seatCountsBySide.${x} must be a whole number from 0 to 40`)}let S=h.reduce((x,v)=>x+r.seatCountsBySide[v],0);if(S<1||S>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==S)throw new u("invalid_operation",`seatCount must equal the ${S}-chair seatCountsBySide total`);r.seatCount=S,r.sides=h.filter(x=>r.seatCountsBySide[x]>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.automaticRadius!==void 0&&typeof r.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(r.shape==="rect"&&r.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");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 c=(h,p,S,x)=>{if(p!==void 0&&(!Number.isFinite(p)||p<S||p>x))throw new u("invalid_operation",`${String(h)} must be from ${S} to ${x}`)};if(c("rotation",r.rotation,0,360),c("radius",r.radius,24,160),c("seatArc",r.seatArc,120,360),c("width",r.width,40,320),c("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 h=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(p=>!h.has(p)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=fe(r,"Table"),f=Je(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!l&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let p=structuredClone(h);if(Object.assign(p,r),r.fill===null&&delete p.fill,p.shape==="round")delete p.seatCountsBySide,p.automaticRadius===!0?p.radius=Ln(p.seatCount,p.seatArc):delete p.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${p.label}" is rectangular and cannot use automatic radius`,{tableId:p.id});delete p.automaticRadius}if(p.overrides&&r.seatCount!==void 0&&(p.overrides=p.overrides.filter(S=>S.index<p.seatCount),p.overrides.length||delete p.overrides),r.bookAsWhole===!1&&delete p.bookAsWhole,r.variableOccupancy===!1&&(delete p.variableOccupancy,delete p.minOccupancy,delete p.maxOccupancy),p.bookAsWhole||delete p.bookAsWhole,p.variableOccupancy||delete p.variableOccupancy,p.bookAsWhole&&p.variableOccupancy)throw new u("invalid_operation",`Table "${p.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:p.id});if((p.bookAsWhole||p.variableOccupancy)&&p.overrides?.length)throw new u("invalid_operation",`Table "${p.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:p.id,overriddenChairIndices:p.overrides.map(S=>S.index)});if(p.bookAsWhole)delete p.minOccupancy,delete p.maxOccupancy;else if(p.variableOccupancy){if(!Number.isInteger(p.minOccupancy)||!Number.isInteger(p.maxOccupancy)||p.minOccupancy<1||p.maxOccupancy<p.minOccupancy||p.maxOccupancy>p.seatCount)throw new u("invalid_operation",`Table "${p.label}" needs whole-number minimum and maximum guests from 1 to its ${p.seatCount}-chair capacity`,{tableId:p.id,seatCount:p.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:p.id});delete p.minOccupancy,delete p.maxOccupancy}if(f&&delete p.displayType,d&&delete p.displayLabel,p.shape==="rect"){if(p.width??=80,p.height??=50,p.seatCountsBySide){let S=["top","bottom","left","right"],x=S.reduce((v,P)=>v+p.seatCountsBySide[P],0);if(x!==p.seatCount)throw new u("invalid_operation",`Table "${p.label}" side counts total ${x}, but seatCount is ${p.seatCount}`,{tableId:p.id,seatCount:p.seatCount,seatCountsBySide:p.seatCountsBySide});p.sides=S.filter(v=>p.seatCountsBySide[v]>0)}}else p.radius??=40;if((p.bookAsWhole||p.variableOccupancy)&&Me(p.label))throw new u("invalid_operation",`Grouped table label "${p.label}" uses SeatLayer's reserved GA namespace`,{tableId:p.id});return p}),g=new Map(b.map(h=>[h.id,h])),y=new Set(o),m=new Map;for(let h of k(e))for(let p of h.objects){let S=p.type==="table"?g.get(p.id)??p:p,x=[];S.type==="row"?x=H(S).map(v=>v.label):S.type==="table"?x=S.bookAsWhole||S.variableOccupancy?[S.label]:ne(S).map(v=>v.label):S.type==="booth"?x=[S.label]:S.type==="gaArea"&&(x=W(S));for(let v of x){let P=m.get(v);if(P&&(y.has(P)||y.has(S.id)))throw new u("invalid_operation",`Inventory label "${v}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:v,conflictingObjectIds:[P,S.id]});m.set(v,P??S.id)}}let w=!1,I=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,p]of i.entries()){let S=b[h],x=JSON.stringify(p);for(let v of I)v in S||delete p[v];Object.assign(p,S),JSON.stringify(p)!==x&&(w=!0)}return{floorId:n.floorId,changed:w,tableIds:o}}function Li(e,t){let n=C(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(g=>n.objects.find(y=>y.type==="booth"&&y.id===g)),a=o.filter((g,y)=>!i[y]);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(t.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&&j(e,r.categoryKey);let s=(g,y,m,w)=>{if(y!==void 0&&(!Number.isFinite(y)||y<m||y>w))throw new u("invalid_operation",`${g} must be from ${m} to ${w}`)};s("width",r.width,30,400),s("height",r.height,30,400),s("rotation",r.rotation,0,360);let l=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 g=zn(r.points);if(!g.ok)throw new u("invalid_operation",g.message??"The booth outline is not a valid simple polygon")}let c=r.points!=null?r.points.map(g=>({x:g.x,y:g.y})):void 0;delete r.points;let d=fe(r,"Booth"),f=Je(r,"Booth"),b=!1;for(let g of i){let y=JSON.stringify(g);Object.assign(g,r),d&&delete g.displayLabel,f&&delete g.displayType,l?delete g.points:c&&(g.points=c),JSON.stringify(g)!==y&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function ki(e,t){let n=C(e,t.floorId),o=[...new Set(t.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(f=>f.type==="gaArea"&&f.id===d)),a=o.filter((d,f)=>!i[f]);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(t.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&&j(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>X))throw new u("invalid_operation",`capacity must be an integer from 1 to ${X}`);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=fe(r,"GA area"),l=Je(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&&Lt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let c=!1;for(let d of i){let f=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:Lt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),s&&delete d.displayLabel,l&&delete d.displayType,JSON.stringify(d)!==f&&(c=!0)}return{floorId:n.floorId,changed:c,gaAreaIds:o}}function nt(e,t){if(t.length<3)return 0;let n=i=>F(i,t,void 0),o=0;for(let i of e)n(L(i))&&(i.type==="row"?o+=H(i).length:i.type==="table"?o+=ne(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=re(i)));return o}function Ei(e,t){let n=C(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(l=>l.id===s)),i=t.objectIds.filter((s,l)=>!o[l]);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(t.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,l)=>s+re(l),0),remainingObjectCount:n.objects.length}}function Ti(e,t){let n=C(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(c=>n.objects.find(d=>d.type==="text"&&d.id===c)),a=o.filter((c,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(t.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=E(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=E(r.background.color,"Text background color");let{padding:c=6,cornerRadius:d=4,opacity:f=.9}=r.background;if(!Number.isFinite(c)||c<0||c>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(f)||f<.1||f>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(c=>Object.prototype.hasOwnProperty.call(r,c))&&i.some(c=>c.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!$n(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(c=>c.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let l=!1;for(let c of i){let d=JSON.stringify(c);r.iconKey!==void 0&&(c.iconKey=r.iconKey),r.text!==void 0&&(c.text=r.text),r.fontSize!==void 0&&(c.fontSize=r.fontSize),r.fontFamily===null?delete c.fontFamily:r.fontFamily!==void 0&&(c.fontFamily=r.fontFamily),r.rotation!==void 0&&(c.rotation=r.rotation),r.color===null?delete c.color:r.color!==void 0&&(c.color=r.color),r.bold!==void 0&&(r.bold?c.bold=!0:delete c.bold),r.italic!==void 0&&(r.italic?c.italic=!0:delete c.italic),r.width===null?delete c.width:r.width!==void 0&&(c.width=r.width),r.align!==void 0&&(r.align==="left"?delete c.align:c.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete c.lineHeight:c.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete c.letterSpacing:c.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?c.underline=!0:delete c.underline),r.opacity!==void 0&&(r.opacity===1?delete c.opacity:c.opacity=r.opacity),r.background===null?delete c.background:r.background!==void 0&&(c.background=r.background),r.labelImportance===null?delete c.labelImportance:r.labelImportance!==void 0&&(c.labelImportance=r.labelImportance),JSON.stringify(c)!==d&&(ze(c),l=!0)}return{floorId:n.floorId,changed:l,textIds:o}}function Fi(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(g=>g.type==="row"&&g.id===b)),a=o.filter((b,g)=>!i[g]);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((b,g)=>b.origin.y-g.origin.y||b.origin.x-g.origin.x),s=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,l=bn(r.map(b=>({label:s(b)})),t.options),c=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=c===void 0||c===""||c==="Row"?t.displayType===void 0?void 0:null:c,f=!1;return r.forEach((b,g)=>{let y=l[g].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(b)!==y&&(f=!0,b.segmentedRow?b.segmentedRow.displayLabel=y:b.displayLabel=y),d!==void 0){if(d===null){b.displayType!==void 0&&(f=!0,delete b.displayType);return}b.displayType!==d&&(f=!0,b.displayType=d)}}),{floorId:n.floorId,changed:f,rows:r.map(b=>({id:b.id,displayLabel:s(b),...b.displayType?{displayType:b.displayType}:{}}))}}function Ni(e,t){let n=Nn.find(c=>c.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=C(e,t.floorId),i=new Set,a=n.build().map(c=>structuredClone(c));for(let c of a)c.id=M(e,c.type,t.idFactory,i),Bn(c,t.center.x,t.center.y);for(let c of n.categories)e.categories.some(d=>d.key===c.key)||e.categories.push({...c});let r=a.filter(c=>c.type==="row");if(r.length){let c=0;for(let d of o.objects){if(d.type!=="row")continue;let f=Dn(d.label);f!=null&&(c=Math.max(c,f+1))}for(let d of r)d.label=U(c++)}let s=new Set(o.objects.flatMap(c=>"label"in c&&c.label?[c.label]:[]));for(let c of a){if((c.type==="table"||c.type==="booth")&&s.has(c.label)){let d=/^(.*?)(\d+)$/.exec(c.label),f=d?d[1]:`${c.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(s.has(`${f}${b}`));c.label=`${f}${b}`}"label"in c&&c.label&&s.add(c.label)}o.objects.push(...a);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let c=oe(a);if(c){let d={type:"section",id:M(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:c};o.objects.push(d),l=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(c=>c.id),...l?[l]:[]],sectionId:l}}function Di(e){let t=structuredClone(e);if([t.start,t.control1,t.control2,t.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=Ge(t,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:t,length:i}}function Vn(e,t){let n=C(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=Di(t.path),a=H(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=H(r),l=a.map((d,f)=>Math.hypot(d.x-s[f].x,d.y-s[f].y)),c=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:l.length?l.reduce((d,f)=>d+f,0)/l.length:0,maxSeatMovement:l.length?Math.max(...l):0,convertingFromParametric:!o.path,changed:c,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Gi(e,t){let n=Vn(e,t);if(!n.changed)return n;let i=C(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(t.path),i.origin={...t.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function Ki(e,t){let n=e.map((o,i)=>[...o,t[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 l=o;l<4;l++)n[r][l]-=s*n[o][l]}}return[n[0][3],n[1][3],n[2][3]]}function $i(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){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 l=0;l<3;l++)t[s][l]+=a[s]*a[l]}}let o=Ki(t,n);return o?{x:o[0],y:o[1]}:null}function Un(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function qn(e,t){let n=C(e,t.floorId),o=n.objects.find(g=>g.type==="section"&&g.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.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=k(e).find(g=>g.id===n.floorId),r=t.mode==="outline"?$i(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(g=>g.type==="row"&&F(L(g),o.outline,o.holes)),l=s.filter(g=>!!g.path).map(g=>g.id),c=[],d=[],f=i/100;for(let g of s){if(g.path)continue;if(g.seatCount<2){c.push(g.id);continue}let y=Math.hypot(g.origin.x-r.x,g.origin.y-r.y);if(y<=g.seatSpacing/2+1e-6){c.push(g.id);continue}let m=2*Math.asin(g.seatSpacing/(2*y))/Q,w=H(g),I=Math.atan2(g.origin.x-r.x,g.origin.y-r.y)/Q,p=(g.curve!==0?Math.sign(g.curve):w.length>1&&Math.sign(Un(Math.atan2(w[1].x-r.x,w[1].y-r.y)/Q-I))||1)*m*(g.seatCount-1);if(Math.abs(p)>320){c.push(g.id);continue}let S=-I,x=g.curve+(p-g.curve)*f,v=g.rotation+Un(S-g.rotation)*f,P={...g,curve:x,rotation:v},G=H(P).map((K,$)=>Math.hypot(K.x-w[$].x,K.y-w[$].y));d.push({rowId:g.id,fromCurve:g.curve,targetCurve:p,resultCurve:x,fromRotation:g.rotation,resultRotation:v,rmsMovement:Math.sqrt(G.reduce((K,$)=>K+$**2,0)/G.length),maxMovement:Math.max(...G)})}let b=d.map(g=>g.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:l,skippedInvalidRowIds:c,averageMovement:b.length?b.reduce((g,y)=>g+y,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(g=>g.maxMovement)):0}}function Bi(e,t){let n=qn(e,t),o=C(e,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(l=>l.type==="row"&&l.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 Jn(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),s=q(n,o,t);return i*a<-1e-9&&r*s<-1e-9}function Hn(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>Jn(n,i,a,t[(r+1)%t.length]))})}function zi(e){if(e.length<3||e.length>256||Math.abs(ve(e))<1||e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)))return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(!(n===t+1||t===0&&n===e.length-1)&&Jn(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function ot(e,t,n){let o=C(e,t),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 rt(e,t){let{target:n,object:o,outer:i}=ot(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!zi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(c=>!F(c,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Hn(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=t.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||t.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let c=0;c<r.length;c++){if(c===t.holeIndex)continue;let d=r[c];if(Hn(a,d)||F(a[0],d,void 0)||F(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let l=n.objects.filter(c=>c.id!==o.id&&c.type!=="section"&&F(L(c),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:l.map(c=>c.id),excludedInventoryUnits:nt(n.objects.filter(c=>c.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ui(e,t){let n=rt(e,t),{object:o}=ot(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function Xn(e,t){let{target:n,object:o}=ot(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[t.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&F(L(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:nt(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Hi(e,t){let n=Xn(e,t),{object:o}=ot(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Vi(e){let t=ee(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Yn(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.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 Qn(e,t){let n=C(e,t.floorId),o=Yn(n.objects,t.sectionIds),i=je(qe(e,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??[]),l=new Set,c=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(g=>g.type==="section"&&c.has(g.logicalSectionId??g.id)).flatMap(g=>g.editor?.defaultCategoryKey?[g.editor.defaultCategoryKey]:[]));for(let g of s){let y=r.get(g);if(y)if(y.type==="row"||y.type==="table")for(let m of Ze(y).keys())l.add(m);else(y.type==="booth"||y.type==="gaArea")&&l.add(y.categoryKey)}let f=o.logicalSectionIds.every(g=>(a.get(g)?.seatCount??0)>0),b=o.logicalSectionIds.every(g=>a.get(g)?.objectIds.some(y=>{let m=r.get(y);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:f,...f&&l.size===1?{categoryKey:[...l][0]}:!f&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:f?l.size!==1:!s.length&&d.size>1,viewApplicable:b}}function qi(e,t){j(e,t.categoryKey);let n=Qn(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=C(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,s=new Set(n.logicalSectionIds);for(let l of o.objects)l.type!=="section"||!s.has(l.logicalSectionId??l.id)||l.editor?.defaultCategoryKey!==t.categoryKey&&(l.editor={...l.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let l of o.objects){if(!i.has(l.id)||l.type!=="row"&&l.type!=="table"&&l.type!=="booth"&&l.type!=="gaArea"||(l.categoryKey!==t.categoryKey&&(l.categoryKey=t.categoryKey,a=!0),l.type!=="row"&&l.type!=="table"||!l.overrides?.length))continue;let c=l.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let f={...d};return delete f.categoryKey,r++,a=!0,Object.keys(f).some(b=>b!=="index")?[f]:[]});c.length?l.overrides=c:delete l.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Ji(e,t){let n=C(e,t.floorId),o=Yn(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(g=>!r.has(g));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=Vi(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&&Xe(a.labelPresentation,"Section"),a.labelStyle!==void 0&&ge(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(g=>g.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=E(a.color,"Section color"));let l=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,c=new Set(o.logicalSectionIds),d=l?n.objects.filter(g=>g.type==="section"&&c.has(g.logicalSectionId??g.id)):[],f=new Set,b=!1;for(let g of o.sections){let y=JSON.stringify(g);a.label!==void 0&&(g.label=a.label),a.labelPresentation===null?delete g.labelPresentation:a.labelPresentation!==void 0&&(g.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(g.elevation=a.elevation);let m=w=>{g.physical3dProvenance&&(delete g.physical3dProvenance[w],Object.keys(g.physical3dProvenance).length===0&&delete g.physical3dProvenance)};a.height===null?(delete g.height,m("height")):a.height!==void 0&&(g.height=a.height,g.physical3dProvenance={...g.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete g.rake,m("rake")):a.rake!==void 0&&(g.rake=a.rake,g.physical3dProvenance={...g.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete g.surfaceKind,m("surfaceKind")):a.surfaceKind!==void 0&&(g.surfaceKind=a.surfaceKind,g.physical3dProvenance={...g.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete g.color:a.color!==void 0&&(g.color=a.color),JSON.stringify(g)!==y&&(b=!0,f.add(g.id))}for(let g of d){let y=JSON.stringify(g),m=g.viewFromSeatUrl;if(a.displayLabel===null?delete g.displayLabel:a.displayLabel!==void 0&&(g.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete g.entrance:a.entrance!==void 0&&(g.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete g.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(g.viewFromSeatUrl=a.viewFromSeatUrl),!g.viewFromSeatUrl||a.viewFromSeatMeta===null?delete g.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?g.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&g.viewFromSeatUrl!==m&&delete g.viewFromSeatMeta,a.labelStyle!==void 0){let w=Ye(g.labelPresentation,a.labelStyle);w?g.labelPresentation=w:delete g.labelPresentation}a.zone===null?delete g.zone:a.zone!==void 0&&(g.zone=a.zone),JSON.stringify(g)!==y&&(b=!0,f.add(g.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...f]}}function Wn(e,t){let n=C(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.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"&&F(L(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+re(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function Xi(e,t){let n=Wn(e,t),i=C(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function Zn(e,t){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let s=L(e);o=l=>({x:s.x+(l.x-s.x)*t.factor,y:s.y+(l.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let l=t.degrees*Math.PI/180,c=Math.cos(l),d=Math.sin(l),f=L(e);o=b=>{let g=b.x-f.x,y=b.y-f.y;return{x:f.x+g*c-y*d,y:f.y+g*d+y*c}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=wt(e.outlinePath,o,i,a)),e.holes&&(e.holes=te(e.holes).map(s=>s.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function Yi(e,t){let n=C(e,t.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Zn(o,t.transform)}}function Qi(e,t){let n=C(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Ke(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=mt(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 Wi(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function Zi(e,t){return eo(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function eo(e,t){let n=C(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.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(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let l=n.objects.find(h=>h.type==="section"&&h.id===s);if(!l||!Wi(l))continue;let d=structuredClone(l);a.set(l.id,{section:l,snapshot:d});let f=JSON.stringify(l),b=(l.sourceOutline??l.outline).map(h=>({...h})),g=Math.min(100,Math.max(0,t.cornerSmoothing??l.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?l.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),w=m?.some(h=>Math.abs(h)>.5)===!0,I=g>.5||w?dn(b,{cornerSmoothing:g,...w?{edgeCurvature:m}:{}}):null;I?(l.sourceOutline=b,l.outlinePath=I,l.outline=mt(I),g>.5?l.cornerSmoothing=g:delete l.cornerSmoothing,w?l.edgeCurvature=[...m]:delete l.edgeCurvature):(l.outline=b,delete l.outlinePath,delete l.sourceOutline,delete l.cornerSmoothing,delete l.edgeCurvature);for(let h=0;h<(l.holes?.length??0);h+=1)rt(e,{floorId:n.floorId,objectId:l.id,points:l.holes[h],holeIndex:h});JSON.stringify(l)!==f&&(r=!0,i.add(l.id))}}catch(s){for(let{section:l,snapshot:c}of a.values()){let d=l;for(let f of Object.keys(d))delete d[f];Object.assign(l,structuredClone(c))}throw s}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}var Tt=.15,Ft=1.6;var ea=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Dt(e){let t=ea.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(i=>i+i).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Gt(e,t){let n=a=>{let r=Dt(a);if(!r)return null;let s=h=>{let p=h/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4},l=s(r[0]),c=s(r[1]),d=s(r[2]),f=(.4124*l+.3576*c+.1805*d)/.95047,b=.2126*l+.7152*c+.0722*d,g=(.0193*l+.1192*c+.9505*d)/1.08883,y=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=y(f),w=y(b),I=y(g);return[116*w-16,500*(m-w),200*(w-I)]},o=n(e),i=n(t);return o&&i?Math.hypot(o[0]-i[0],o[1]-i[1],o[2]-i[2]):null}function Nt(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function to(e){return .2126*Nt(e[0])+.7152*Nt(e[1])+.0722*Nt(e[2])}function it(e,t){let n=Dt(e),o=Dt(t);if(!n||!o)return null;let i=to(n),a=to(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var no=["butt","round","square"],oo=["miter","round","bevel"],ro=["none","arrow"];function Kt(e){return e==="line"||e==="polyline"}var io=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Al=io.map(e=>e.key),ta=new Map(io.map(e=>[e.key,e]));function Ee(e){return typeof e=="string"&&ta.has(e)}var na=new Set(["companion","child","senior","student","membership","custom"]);function be(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.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"),l=n.get(s);if(l)throw new u("duplicate_category_label",`Categories ${l} and ${a} share the same label`,{categoryKeys:[l,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.referenceDirectSeatImport!==void 0){let c=i.referenceDirectSeatImport;if(c.assetId!==c.assetId.trim()||c.assetId.length>160||!c.assetId||c.familyId!==c.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(c.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{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.seatGlyph!=null&&!Ee(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,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 c=new Set,d=new Set;for(let f of i.tiers){let b=f.id.trim(),g=f.name.normalize("NFKC").trim(),y=g.toLocaleLowerCase("en");if(!b||b.length>160||c.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!g||g.length>80||d.has(y))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:g});if(!Number.isFinite(f.price)||f.price<0||f.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(f.restriction!=null&&!na.has(f.restriction))throw new u("invalid_operation",`Ticket tier ${b} has an unknown restriction`,{categoryKey:a,tierId:b});if(f.buyerMessage!=null){if(f.buyerMessage=f.buyerMessage.normalize("NFKC").trim(),!f.buyerMessage)delete f.buyerMessage;else if(f.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${b} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:b})}if(f.currency!=null&&(f.currency=f.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(f.currency)))throw new u("invalid_operation",`Ticket tier ${b} must use a three-letter ISO currency`,{categoryKey:a,tierId:b});if(f.applicability!=null){let m=f.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),w=f.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(I=>!I||I.length>160)||new Set(m).size!==m.length)||w&&(!w.length||w.some(I=>!_e.some(h=>h.key===I))||new Set(w).size!==w.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});f.applicability={...m?{seatLabels:m}:{},...w?{accessibility:[...w]}:{}},!f.applicability.seatLabels&&!f.applicability.accessibility&&delete f.applicability}if(f.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(f.evidence.provenance)||typeof f.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(f.evidence.sourceDescription=f.evidence.sourceDescription.normalize("NFKC").trim(),!f.evidence.sourceDescription||f.evidence.sourceDescription.length>240||f.evidence.capturedAt!==void 0&&(f.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(f.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}c.add(b),d.add(y)}}}return o}function so(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.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(f=>f.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 l=structuredClone(r.patch),{tiers:c,...d}=l;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(l,"tiers")&&(c==null?delete s.tiers:s.tiers=c?.map(f=>{let b={...f,id:f.id.trim(),name:f.name.normalize("NFKC").trim()};return f.buyerMessage?.trim()?b.buyerMessage=f.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete s.referenceDirectSeatImport}let i=be(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function oa(e,t){let n=structuredClone(e.categories),o=n.find(r=>r.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let i=be(n),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,category:e.categories.find(r=>r.key===t.categoryKey),categories:e.categories}}function ra(e,t){let n=t.categoryKeys.map(l=>l.trim()),o=e.categories.map(l=>l.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(l=>!n.includes(l)),r=n.filter(l=>!i.has(l));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((l,c)=>l===o[c]))return{changed:!1,categoryKeys:o,categories:e.categories};let s=new Map(e.categories.map(l=>[l.key,l]));return e.categories=be(n.map((l,c)=>{let d=structuredClone(s.get(l));return l!==o[c]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var $t=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function ao(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[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 ia(e,t){let n=ao(e),o=ao(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var aa=3600;function co(e,t,n=$t){return n.find(i=>e.every(a=>ia(i,a)>=aa))??n[t%n.length]}function sa(e,t){let n=t?.palette??$t;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return so(e,{updates:i}),{changed:e.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:e.categories}}function ca(e,t){let n=t.color.trim().toLowerCase(),o=t.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(e.categories),a=i.find(l=>l.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=be(i),s=JSON.stringify(r)!==JSON.stringify(e.categories);return s&&(e.categories=r),{changed:s,category:e.categories.find(l=>l.key===t.categoryKey),categories:e.categories}}function lo(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let l=t.idFactory("cat").trim();if(l&&!n.has(l)){o=l;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=be([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var la=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],da={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function ua(e,t){let n=da[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var fa=26;function ga(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,s,l]=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],c=n-o/2,d=f=>Math.round((f+c)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(s)}${d(l)}`}function ba(e,t,n){let o=r=>e.every(s=>{let l=Gt(r,s);return l==null||l>=fa}),i=r=>{let s=it(r,"#12151d"),l=it(r,"#ffffff");return(s??0)>=3||(l??0)>=3},a=t.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 l=ga(r,.62,s);if(o(l)&&i(l))return l}return n}function uo(e,t){let n=We.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function ha(e){let t=new Map;for(let n of k(e))for(let o of n.objects){let i=We.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of Ze(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=t.get(r)??new Set;s.add(i.objectType),t.set(r,s)}}return t}function pa(e,t){let n=new Set(e.categories.map(i=>i.label.toLowerCase())),o=t;for(let i=2;n.has(o.toLowerCase());i+=1)o=`${t} ${i}`;return o}function fo(e,t,n){let o=ha(e),i=c=>{let d=o.get(c);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(c=>c.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let c=e.categories.find(d=>{let f=o.get(d.key);return f?.size===1&&f.has(n)});if(c)return{kind:"existing",categoryKey:c.key,label:c.label}}let r=We.find(c=>c.objectType===n),s=a?uo(a.label,n):n==="gaArea"?"General Admission":r.creationWord,l=e.categories.find(c=>c.label.toLowerCase()===s.toLowerCase()&&i(c.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:pa(e,s)}}function ya(e,t,n,o){let i=fo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return ma(e,n,a,i.label,o)}function ma(e,t,n,o,i){let a=i.palette??la,r=e.categories.map(d=>d.color),s=i.suggestColor?.(r.map(d=>d.toLowerCase()))??co(r,e.categories.length),l=ba(r,ua(t,a),s),c=lo(e,{label:o,color:l,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=c.categories,c.category.key}function wa(e,t){let n=new Set;for(let o of k(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function Sa(e,t){let n=e.categories.find(a=>a.key===t.categoryKey);if(!n)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});if(e.categories.length<=1)throw new u("invalid_operation","A chart must retain at least one category");let o=wa(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let i=be(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var xa=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],va=["seat","deck","shell","fascia"];function Ia(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),i={...e.theme??{}};for(let a of xa){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=E(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<Tt||n.seatScale>Ft)throw new u("invalid_operation",`Theme seatScale must be from ${Tt} to ${Ft}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=ee(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster 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}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let s of va){let l=n.venue3d[s];l===null?delete a[s]:l!==void 0&&(a[s]=E(l,`3D venue ${s}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Ca(e,t){let n=t.url===null?null:ee(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(f=>f.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let l=(s.viewFromSeatUrl??void 0)===o,c=o?t.metadata===null?void 0:t.metadata??(l?s.viewFromSeatMeta:void 0):void 0,d=!l||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(c??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=c,{changed:d,scope:"floor",floorId:t.floorId,url:s.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function Oa(e,t){let n=qe(e,t.floorId),o=In(n),i=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:i==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function at(e,t){j(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.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(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.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:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.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 c=C(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:t.rowLabelStart??c,seatLabelStart:t.seatLabelStart??1}}function Ra(e,t,n){let o=n*Q;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Pa(e,t,n,o){let i=Math.abs(o-n)*Q,a=[["left",.25],["center",.5],["right",.75]].flatMap(([c,d])=>{let f=e.aisleGaps[c];if(!f)return[];let b=f/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((c,d)=>c[0]-d[0]),r=[];for(let c of a){let d=r[r.length-1];d&&c[0]<=d[1]?d[1]=Math.max(d[1],c[1]):r.push([...c])}let s=[],l=0;for(let c of r)c[0]-l>1e-6&&s.push([l,c[0]]),l=Math.max(l,c[1]);return 1-l>1e-6&&s.push([l,1]),s.filter(([c,d])=>t*i*(d-c)>=e.seatPitch*.75)}function _a(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((l,c)=>l+c,0),a=e.map(l=>o*l/i),r=a.map(l=>2+Math.floor(l)),s=t-r.reduce((l,c)=>l+c,0);return a.map((l,c)=>({index:c,fraction:l-Math.floor(l)})).sort((l,c)=>c.fraction-l.fraction||l.index-c.index).forEach(({index:l})=>{s-- >0&&r[l]++}),r}function st(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,l=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,c=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(c-l)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(c-l)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=Pa(e,r,l,c);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let f=d.map(([y,m])=>r*Math.abs(c-l)*Q*(m-y)),b=e.fit==="fixed-count"?_a(f,e.seatsPerRow):f.map(y=>Math.max(2,Math.round(y/e.seatPitch)+1)),g=e.seatLabelStart;d.forEach(([y,m],w)=>{let I=l+(c-l)*y,h=l+(c-l)*m;e.facing==="outward"&&([I,h]=[h,I]);let p=b[w];if(p>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let S=Math.abs(h-I)*Q/(p-1),x=2*r*Math.sin(S/2),v={type:"row",id:n(i,w),label:U(e.rowLabelStart+i),origin:Ra(e.center,r,I),rotation:-I,curve:h-I,seatCount:p,seatSpacing:x,categoryKey:e.categoryKey,seatLabelStart:g,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:i,segmentIndex:w}};o.push(v),g+=p})}return o}function Bt(e,t){let n=at(e,t),o=C(e,t.floorId),i=st(n,"preview-arc-fan",(l,c)=>`preview-fan-${l}-${c}`),a=i.map(l=>l.seatSpacing),r=Math.max(...a.map(l=>Math.abs(l-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((l,c)=>l+c.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(l=>l>0).length,warnings:s}}function Aa(e,t){let n=at(e,t),o=C(e,t.floorId),i=new Set,a=M(e,"fan",t.idFactory,i),r=st(n,a,()=>M(e,"r",t.idFactory,i)),s=Bt(e,t),l=null,c=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(c){if(c.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let f=oe(r);f&&(l=M(e,"sec",t.idFactory,i),d={type:"section",id:l,label:c,outline:f,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(f=>f.id),sectionId:l,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 go(e,t){let n=C(e,t.floorId),o=n.objects.filter(f=>f.type==="row"&&f.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=f=>{let b=f.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(f=>a(f)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(f=>f.type==="section"&&f.arcFanGroupId===t.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},l=at(e,s),c=new Set(st(l,t.groupId,(f,b)=>`${f}:${b}`).map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`));if(c.size!==d.size||[...c].some(f=>!d.has(f)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return s}function Ma(e,t){go(e,{floorId:t.floorId,groupId:t.groupId});let n=at(e,t),o=C(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),s=new Set,l=st(n,t.groupId,(m,w)=>r.get(`${m}:${w}`)??M(e,"r",t.idFactory,s)),c=Bt(e,t),d=t.sectionLabel?.normalize("NFKC").trim(),f=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let m=oe(l);m&&(f={type:"section",id:a?.id??M(e,"sec",t.idFactory,s),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),g=Math.min(...o.objects.map((m,w)=>b.has(m.id)?w:1/0)),y=o.objects.filter(m=>!b.has(m.id));return y.splice(Number.isFinite(g)?g:y.length,0,...l,...f?[f]:[]),o.objects.splice(0,o.objects.length,...y),{floorId:o.floorId,rowIds:l.map(m=>m.id),sectionId:f?.id??null,groupId:t.groupId,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function ja(e){let t=new Set(B(e).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;t.has(U(n));)n+=1;let o=U(n);return t.add(o),n+=1,o}}function bo(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function La(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.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(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=C(e,t.floorId),a=new Set,r=ja(e),s=kt(t.rotation??0),l=t.curve??0,c=t.style,d=c?M(e,"rowblock",t.idFactory,a):void 0,f=c?bo({style:c,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:l}):void 0,b={x:Math.cos(s*J),y:Math.sin(s*J)},g={x:-b.y,y:b.x},y=Array.from({length:t.rowCount},(I,h)=>{let p=c==="intertwined"&&h%2===1?o/2:0,S={type:"row",id:M(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+g.x*h*n+b.x*p,y:t.origin.y+g.y*h*n+b.y*p},rotation:s,curve:l,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return c&&d&&f&&(S.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:c,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:l,signature:f}),S});i.objects.push(...y);let m=null,w=t.sectionLabel?.trim();if(w){let I=oe(y);if(I){let h={type:"section",id:M(e,"sec",t.idFactory,a),label:w,outline:I};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:y.map(I=>I.id),sectionId:m,createdIds:[...y.map(I=>I.id),...m?[m]:[]]}}function ho(e,t){let n=new Set(B(e).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(`${t}${o}`);)o+=1;let i=`${t}${o}`;return n.add(i),o+=1,i}}function ka(e,t){let n=new Set(B(e).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Ea=456;function po(e){let t=Math.sqrt(Math.max(1,e)*Ea);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ta(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=C(e,t.floorId),o=new Set,{width:i,height:a}=po(t.capacity),r=ka(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:M(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function Fa(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.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(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let i=C(e,t.floorId),a=new Set,r=ho(e,"T"),s=[];for(let l=0;l<t.tableRows;l+=1)for(let c=0;c<t.tableColumns;c+=1)s.push({type:"table",id:M(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.tableColumns-1)/2)*n,y:t.center.y+(l-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.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(l=>l.id),createdIds:s.map(l=>l.id)}}function Na(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.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(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=C(e,t.floorId),a=new Set,r=ho(e,"B"),s=[];for(let l=0;l<t.boothRows;l+=1)for(let c=0;c<t.boothColumns;c+=1)s.push({type:"booth",id:M(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.boothColumns-1)/2)*n,y:t.center.y+(l-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function Da(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.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(g=>g.type==="row"&&g.id===b)),a=o.filter((b,g)=>!i[g]);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 l=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!l||l.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let c=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(g=>!!g):[])),d="";for(let b=0;b<100;b+=1){let g=t.idFactory("rowgroup");if(g&&!c.has(g)){d=g;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let f=r[0];return r.forEach((b,g)=>{b.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:g,componentCount:r.length,boundaryBefore:g===0?"start":t.boundaries[g-1],displayLabel:l,...f.displayType?{displayType:f.displayType}:{},...f.labelPresentation?{labelPresentation:structuredClone(f.labelPresentation)}:{},...f.viewFromSeatUrl?{viewFromSeatUrl:f.viewFromSeatUrl}:{},...f.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(f.viewFromSeatMeta)}:{},...f.confidenceEvidence?{confidenceEvidence:structuredClone(f.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function Ga(e,t){let n=C(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),i=t.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,l)=>s.segmentedRow.componentIndex-l.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 Ka(e,t){let n=C(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.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(t.boundaries&&(t.boundaries.length!==o.length-1||t.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=t.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 l=r.segmentedRow,c=l.viewFromSeatUrl;i!==void 0&&(l.displayLabel=i),t.boundaries&&s>0&&(l.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(l.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete l.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(l.viewFromSeatUrl=t.viewFromSeatUrl),!l.viewFromSeatUrl||t.viewFromSeatMeta===null?delete l.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?l.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&l.viewFromSeatUrl!==c&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function $a(e,t){if(typeof t.groupId!="string"||!t.groupId)throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let n=C(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,z)=>R.rowBlockGeneration.rowIndex-z.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((R,z)=>{let A=R.rowBlockGeneration;return A.kind!=="row-block-v1"||A.rowIndex!==z||A.signature!==i.signature||JSON.stringify(A)!==JSON.stringify({...i,rowIndex:z})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,s=t.rowCount??i.rowCount,l=t.seatsPerRow??i.seatsPerRow,c=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,f=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?kt(t.rotation??i.rotation):t.rotation??i.rotation,g=t.origin?{...t.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(l)||l<1||l>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![c,d].every(R=>Number.isFinite(R)&&R>0)||!Number.isFinite(f)||!Number.isFinite(b)||!Number.isFinite(g.x)||!Number.isFinite(g.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let y=bo({style:r,origin:g,rotation:b,rowCount:s,seatsPerRow:l,rowGap:c,seatSpacing:d,curve:f}),m={x:Math.cos(b*J),y:Math.sin(b*J)},w={x:-m.y,y:m.x},I=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),h=new Set,p=new Set(n.objects.filter(R=>R.type==="row").filter(R=>!o.includes(R)).map(R=>R.label)),S=n.objects.filter(R=>R.type==="row").length,x=()=>{for(;p.has(U(S));)S+=1;let R=U(S);return p.add(R),S+=1,R},v=[],P=[];for(let R=0;R<s;R+=1){let z=r==="intertwined"&&R%2===1?d/2:0,A=I.get(R);A||(A={type:"row",id:M(e,"r",t.idFactory,h),label:x(),origin:{...g},rotation:b,curve:f,seatCount:l,seatSpacing:d,categoryKey:o[0].categoryKey},P.push(A.id)),A.origin={x:g.x+w.x*R*c+m.x*z,y:g.y+w.y*R*c+m.y*z},A.rotation=b,A.curve=f,A.seatCount=l,A.seatSpacing=d,delete A.path,delete A.arcFanGeneration,A.overrides&&(A.overrides=A.overrides.filter(xe=>xe.index<l),A.overrides.length||delete A.overrides),A.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:R,rowCount:s,seatsPerRow:l,origin:{...g},rotation:b,rowGap:c,seatSpacing:d,curve:f,signature:y},v.push(A)}let N=o.slice(s).map(R=>R.id),G=Math.min(...o.map(R=>n.objects.indexOf(R))),K=new Set(o.map(R=>R.id)),$=n.objects.filter(R=>!K.has(R.id));return $.splice(G,0,...v),n.objects.splice(0,n.objects.length,...$),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(R=>R.id),createdRowIds:P,removedRowIds:N,changed:a!==JSON.stringify(v)||P.length>0||N.length>0}}function zt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Ut(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Ht(e){return Ut(zt(e),40)}function yo(e,t=39){return Ut(zt(e),Math.max(1,t))}function he(e,t=80){return Ut(zt(e),Math.max(1,t))}function mo(e){return he(e).toLocaleLowerCase("en")}function Vt(e){return mo(e)}function wo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Ba(e){let t=wo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(Y(e,o,i))}return n}function za(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=wo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(i?.label??`${e.label}-${o+1}`)}return n}function Ua(e){return e.type==="row"?[e.label,...Ba(e)]:e.type==="table"?[e.label,...za(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...W(e)]:[]}function So(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of Ua(o)){let a=Vt(i);a&&n.add(a)}return n}function Ha(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Vt(e)];for(let i=0;i<t;i+=1)o.push(Vt(Y(n,i)));return o.filter(Boolean)}function xo(e,t,n){let o=Ha(t,n);if(!o.length||o.some(i=>e.has(i)||Me(i)))return!1;for(let i of o)e.add(i);return!0}var Va=1e-6,qa=160,Ja=.001,Xa=1e-5;function pe(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>qa)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function vo(e){return typeof e=="string"&&yo(e)||void 0}function Io(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(qt(e.origin)&&qt(t.start)&&qt(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},i=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Ja+Math.max(1,i)*Xa;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||i<=Va)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,l=Math.abs(((e.rotation-s)%360+540)%360-180),c=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return l<=c}function qt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var Ya=300;function Qa(e){let t=new Set(B(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(U(n));)n+=1;let i=U(n);return n+=1,t.add(i),i};return i=>{let a=Ht(i),r=0;return()=>{for(;a&&r<4096;r+=1){let s=`${a}-${U(r)}`;if(!t.has(s))return t.add(s),r+=1,s}return o()}}}function Wa(e){let t=So(B(e));return(n,o)=>{let i=he(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,s=r?`${he(i,80-r.length)}${r}`:i;if(s&&xo(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function Za(e){return{ordinaryFor:Qa(e),direct:Wa(e)}}function Co(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function es(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[s,l]of r.rows.entries()){let c=pe(`${r.sourceGroupId}:${s}`),d=c&&pe(l.directSourceRowId)===c?c:void 0;d&&o.set(d,o.has(d)?null:l)}let i=new Map;for(let r of e){let s=pe(r.referenceScan?.directSourceRowId);if(!s){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let l=i.get(s)??[];l.push(r),i.set(s,l)}let a=new Map;for(let[r,s]of i){let l=s.filter(b=>b.overrides?.length);if(!l.length)continue;let c=o.get(r),d=l[0],f=d.overrides;if(s.length!==1||l.length!==1||!f||!c||!Io(d,c))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:s.map(b=>b.id)});a.set(r,structuredClone(f))}return a}function Oo(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!(o.type==="row"&&o.referenceScan?.assetId===t&&(!n||o.referenceScan.sectionId===n)))}function ts(e,t,n,o,i,a,r){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=Oo(t,n,r).filter(f=>F(L(f),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(f=>f.id)},rows:[],seats:0}}let l=[],c=0;for(let[d,f]of e.rows.entries()){let b=Math.min(Ya,Math.max(1,Math.round(f.seatCount)));if(!Number.isFinite(b)||b<1)continue;let g=f.end.x-f.start.x,y=f.end.y-f.start.y,m=Math.hypot(g,y),w=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(w)||w<=0)continue;let I=m>0?Math.atan2(y,g)*180/Math.PI:0,h=e.sourceGroupId?pe(`${e.sourceGroupId}:${d}`):void 0,p=h&&pe(f.directSourceRowId)===h?h:void 0,S=p?vo(f.directReviewedSuffix):void 0,x=e.sourceGroupId&&f.rowLabel?he(f.rowLabel):"",v=e.sourceGroupId&&f.rowDisplayLabel?he(f.rowDisplayLabel):"",P=!!e.sourceGroupId&&f.rowDisplayLabel==="";l.push({label:x?a(x,b):i(),displayLabel:v||(P?"":String(d+1)),origin:{x:f.start.x,y:f.start.y},rotation:I,seatCount:b,seatSpacing:w,...p?{directSourceRowId:p}:{},...S?{directReviewedSuffix:S}:{}}),c+=b}return{skip:null,rows:l,seats:c}}function ns(e,t,n){j(e,n.categoryKey);let o=C(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=n.categoryKeyForSection?.(h)??n.categoryKey;j(e,p),r.set(h,p)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&s){let h=Oo(o.objects,i,a.id).filter(p=>F(L(p),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:h.map(p=>p.id)}]}}let l=o.objects.filter(h=>Co(h,i,a?.id)),c=es(l,t,a?.id),d=[],f=o.objects.filter(h=>Co(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...f);let b=[],g=[],y=[],m=new Set,w=0,I=Za(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=ts(h,o.objects,i,t.seatPitch,I.ordinaryFor(h.name),I.direct,a?.id);if(p.skip){g.push(p.skip);continue}let S=p.rows.map(x=>({type:"row",id:M(e,"r",n.idFactory,m),referenceScan:{assetId:i,...h.sectionId?{sectionId:h.sectionId}:{},...x.directSourceRowId?{directSourceRowId:x.directSourceRowId}:{},...x.directReviewedSuffix?{directReviewedSuffix:x.directReviewedSuffix}:{}},label:x.label,...x.displayLabel!==void 0?{displayLabel:x.displayLabel}:{},origin:x.origin,rotation:x.rotation,curve:0,seatCount:x.seatCount,seatSpacing:x.seatSpacing,categoryKey:r.get(h)??n.categoryKey,...x.directSourceRowId&&c.has(x.directSourceRowId)?{overrides:structuredClone(c.get(x.directSourceRowId))}:{}}));o.objects.push(...S);for(let x of S)y.push(x.id);b.push({sectionId:h.sectionId,name:h.name,seats:p.seats,rows:S.length}),w+=p.seats}return{floorId:o.floorId,assetId:i,createdRowIds:y,removedRowIds:d,totalSeats:w,perSection:b,skipped:g}}function Po(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.objectIds)];if(!i.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=i.map(m=>o.objects.find(w=>(w.type==="table"||w.type==="booth")&&w.id===m)),r=i.filter((m,w)=>!a[w]);if(r.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:r});let s=a[0].type;if(a.some(m=>m.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[m,w,I]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(w)||w<1||w>I)throw new u("invalid_operation",`${m} must be a whole number from 1 to ${I}`);for(let[m,w]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(w)||w<30||w>2e3)throw new u("invalid_operation",`${m} must be from 30 to 2000 chart units`);let l=t.rows*t.columns;if(l<2)throw new u("invalid_operation","Choose at least two grid cells");let c=i.length*(l-1);if(c>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((m,w)=>m+(w.type==="table"?w.seatCount:1),0),b=(e.floors?.length?e.floors.flatMap(m=>m.objects):e.objects).reduce((m,w)=>m+(w.type==="row"||w.type==="table"?w.seatCount:w.type==="gaArea"?Math.max(0,Math.floor(w.capacity)):w.type==="booth"?1:0),0),g=d*(l-1),y=n.maxInventory??1e5;if(b+g>y)throw new u("invalid_operation",`Grid inventory would exceed the ${y} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:i,sourceCount:i.length,cells:l,createdCount:c,addedInventory:g,resultingInventory:b+g,provenanceRemovedCount:a.filter(m=>!!m.referenceInventorySource).length*(l-1)}}}function os(e,t,n={}){return Po(e,t,n).preview}function rs(e,t,n={}){let{target:o,sources:i,preview:a}=Po(e,t,n),r=new Set,s=new Set((e.floors?.length?e.floors.flatMap(f=>f.objects):e.objects).flatMap(f=>"label"in f&&f.label?[f.label]:[])),l=[],c=(f,b)=>{let g=Math.max(2,b),y=w=>{let I=`-${w}`;return`${f.slice(0,Math.max(1,80-I.length))}${I}`},m=y(g);for(;s.has(m);)m=y(++g);return s.add(m),m},d=1;for(let f=0;f<t.rows;f++)for(let b=0;b<t.columns;b++)if(!(f===0&&b===0)){d+=1;for(let g of i){let y=structuredClone(g);y.id=M(e,y.type,t.idFactory,r),y.label=c(g.label,d),y.center={x:g.center.x+b*t.stepX,y:g.center.y+f*t.stepY},delete y.referenceInventorySource,l.push(y)}}return o.objects.push(...l),{...a,createdIds:l.map(f=>f.id)}}function is(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=E(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var as=new Set(_e.map(e=>e.key));function Te(e){return`${e.rowId}:${e.index}`}function ss(e){let t=e.lastIndexOf(":"),n=t>0?e.slice(0,t):"",o=t>0?Number(e.slice(t+1)):Number.NaN;if(!n||!Number.isInteger(o)||o<0)throw new u("invalid_operation",`Invalid stable seat id: ${e}`,{seatId:e});return{rowId:n,index:o}}function cs(e,t){e.label||delete e.label,e.displayLabel||delete e.displayLabel,e.dx||delete e.dx,e.dy||delete e.dy,e.skip||delete e.skip,e.categoryKey||delete e.categoryKey,Ee(e.glyph)||delete e.glyph;let n=Oe(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),i={};typeof e.commercial.restrictedView=="boolean"&&(i.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(i.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(i.premium=e.commercial.premium),o&&(i.note=o),Object.keys(i).length?e.commercial=i:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&Ve(t,e)}function ls(e){return Object.keys(e).every(t=>t==="index")}function _o(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(e,t),i=[],a=new Set,r=new Map;for(let s of n){let l=Te(s);if(a.has(l))continue;a.add(l);let c=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!c)throw new u("object_not_found",`Unknown row or table for seat: ${l}`,{seatId:l,objectId:s.rowId});if(c.type==="table"&&(c.bookAsWhole||c.variableOccupancy))throw new u("invalid_operation",`Table "${c.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:l,tableId:c.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=c.seatCount)throw new u("invalid_operation",c.type==="row"?`Seat index is outside row bounds: ${l}`:`Chair index is outside table bounds: ${l}`,{seatId:l,objectId:s.rowId,index:s.index,seatCount:c.seatCount});i.push({rowId:s.rowId,index:s.index}),r.set(c.id,c)}return{floorId:o.floorId,refs:i,owners:r}}function Jt(e,t){let n=_o(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.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&&t.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(t.patch.categoryKey&&j(e,t.patch.categoryKey),t.patch.glyph!=null&&!Ee(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(r=>!as.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.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(c=>c.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,l=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(s&&l)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Te(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=ee(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&ge(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let s=n.owners.get(a.rowId),l=JSON.stringify(s.overrides??[]),c=s.overrides??(s.overrides=[]),d=c.find(b=>b.index===a.index);d||(d={index:a.index},c.push(d));let f=d.viewFromSeatUrl;for(let b of o){let g=t.patch[b];if(b==="wheelchairSpaceType"&&g==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(y=>y!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(g==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(g)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...g};else if(b==="labelStyle"){let y=is(d.labelStyle,g);y?d.labelStyle=y:delete d.labelStyle}else Object.assign(d,{[b]:g})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==f&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),cs(d,s),ls(d)&&(s.overrides=c.filter(b=>b!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==l&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map(Te)}}function ds(e,t){let n=_o(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(l=>l.rowId===i).map(l=>l.index)),s=a.overrides.filter(l=>!r.has(l.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(Te)}}function us(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(p=>p.type==="row"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&j(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,p=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!p.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${p.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:s,labelRotation:l,labelStyleShape:c,displayLabel:d,displayType:f,...b}=t.patch,g=d===void 0?{}:{displayLabel:d},y=fe(g,"Row"),m=f===void 0?void 0:Rt(f,"Row");if(r!==void 0&&ge(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(l!=null&&(!Number.isFinite(l)||l<-180||l>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(c!==void 0&&c!=="plain"&&c!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&Xe(b.labelPresentation,"Row");let w=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),I=!1;for(let h of i){let p=JSON.stringify(h),S=w(h),x=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?L(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(v=>v.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),x){let v=L(h);h.origin={x:h.origin.x+x.x-v.x,y:h.origin.y+x.y-v.y}}if(JSON.stringify(h)!==p&&(I=!0),w(h)!==S&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=Ye(h.labelPresentation,r);P?h.labelPresentation=P:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(s!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(l!==void 0||c!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};l===null?delete P.rotation:l!==void 0&&(P.rotation=l),c!==void 0&&(P.style=c),h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(m!==void 0){let v=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==v&&(I=!0)}if(d!==void 0){let v=h.displayLabel;y?delete h.displayLabel:h.displayLabel=g.displayLabel,h.displayLabel!==v&&(I=!0)}}return{floorId:n.floorId,changed:I,rowIds:o}}var fs=3;function ct(e){return(e%360+360)%360}function gs(e){let t=e.rotation*J;return{x:Math.cos(t),y:Math.sin(t)}}function bs(e,t){let n=Math.abs(ct(e-t));return n>180&&(n=360-n),n}function ye(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Ao(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*J;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function hs(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=i=>({x:i.x+t,y:i.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function Mo(e,t){let n=Ao(e),o={x:-n.y,y:n.x},i=L(e[0]),a=e.map(l=>({row:l,coord:ye(L(l),i,o)})).sort((l,c)=>l.coord-c.coord),r=a[0].coord,s=!1;return a.forEach((l,c)=>{let d=r+c*t-l.coord;Math.abs(d)>1e-6&&(hs(l.row,o.x*d,o.y*d),delete l.row.arcFanGeneration,delete l.row.rowBlockGeneration,s=!0)}),s}function ps(e,t){let n={x:-t.y,y:t.x},o=L(e[0]),i=e.map(r=>ye(L(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 ys(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=de(e),n=t[0],o=t[t.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,r/(e.seatCount-1))),r>1e-6&&(e.rotation=ct(Math.atan2(a,i)/J)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function ms(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${t}${o}`.slice(0,80);if(!n.has(i))return i}return`${t}-${Date.now().toString(36)}`}function ws(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(x=>n.objects.find(v=>v.type==="row"&&v.id===x)),a=o.filter((x,v)=>!i[v]);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(x=>x.path||x.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged. Straighten the rows first, then merge.",{rowIds:s.map(x=>x.id)});let l=r[0],c=r.find(x=>bs(x.rotation,l.rotation)>fs);if(c)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[l.id,c.id]});let d=gs(l),f={x:-d.y,y:d.x},b=Math.max(8,l.seatSpacing*.6),g=r.find(x=>Math.abs(ye(x.origin,l.origin,f))>b);if(g){let x=Math.round(Math.abs(ye(g.origin,l.origin,f)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${x} units from the first.`,{rowIds:[l.id,g.id]})}let y=r.slice().sort((x,v)=>ye(x.origin,l.origin,d)-ye(v.origin,l.origin,d)),m=y.reduce((x,v)=>x+v.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let w=y[0],I=[],h=0;for(let x of y){if(x.overrides)for(let v of x.overrides)I.push({...structuredClone(v),index:v.index+h});h+=x.seatCount}w.seatCount=m,w.curve=0,delete w.path,I.length?w.overrides=I:delete w.overrides,delete w.arcFanGeneration,delete w.rowBlockGeneration;let p=y.slice(1).map(x=>x.id),S=new Set(p);for(let x=n.objects.length-1;x>=0;x--)S.has(n.objects[x].id)&&n.objects.splice(x,1);return{floorId:n.floorId,changed:!0,rowId:w.id,removedRowIds:p,seatCount:m}}function Ss(e,t){let n=C(e,t.floorId),o=n.objects.find(g=>g.type==="row"&&g.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row. Straighten it first, then split.",{rowIds:[o.id]});let i=o.seatCount,a=t.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,l=i-a,c={type:"row",id:M(e,"r",t.idFactory,new Set),label:ms(n.objects,o.label),origin:{...r[a]},rotation:ct(o.rotation-s*a),curve:s*(l-1),seatCount:l,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(c.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(c.seatLabelStart=o.seatLabelStart),o.commercial&&(c.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(c.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(c.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(c.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let g=structuredClone(o.labelPresentation);delete g.position,c.labelPresentation=g}let d=[],f=[];if(o.overrides)for(let g of o.overrides)g.index<a?d.push(structuredClone(g)):f.push({...structuredClone(g),index:g.index-a});o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,f.length&&(c.overrides=f);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,c),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:c.id,firstSeatCount:a,secondSeatCount:l,newLabel:c.label}}function xs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.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(l=>l.type==="row"&&l.id===s)),a=o.filter((s,l)=>!i[l]);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=Mo(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function vs(e,t){let n=C(e,t.floorId),o=[...new Set(t.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(g=>g.type==="row"&&g.id===b)),a=o.filter((b,g)=>!i[g]);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])),l=s();for(let b of r)ys(b);let c=Ao(r),d=ct(Math.atan2(c.y,c.x)/J);for(let b of r)b.rotation=d;let f=ps(r,c);return Mo(r,f),{floorId:n.floorId,changed:s()!==l,rowIds:o,gap:f}}var dt=ir(require("polygon-clipping"),1),jo=100,Lo=512,Xt=8192,Ko=64,ko=1e7,T=1e-7;function $o(e,t){return Math.abs(e.x-t.x)<=T&&Math.abs(e.y-t.y)<=T}function Bo(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&$o(t[0],t[t.length-1]);)t.pop();return t}function Fe(e,t,n){let o=q(t,n,e);return Math.abs(o)>T?!1:e.x>=Math.min(t.x,n.x)-T&&e.x<=Math.max(t.x,n.x)+T&&e.y>=Math.min(t.y,n.y)-T&&e.y<=Math.max(t.y,n.y)+T}function zo(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),s=q(n,o,t);return(i>T&&a<-T||i<-T&&a>T)&&(r>T&&s<-T||r<-T&&s>T)?!0:Math.abs(i)<=T&&Fe(n,e,t)||Math.abs(a)<=T&&Fe(o,e,t)||Math.abs(r)<=T&&Fe(e,n,o)||Math.abs(s)<=T&&Fe(t,n,o)}function Is(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&zo(e[t],e[n],e[o],e[i]))return!0}}return!1}function Eo(e,t){return e.some((n,o)=>t.some((i,a)=>zo(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function Yt(e,t){return!t.some((n,o)=>Fe(e,n,t[(o+1)%t.length]))&&F(e,t,void 0)}function ut(e,t,n){let o=Bo(e);if(o.length<3||o.length>Lo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>ko||Math.abs(i.y)>ko||$o(i,o[(a+1)%o.length]))||Math.abs(ve(o))<=T||Is(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Lo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Cs(e){let t=ut(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Ko)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>ut(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((s,l)=>{let c=a[(l+1)%a.length];return[s,{x:(s.x+c.x)/2,y:(s.y+c.y)/2}]}).every(s=>Yt(s,t))||Eo(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(Eo(a,o[s])||Yt(a[0],o[s])||Yt(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function lt(e){return e.map(t=>[t.x,t.y])}function To(e){return Bo(e.map(([t,n])=>({x:t,y:n})))}function Fo(e){return Math.abs(e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n[0]*i[1]-i[0]*n[1]},0))/2}function Os(e){return e.reduce((t,n)=>t+(Fo(n[0]??[])-n.slice(1).reduce((o,i)=>o+Fo(i),0)),0)}function Qt(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Qt).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Qt(t[n])}`).join(",")}}`}function No(e,t,n){let o=e[t];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 ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return i}function Do(e){return Qt({categoryKey:e.categoryKey,displayLabel:No(e,"displayLabel",80),displayType:No(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function Go(e,t){let n=Math.min(...e.points.map(i=>i.y)),o=Math.min(...e.points.map(i=>i.x));return[n,o,t]}function Rs(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function Uo(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.gaAreaIds)];if(i.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(i.length>jo)throw new u("invalid_operation",`Join Areas supports at most ${jo} areas at once`);let a=i.map(O=>o.objects.find(_=>_.type==="gaArea"&&_.id===O)),r=i.filter((O,_)=>!a[_]);if(r.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:r});let s=a;j(e,s[0].categoryKey);let l=Do(s[0]),c=s.find(O=>Do(O)!==l);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:[s[0].id,c.id]});let d=je(e).objectToSection,f=d.get(s[0].id)??"__ungrouped__",b=s.find(O=>(d.get(O.id)??"__ungrouped__")!==f);if(b)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,b.id],sectionIds:[f,d.get(b.id)??"__ungrouped__"]});let g=s.reduce((O,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>X)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return O+_.capacity},0);if(g>X)throw new u("invalid_operation",`Joined GA capacity would be ${g}, over the ${X}-unit area limit`,{capacity:g});let y=B(e).reduce((O,_)=>O+re(_),0),m=n.maxInventory??1e5;if(y>m)throw new u("invalid_operation",`Chart inventory exceeds the ${m}-unit publication limit`,{inventory:y});let w=s.map(Cs),I=w.reduce((O,_)=>O+_.outer.length+_.holes.reduce((V,Z)=>V+Z.length,0),0);if(I>Xt)throw new u("invalid_operation",`Join Areas supports at most ${Xt} source vertices`,{vertexCount:I});let h;try{let O=w.map(Z=>[lt(Z.outer)]);if(h=dt.default.union(O[0],...O.slice(1)),h.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:h.length});let _=w.flatMap(Z=>Z.holes.map(ht=>[lt(ht)]));_.length&&(h=dt.default.difference(h,..._));let V=w.findIndex(Z=>{let ht=[lt(Z.outer),...Z.holes.map(lt)];return Os(dt.default.intersection(ht,h))<=T});if(V>=0)throw new u("invalid_operation",`GA area ${s[V].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[V].id})}catch(O){throw O instanceof u?O:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:O instanceof Error?O.message:"polygon_union_failed"})}if(h.length!==1||!h[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:h.length});let p=To(h[0][0]),S=h[0].slice(1).map(To),x=p.length+S.reduce((O,_)=>O+_.length,0);if(S.length>Ko||x>Xt)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:S.length,vertexCount:x});ut(p,"outline",s[0].id),S.forEach(O=>ut(O,"cutout",s[0].id));let v=new Map(o.objects.map((O,_)=>[O.id,_])),P=s.slice().sort((O,_)=>Rs(Go(O,v.get(O.id)??Number.MAX_SAFE_INTEGER),Go(_,v.get(_.id)??Number.MAX_SAFE_INTEGER))),N=P[0],G=structuredClone(e),K=C(G,o.floorId),$=K.objects.find(O=>O.type==="gaArea"&&O.id===N.id);$.points=structuredClone(p),S.length?$.holes=structuredClone(S):delete $.holes;let R=new Set(P.slice(1).map(O=>O.id));for(let O=K.objects.length-1;O>=0;O-=1)R.has(K.objects[O].id)&&K.objects.splice(O,1);let z=je(G).objectToSection.get(N.id)??"__ungrouped__";if(z!==f)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:N.id,beforeSectionId:f,afterSectionId:z});let A=[],xe=new Set;for(let O of P){if(!jt(O))throw new u("invalid_operation",`GA area ${O.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:O.id});let _=W(O);if(_.length!==O.capacity||_.some(V=>xe.has(V)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:O.id});_.forEach(V=>xe.add(V)),A.push(...et(O))}if(A.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let Qo=new Set(s.map(O=>O.id));for(let O of B(e).filter(_=>_.type==="gaArea"&&!Qo.has(_.id))){let _=W(O).find(V=>xe.has(V));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:O.id})}let Wo=P.slice(1).map(O=>O.id);return{floorId:o.floorId,areaId:N.id,survivorLabel:N.label,removedAreaIds:Wo,sourceAreaCount:P.length,capacity:g,inventorySegmentCount:A.length,outerVertexCount:p.length,holeCount:S.length,sectionId:f,points:p,...S.length?{holes:S}:{},segments:A}}function Ps(e,t,n={}){let{segments:o,...i}=Uo(e,t,n);return i}function _s(e,t,n={}){let o=Uo(e,t,n),i=C(e,o.floorId),a=i.objects.find(c=>c.type==="gaArea"&&c.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes,a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments);let r=new Set(o.removedAreaIds);for(let c=i.objects.length-1;c>=0;c-=1)r.has(i.objects[c].id)&&i.objects.splice(c,1);let{segments:s,...l}=o;return{...l,changed:!0}}function As(e,t){let n=C(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(c=>n.objects.find(d=>d.type==="shape"&&d.id===c)),a=o.filter((c,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(t.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.labelStyle!==void 0){let c=i.filter(d=>d.role!=="stage");if(c.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:c.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<ue||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${ue} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=E(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");for(let d of["bold","italic","underline"]){let f=r.labelStyle[d];if(f!=null&&typeof f!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=E(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:E(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 c=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!c.length||c.length>20||c.some(d=>!d||d.length>100)||new Set(c).size!==c.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=c}if(r.lineCap!==void 0&&r.lineCap!==null&&!no.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!oo.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[c,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!ro.includes(d))throw new u("invalid_operation",`Shape ${c} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let c=i.filter(d=>!Kt(r.kind??d.kind));if(c.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:c.map(d=>d.id)})}let l=!1;for(let c of i){let d=JSON.stringify(c);if(r.label===null?delete c.label:r.label!==void 0&&(c.label=r.label),r.labelStyle!==void 0){let f={...c.labelStyle};r.labelStyle.size===null?delete f.size:r.labelStyle.size!==void 0&&(f.size=r.labelStyle.size),r.labelStyle.color===null?delete f.color:r.labelStyle.color!==void 0&&(f.color=r.labelStyle.color),r.labelStyle.fontFamily===null?delete f.fontFamily:r.labelStyle.fontFamily!==void 0&&(f.fontFamily=r.labelStyle.fontFamily),r.labelStyle.bold===null?delete f.bold:r.labelStyle.bold!==void 0&&(f.bold=r.labelStyle.bold),r.labelStyle.italic===null||r.labelStyle.italic===!1?delete f.italic:r.labelStyle.italic===!0&&(f.italic=!0),r.labelStyle.underline===null||r.labelStyle.underline===!1?delete f.underline:r.labelStyle.underline===!0&&(f.underline=!0),Object.keys(f).length?c.labelStyle=f:delete c.labelStyle}if(r.fill===null?delete c.fill:r.fill!==void 0&&(c.fill=r.fill),r.kind!==void 0&&(c.kind=r.kind,Kt(c.kind)||(delete c.lineCap,delete c.lineJoin,delete c.startEnding,delete c.endEnding)),r.stroke===null?delete c.stroke:r.stroke!==void 0&&(c.stroke={...r.stroke}),r.opacity===null?delete c.opacity:r.opacity!==void 0&&(c.opacity=r.opacity),r.heightM===null?delete c.heightM:r.heightM!==void 0&&(c.heightM=r.heightM),r.eventConfigurationIds===null?delete c.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(c.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete c.lineCap:r.lineCap!==void 0&&(c.lineCap=r.lineCap),r.lineJoin===null?delete c.lineJoin:r.lineJoin!==void 0&&(c.lineJoin=r.lineJoin),r.startEnding===null?delete c.startEnding:r.startEnding!==void 0&&(c.startEnding=r.startEnding),r.endEnding===null?delete c.endEnding:r.endEnding!==void 0&&(c.endEnding=r.endEnding),r.cornerRadius===null)delete c.cornerRadius;else if(r.cornerRadius!==void 0){let f=Math.min(c.width??1/0,c.height??1/0),b=Number.isFinite(f)?f/2:r.cornerRadius;c.cornerRadius=c.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(c)!==d&&(ze(c),l=!0)}return{floorId:n.floorId,changed:l,shapeIds:o}}function Vo(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),s=Math.max(...o),l=Math.max(1,a-i),c=Math.max(1,s-r);return{cx:i+l/2,cy:r+c/2,width:l,height:c}}function Ms(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.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(c=>c.type==="shape"&&c.id===r.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let l=s.role==="stage"?Vo(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 c=s.points??[];if(c.length<3||c.some(w=>!Number.isFinite(w.x)||!Number.isFinite(w.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=c.map(w=>w.x),f=c.map(w=>w.y),b=Math.min(...d),g=Math.max(...d),y=Math.min(...f),m=Math.max(...f);return{cx:(b+g)/2,cy:(y+m)/2,width:Math.max(1,g-b),height:Math.max(1,m-y)}})();return{shape:s,update:r,box:l}}),a=!1;for(let{shape:r,update:s,box:l}of i)if(!(Math.abs(l.width-s.width)<1e-9&&Math.abs(l.height-s.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height;else{let c=s.width/l.width,d=s.height/l.height;r.points=(r.points??[]).map(f=>({x:l.cx+(f.x-l.cx)*c,y:l.cy+(f.y-l.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=l.cx-s.width/2,r.y=l.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 js(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.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=t.updates.map(s=>{if(!i.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let l=n.objects.find(c=>c.type==="shape"&&c.id===s.stageId);if(!l)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(l.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:l,stageKind:s.stageKind,box:l.stageKind===s.stageKind?null:Vo(l)}}),r=!1;for(let s of a)s.box&&(s.shape.points=pn({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}))}}function qo(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of k(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function ft(e){return Array.isArray(e)?e.map(ft):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,ft(n)]))}function ks(e,t){return JSON.stringify(ft(e))===JSON.stringify(ft(t))}function Wt(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Es(e){return e?e.status==="retracted"?"retract":Wt(e)?"approve":"set":"clear"}function Jo(e,t){let n=qo(e),o=qo(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let s=n.get(r),l=o.get(r);if(s&&l&&ks(s.evidence,l.evidence))continue;let c=l?.target??s?.target;c&&a.push({...c,operation:Es(l?.evidence),...s?{before:s.evidence}:{},...l?{after:l.evidence}:{}})}return a}function Ts(e,t){return Jo(e,t).some(n=>Wt(n.before)||Wt(n.after))}var Fs=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Ns=new Set(["generated","geometry-verified","configuration-verified"]),Ds=new Set(["none","comparable-build-reference","actual-build-checked"]),Gs=new Set(["clear","partial","obstructed"]);function Zt(e){return e.toISOString().slice(0,10)}function en(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function we(e,t,n){if(!en(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function me(e,t,n){if(e!==void 0)return we(e,t,n)}function gt(e,t,n){let o=n?[C(e,n)]:k(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function Xo(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Ne(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return Xo(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=gt(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(i=>i.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=gt(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function bt(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=Xo(e,t.floorId);return n?i.confidenceEvidence=n:delete i.confidenceEvidence,{floorId:i.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let i=gt(e,t.objectId,t.floorId);return Jt(e,{floorId:i.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:i.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=gt(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function Ks(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!en(e.label,80)||!en(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!Gs.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>we(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function Yo(e,t=new Date){if(e.schema!==void 0&&e.schema!=="seatlayer.seat-confidence/1")throw new u("invalid_operation","Confidence evidence schema must be seatlayer.seat-confidence/1");if(!Fs.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Ns.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Ds.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=me(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let i=e.limitations?.map(f=>we(f,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=me(e.assessedAt,40,"assessedAt")??Zt(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=me(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Zt(new Date(r+365*24*60*60*1e3))),l=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(l)||l<r||l>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let c=me(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!c)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=me(e.sourceLabel,120,"sourceLabel");if(n!=="none"&&!d)throw new u("invalid_operation","Real-world evidence requires a buyer-safe source describing what was checked");if(n==="actual-build-checked"&&(e.modelLevel!=="configuration-verified"||!o))throw new u("invalid_operation","An actual-build check requires a configuration-verified model and an event configuration");return{schema:"seatlayer.seat-confidence/1",evidenceId:we(e.evidenceId,120,"evidenceId"),modelVersion:we(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...c?{approvedByRole:c}:{},...d?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:Ks(e.modeledTarget)}:{}}}function Se(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function $s(e,t){let n=Yo(t.evidence,t.now),o=JSON.stringify(Ne(e,t)??null),i=bt(e,t,n),a=JSON.stringify(Ne(e,t)??null);return Se(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function Bs(e,t){let n=Ne(e,t);if(!n)return Se(t,{changed:!1});let o=bt(e,t,void 0);return Se(t,{changed:!0,...o,evidenceId:n.evidenceId})}function zs(e,t){let n=Ne(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=we(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=me(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!i)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let r={...n,status:"approved",approvedByRole:o,assessedAt:Zt(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(r.basisSha256=s);let l=JSON.stringify(n),c=bt(e,t,r);return Se(t,{changed:l!==JSON.stringify(r),...c,evidenceId:r.evidenceId,status:"approved"})}function Us(e,t){let n=Ne(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return Se(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=bt(e,t,o);return Se(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});