@seatlayer/core 0.109.2 → 0.110.1

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 (166) hide show
  1. package/dist/ar-C5PA2DVE.js +1 -0
  2. package/dist/be-TMKSMYPN.js +1 -0
  3. package/dist/bg-V6HTEDUB.js +1 -0
  4. package/dist/ca-CTZMHWW4.js +1 -0
  5. package/dist/{categoryInventory-WNOXm5Il.d.cts → categoryInventory-BE1AThTx.d.cts} +1 -1
  6. package/dist/{categoryInventory-nNbloQGE.d.ts → categoryInventory-DxciZQK_.d.ts} +1 -1
  7. package/dist/chunk-2VYFNNYC.js +1 -0
  8. package/dist/{chunk-YE4NP3XB.js → chunk-3V32MDJI.js} +1 -1
  9. package/dist/{chunk-GPZFVQXV.js → chunk-4522UUXG.js} +1 -1
  10. package/dist/chunk-4AGC7B64.js +1 -0
  11. package/dist/{chunk-ZYQXT5JP.js → chunk-5IADCFUU.js} +1 -1
  12. package/dist/{chunk-2JFCDE27.js → chunk-6CBJBESS.js} +1 -1
  13. package/dist/{chunk-LFV56MPT.js → chunk-DLHW3UDD.js} +1 -1
  14. package/dist/{chunk-JRZHC75P.js → chunk-EE2CVYFJ.js} +1 -1
  15. package/dist/{chunk-33SRM2CP.js → chunk-GUNNA5LB.js} +1 -1
  16. package/dist/{chunk-UUIZHJYL.js → chunk-GVVZR3YS.js} +1 -1
  17. package/dist/{chunk-MRLWH6RC.js → chunk-GWGWNBGU.js} +1 -1
  18. package/dist/chunk-JQBJZMLG.js +1 -0
  19. package/dist/chunk-NVAF2E7Q.js +1 -0
  20. package/dist/{chunk-WKWXU5QM.js → chunk-PBXGWYB4.js} +1 -1
  21. package/dist/{chunk-UEDS3HJ3.js → chunk-URW7MSCJ.js} +1 -1
  22. package/dist/{chunk-FBXZWNND.js → chunk-YRDOE3N7.js} +1 -1
  23. package/dist/{chunk-UNSAUDO2.js → chunk-ZY6WTPTI.js} +1 -1
  24. package/dist/core/chart-ops/index.cjs +1 -1
  25. package/dist/core/chart-ops/index.d.cts +36 -6
  26. package/dist/core/chart-ops/index.d.ts +36 -6
  27. package/dist/core/chart-ops/index.js +1 -1
  28. package/dist/core/inventory/index.cjs +1 -1
  29. package/dist/core/inventory/index.d.cts +4 -4
  30. package/dist/core/inventory/index.d.ts +4 -4
  31. package/dist/core/inventory/index.js +1 -1
  32. package/dist/core/layout/index.d.cts +5 -5
  33. package/dist/core/layout/index.d.ts +5 -5
  34. package/dist/core/layout/index.js +1 -1
  35. package/dist/core/quality/index.cjs +1 -1
  36. package/dist/core/quality/index.d.cts +3 -3
  37. package/dist/core/quality/index.d.ts +3 -3
  38. package/dist/core/quality/index.js +1 -1
  39. package/dist/core/render-assets/index.cjs +1 -1
  40. package/dist/core/render-assets/index.d.cts +2 -2
  41. package/dist/core/render-assets/index.d.ts +2 -2
  42. package/dist/core/render-assets/index.js +1 -1
  43. package/dist/core/seatConfidence.d.cts +1 -1
  44. package/dist/core/seatConfidence.d.ts +1 -1
  45. package/dist/core/sections/index.d.cts +5 -5
  46. package/dist/core/sections/index.d.ts +5 -5
  47. package/dist/core/sections/index.js +1 -1
  48. package/dist/cs-FUDGOUFL.js +1 -0
  49. package/dist/cy-5RRARIAP.js +1 -0
  50. package/dist/da-PONPPWKY.js +1 -0
  51. package/dist/de-PKG7AAB5.js +1 -0
  52. package/dist/el-H7OFU4QQ.js +1 -0
  53. package/dist/es-QSW5IZ6U.js +1 -0
  54. package/dist/et-GTMPSS72.js +1 -0
  55. package/dist/{eventConfigurations-QwuBqi8E.d.ts → eventConfigurations-Cdt-e0uD.d.ts} +1 -1
  56. package/dist/{eventConfigurations-Dp0gQBxf.d.cts → eventConfigurations-D0us5j0K.d.cts} +1 -1
  57. package/dist/fa-SGLTFGJF.js +1 -0
  58. package/dist/fi-7YTEAVDM.js +1 -0
  59. package/dist/fr-ECCQ24MZ.js +1 -0
  60. package/dist/he-YHMMDOX7.js +1 -0
  61. package/dist/hi-GRAQX2E6.js +1 -0
  62. package/dist/hr-MN33LRIJ.js +1 -0
  63. package/dist/hu-NW3SMQVM.js +1 -0
  64. package/dist/id-3OPRAUF7.js +1 -0
  65. package/dist/index.cjs +1 -1
  66. package/dist/index.d.cts +31 -13
  67. package/dist/index.d.ts +31 -13
  68. package/dist/index.js +1 -1
  69. package/dist/it-RYM74YWO.js +1 -0
  70. package/dist/ja-4NI6DG5D.js +1 -0
  71. package/dist/ko-C4F6UEMK.js +1 -0
  72. package/dist/ku-DMSBMWTC.js +1 -0
  73. package/dist/{labeling-CLrYgex2.d.ts → labeling-DXgkxMoi.d.ts} +1 -1
  74. package/dist/{labeling-Bzfv743A.d.cts → labeling-eYKVPLMb.d.cts} +1 -1
  75. package/dist/localeLoaders-G3GCGLPW.js +1 -0
  76. package/dist/lt-3EXKKZFG.js +1 -0
  77. package/dist/lv-4EWNRDCG.js +1 -0
  78. package/dist/ms-7LJBSAEJ.js +1 -0
  79. package/dist/nl-GWTIWXRW.js +1 -0
  80. package/dist/no-T3FW2WLX.js +1 -0
  81. package/dist/pl-OG5OBRHR.js +1 -0
  82. package/dist/pt-YQ6VES5R.js +1 -0
  83. package/dist/{renderedQuality-DL_Bwohi.d.ts → renderedQuality-Dzo2_8f4.d.ts} +1 -1
  84. package/dist/{renderedQuality-D7adZpeD.d.cts → renderedQuality-Frgw6jdx.d.cts} +1 -1
  85. package/dist/{renderer-BaX5XS07.d.cts → renderer-DM2sv1un.d.cts} +19 -2
  86. package/dist/{renderer-GIwwPupP.d.ts → renderer-DuieD7jP.d.ts} +19 -2
  87. package/dist/ro-VK5MASYF.js +1 -0
  88. package/dist/ru-YU5CYR6T.js +1 -0
  89. package/dist/{seatTypeIcons-BbHRuAXE.d.ts → seatTypeIcons-Bz0OJtEi.d.ts} +1 -1
  90. package/dist/{seatTypeIcons-CnIsRKIM.d.cts → seatTypeIcons-Cm8tjLYl.d.cts} +1 -1
  91. package/dist/{sections-BOaTNaYG.d.ts → sections-Bf_DV0oG.d.ts} +1 -1
  92. package/dist/{sections-DRiD7LLT.d.cts → sections-PbQiqN0i.d.cts} +1 -1
  93. package/dist/{segmentedRowModel-CDm8wEMA.d.ts → segmentedRowModel-CO7DD803.d.ts} +1 -1
  94. package/dist/{segmentedRowModel-C0MT2W3h.d.cts → segmentedRowModel-Co9LqS4i.d.cts} +1 -1
  95. package/dist/sk-CE7PXAYL.js +1 -0
  96. package/dist/sl-EYUPV4BG.js +1 -0
  97. package/dist/sr-PPXCN4IK.js +1 -0
  98. package/dist/sv-WR2BJBCJ.js +1 -0
  99. package/dist/{tableSizing-CjeVoew4.d.ts → tableSizing-BDePQyPD.d.ts} +3 -3
  100. package/dist/{tableSizing-BvWmV_II.d.cts → tableSizing-C6EjKNnk.d.cts} +3 -3
  101. package/dist/th-JUB2DODR.js +1 -0
  102. package/dist/{ticketRestrictions-Cp_Wkjy9.d.cts → ticketRestrictions-CgYwHQOf.d.cts} +2 -2
  103. package/dist/{ticketRestrictions-P3RuwcmT.d.ts → ticketRestrictions-D5wgOq4P.d.ts} +2 -2
  104. package/dist/tr-GFHA7FT6.js +1 -0
  105. package/dist/{types-fSWyPu3f.d.ts → types-CGOr0BpE.d.cts} +41 -16
  106. package/dist/{types-fSWyPu3f.d.cts → types-CGOr0BpE.d.ts} +41 -16
  107. package/dist/uk-3FTS2SRK.js +1 -0
  108. package/dist/vi-7OTXPOQV.js +1 -0
  109. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  110. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  111. package/dist/view3d/index.cjs +410 -169
  112. package/dist/view3d/index.d.cts +100 -4
  113. package/dist/view3d/index.d.ts +100 -4
  114. package/dist/view3d/index.js +408 -167
  115. package/dist/view3d/scene/scene.worker.cjs +1 -1
  116. package/dist/view3d/scene/scene.worker.js +1 -1
  117. package/dist/zh-Hans-FD4XNYUA.js +1 -0
  118. package/dist/zh-Hant-7TXVJKJQ.js +1 -0
  119. package/package.json +1 -1
  120. package/dist/ar-TPTLODBK.js +0 -1
  121. package/dist/be-SX5AJ2EF.js +0 -1
  122. package/dist/bg-T7FBXPVU.js +0 -1
  123. package/dist/ca-TTI23CKH.js +0 -1
  124. package/dist/chunk-4N5CHKHD.js +0 -1
  125. package/dist/chunk-GUXENCHS.js +0 -1
  126. package/dist/chunk-HSEX7LUB.js +0 -1
  127. package/dist/chunk-T2QG47QQ.js +0 -1
  128. package/dist/cs-KEMKTFP3.js +0 -1
  129. package/dist/cy-EGUWNAAE.js +0 -1
  130. package/dist/da-AHX4SSIT.js +0 -1
  131. package/dist/de-U3ISXVMR.js +0 -1
  132. package/dist/el-NBMJFLGN.js +0 -1
  133. package/dist/es-IYOV3DZF.js +0 -1
  134. package/dist/et-QHFQ3BIM.js +0 -1
  135. package/dist/fa-FEFRLXP7.js +0 -1
  136. package/dist/fi-HB6NGCIV.js +0 -1
  137. package/dist/fr-5EX7Z5Z5.js +0 -1
  138. package/dist/he-MEW7GMCW.js +0 -1
  139. package/dist/hi-V2CICZDC.js +0 -1
  140. package/dist/hr-SUZYZ3DL.js +0 -1
  141. package/dist/hu-RJFHJPXB.js +0 -1
  142. package/dist/id-LEP73A6A.js +0 -1
  143. package/dist/it-V65UNUVY.js +0 -1
  144. package/dist/ja-3HISSPHC.js +0 -1
  145. package/dist/ko-5DFMEYUO.js +0 -1
  146. package/dist/ku-H3EOMAJX.js +0 -1
  147. package/dist/localeLoaders-M2TUVL75.js +0 -1
  148. package/dist/lt-XHIM3BWS.js +0 -1
  149. package/dist/lv-P5EQD4YY.js +0 -1
  150. package/dist/ms-XC3SU4I2.js +0 -1
  151. package/dist/nl-K2N44NUV.js +0 -1
  152. package/dist/no-C4MFGLSN.js +0 -1
  153. package/dist/pl-ADABFEA3.js +0 -1
  154. package/dist/pt-4AQPHHDG.js +0 -1
  155. package/dist/ro-PZLP7BEU.js +0 -1
  156. package/dist/ru-33R4HJF2.js +0 -1
  157. package/dist/sk-XCXFOU73.js +0 -1
  158. package/dist/sl-23PMG7BB.js +0 -1
  159. package/dist/sr-SOPFKPZ5.js +0 -1
  160. package/dist/sv-PKDMDUS5.js +0 -1
  161. package/dist/th-NU4K5DFF.js +0 -1
  162. package/dist/tr-HEDRXONB.js +0 -1
  163. package/dist/uk-T7JNLCSZ.js +0 -1
  164. package/dist/vi-EWDKGL2Y.js +0 -1
  165. package/dist/zh-Hans-ED7CX2SQ.js +0 -1
  166. package/dist/zh-Hant-UKJQ2KBS.js +0 -1
@@ -1 +1 @@
1
- "use strict";var ls=Object.create;var Dt=Object.defineProperty;var ds=Object.getOwnPropertyDescriptor;var us=Object.getOwnPropertyNames;var fs=Object.getPrototypeOf,hs=Object.prototype.hasOwnProperty;var gs=(e,t)=>{for(var n in t)Dt(e,n,{get:t[n],enumerable:!0})},Jo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of us(t))!hs.call(e,r)&&r!==n&&Dt(e,r,{get:()=>t[r],enumerable:!(o=ds(t,r))||o.enumerable});return e};var bs=(e,t,n)=>(n=e!=null?ls(fs(e)):{},Jo(t||!e||!e.__esModule?Dt(n,"default",{value:e,enumerable:!0}):n,e)),ms=e=>Jo(Dt({},"__esModule",{value:!0}),e);var Gf={};gs(Gf,{AISLE_EMPTY_SEATS:()=>da,COLORBLIND_SAFE_PALETTE:()=>Se,ChartOperationError:()=>u,DECOR_UNITS_PER_METRE:()=>Wa,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>qn,DEFAULT_ROUTE_NAME:()=>lo,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Fn,FIRST_CATEGORY_COLOURS:()=>oa,MAX_BUYER_IMAGE_URL_LENGTH:()=>nc,MAX_FLOOR_BASE_HEIGHT_M:()=>tn,NAMED_AREA_FILL:()=>Qa,ROUTE_STROKE:()=>co,ROW_CURVE_DEGREES:()=>os,addArcFanRows:()=>Co,addArea:()=>pf,addBookableGridArray:()=>cu,addBoothArray:()=>_o,addChartCategories:()=>vd,addChartCategory:()=>yn,addChartFloor:()=>kc,addChartZone:()=>jc,addCurvedRows:()=>Df,addGAArea:()=>Ro,addGate:()=>yl,addIcon:()=>mf,addLandmark:()=>uf,addPlacedBoothArray:()=>Tf,addPlacedGAArea:()=>Mf,addPlacedRowBlocks:()=>Cf,addPlacedTableArray:()=>Rf,addRoute:()=>vl,addRowAisle:()=>Pu,addRowBlock:()=>Ao,addStage:()=>df,addTableArray:()=>Mo,addText:()=>bf,applyPolygonHole:()=>Vl,applyReferenceScanRows:()=>iu,applySectionCornerSmoothing:()=>ed,applySectionEstimates:()=>td,applySectionOutlineShaping:()=>qi,applySectionRowFit:()=>Ul,approveConfidenceEvidence:()=>Ju,arcFanInputForGroup:()=>sa,assignSectionInventoryCategory:()=>Yl,automaticPlacementCenter:()=>ke,blockSectionLabels:()=>Of,clearConfidenceEvidence:()=>Yu,compactChartDoc:()=>xc,compactRowOverrides:()=>_r,compactTableOverrides:()=>kr,confidenceEvidenceChangeRequiresPublish:()=>Ku,confidenceEvidenceChanges:()=>Va,confidenceEvidenceIndex:()=>Du,confirmReferenceCategoryOutputColor:()=>ld,convertGeneratedSectionToPolygon:()=>Jl,convertShapeToOutline:()=>Eu,countCoveredInventory:()=>go,curvedRowsPlacement:()=>as,decorPlacement:()=>tt,decorPlacementCenter:()=>cf,detectSeatLabelRun:()=>Rr,dropRedundantSeatOverrideFields:()=>Zt,familyCategoryLabel:()=>ra,fitSegmentedRowJoin:()=>Pt,gaAreaFootprint:()=>Sn,gateShape:()=>ji,groupRowsAsSegmented:()=>At,insertSeatingBlock:()=>Gl,isSafeBuyerImageUrl:()=>xr,joinGAAreas:()=>Lu,landmarkRoles:()=>yf,makeGate:()=>xl,mergeRows:()=>vu,mirrorFirstFloor:()=>Ae,normalizeBuyerImageUrl:()=>ye,normalizeDraftEvidence:()=>qa,parseSeatRefId:()=>uu,pickColorblindSafeCategoryColor:()=>na,planCreationCategory:()=>ia,previewArcFanRows:()=>vo,previewBookableGridArray:()=>su,previewGeneratedSectionPolygonConversion:()=>Vi,previewJoinGAAreas:()=>ku,previewPolygonHole:()=>mn,previewRemovePolygonHole:()=>zi,previewRowCubicPath:()=>Gi,previewSectionRowFit:()=>$i,reassignColorblindSafeCategoryColors:()=>cd,relabelChartRows:()=>Dl,releaseGateReferences:()=>fo,remapGateReferences:()=>Il,removeCategoryMovingInventory:()=>Cd,removeChartCategory:()=>Io,removeChartFloor:()=>Tc,removeChartObjects:()=>Fl,removeChartZone:()=>Nc,removePolygonHole:()=>Xl,renameChartFloor:()=>Lc,renameDirectSeatImportCategory:()=>rd,reorderChartCategories:()=>id,replaceArcFanRows:()=>Ld,replaceRowBlock:()=>Kd,resetSeatOverrides:()=>gu,resizeShapes:()=>ju,resolveCreationCategory:()=>xd,retractConfidenceEvidence:()=>Wu,roundBuyerCoordinates:()=>Ic,routeShape:()=>Fi,seatRefId:()=>Mt,seatSemanticsSignature:()=>Un,sectionInventorySelectionSummary:()=>Hi,segmentedRowAisleTooNarrow:()=>Nd,setConfidenceEvidence:()=>qu,setObjectEntrance:()=>Sl,setRoute:()=>Cl,setRowBlockSpacing:()=>Cu,splitRow:()=>Do,straightenAndSpaceRows:()=>Ou,transformSectionBoundary:()=>Wl,transformSectionBoundaryObject:()=>Xi,ungroupSegmentedRow:()=>$d,uniqueCategoryLabel:()=>aa,updateBooths:()=>Tl,updateCategoryDefinitions:()=>pn,updateChartFloorBaseHeight:()=>Ec,updateChartTheme:()=>Ad,updateChartZones:()=>Fc,updateGAAreas:()=>jl,updateGate:()=>wl,updateRowCubicPath:()=>Bl,updateRows:()=>bu,updateSeatOverrides:()=>No,updateSectionExactPath:()=>Zl,updateSectionMetadata:()=>bo,updateSegmentedRow:()=>Bd,updateShapes:()=>Tu,updateStageKinds:()=>Fu,updateTables:()=>El,updateTextObjects:()=>Nl,updateViewFromSeatFallback:()=>Rd});module.exports=ms(Gf);var Wo=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function ps(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/Wo(e))),r=0;for(let a of n){if(!a.length){r+=1;continue}let i=0;for(let s of a.split(/\s+/)){let c=s.length;i&&i+1+c<=o?i+=1+c:(r+=Math.max(1,Math.ceil(c/o)),i=c%o)}}return Math.max(1,r)}function Zo(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*Wo(e),r=e.width??o+t*2,a=Math.max(1,r-t*2),i=ps(e,a);return{width:r,height:i*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:i,padding:t}}var ys=Math.PI/180;function Z(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function ws(e,t,n){let o=Math.cos(n),r=Math.sin(n),a=e.x-t.x,i=e.y-t.y;return{x:t.x+a*o-i*r,y:t.y+a*r+i*o}}function Qo(e,t,n){return n?ws(e,t,n*ys):e}function Tn(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function er(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,a=3*n*t*t,i=t*t*t;return{x:o*e.start.x+r*e.control1.x+a*e.control2.x+i*e.end.x,y:o*e.start.y+r*e.control1.y+a*e.control2.y+i*e.end.y}}function Gt(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[er(e,.5)];let o=Array.from({length:n+1},(c,l)=>er(e,l/n)),r=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;r[c]=r[c-1]+Math.hypot(l,d)}let a=r[r.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let i=[],s=1;for(let c=0;c<t;c+=1){let l=a*c/(t-1);for(;s<r.length-1&&r[s]<l;)s+=1;let d=r[s-1],f=r[s],g=f===d?0:(l-d)/(f-d);i.push({x:o[s-1].x+(o[s].x-o[s-1].x)*g,y:o[s-1].y+(o[s].y-o[s-1].y)*g})}return i}function nt(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 ot(e,t,n){return Math.max(t,Math.min(n,e))}function xs(e){return ot(e,0,1)}function tr(e){let t=xs(e);return t*t*(3-2*t)}var Te=Math.PI*2;function je(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Ss(e,t,n){let o=t-e;if(n){for(;o<0;)o+=Te;for(;o>=Te;)o-=Te}else{for(;o>0;)o-=Te;for(;o<=-Te;)o+=Te}return o}function $t(e){if(e.version!==1||e.closed!==!0||!je(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||!je(n.end))return!1;if(n.kind==="line"){if(Z(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!je(n.control1)||!je(n.control2)||Z(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!je(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(Z(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(Z(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Z(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return Z(t,e.start)<=1e-4}function Is(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 rt(e,t=2){if(!$t(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let i=Math.atan2(r.y-a.center.y,r.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),c=Ss(i,s,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(c)*a.radius/n));for(let d=1;d<=l;d+=1){let f=i+c*d/l;o.push({x:a.center.x+Math.cos(f)*a.radius,y:a.center.y+Math.sin(f)*a.radius})}}else{let i=Z(r,a.control1)+Z(a.control1,a.control2)+Z(a.control2,a.end),s=Math.max(2,Math.ceil(i/n));for(let c=1;c<=s;c+=1)o.push(Is(r,a,c/s))}r=a.end}return Z(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function rr(e,t,n){return it(e,r=>({x:r.x+t,y:r.y+n}))}function it(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(r=>r.kind==="line"?{...r,end:t(r.end)}:r.kind==="arc"?{...r,center:t(r.center),radius:r.radius*Math.abs(n),clockwise:o?!r.clockwise:r.clockwise,end:t(r.end)}:{...r,control1:t(r.control1),control2:t(r.control2),end:t(r.end)})}}function ir(e){return e.map(t=>t===0?0:-t)}var Fn=45,jn=150,vs=60;function Cs(e){let t=Fn/100;if(e<=t)return jn;let n=Math.min(1,(e-t)/(1-t));return jn-n*(jn-vs)}var nr=.5523;function or(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Os(e){let t=[],n=[];for(e.forEach((o,r)=>{je(o)&&(t.length&&or(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&or(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var Ps=.5,As=4/3;function Rs(e,t,n){let o=t.x-e.x,r=t.y-e.y,a=Math.hypot(o,r);if(a<=1e-9)return{kind:"line",end:{...t}};let i=-r/a,s=o/a,c=n*As;return{kind:"bezier",control1:{x:e.x+o/3+i*c,y:e.y+r/3+s*c},control2:{x:e.x+o*2/3+i*c,y:e.y+r*2/3+s*c},end:{...t}}}function Bt(e,t){let{points:n,sourceIndex:o}=Os(e),r=n.length;if(r<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,i=t.edgeCurvature,s=new Array(r).fill(0);if(i?.length)for(let S=0;S<r;S+=1){let m=i[o[S]];s[S]=Number.isFinite(m)?Math.min(100,Math.max(-100,m))/100:0}let c=s.some(S=>Math.abs(S)>1e-6);if(a<=0&&!c)return null;let l=t.wideAngleThresholdDeg??Cs(a),d=[];for(let S=0;S<r;S+=1)d[S]=Z(n[S],n[(S+1)%r]);let f=new Array(r).fill(0);for(let S=0;S<r;S+=1){let m=n[(S-1+r)%r],v=n[S],C=n[(S+1)%r],P={x:m.x-v.x,y:m.y-v.y},j={x:C.x-v.x,y:C.y-v.y},Y=Math.hypot(P.x,P.y),J=Math.hypot(j.x,j.y);if(Y<=1e-9||J<=1e-9)continue;let R=Math.min(1,Math.max(-1,(P.x*j.x+P.y*j.y)/(Y*J))),oe=Math.acos(R)*180/Math.PI;if(oe<l)continue;let M=tr((oe-l)/(180-l));f[S]=a*M*.5*Math.min(Y,J)}for(let S=0;S<r;S+=1){let m=(S+1)%r,v=f[S]+f[m];if(v>d[S]&&v>1e-9){let C=d[S]/v;f[S]*=C,f[m]*=C}}let g=new Array(r),h=new Array(r);for(let S=0;S<r;S+=1){let m=n[(S-1+r)%r],v=n[S],C=n[(S+1)%r];if(f[S]<=1e-6){g[S]={...v},h[S]={...v};continue}let P=Z(v,m)||1,j=Z(v,C)||1;g[S]={x:v.x+(m.x-v.x)/P*f[S],y:v.y+(m.y-v.y)/P*f[S]},h[S]={x:v.x+(C.x-v.x)/j*f[S],y:v.y+(C.y-v.y)/j*f[S]}}if(f.every(S=>S<=1e-6)&&!c)return null;let b=[],p={...h[0]},x=p,I=(S,m)=>{if(Z(x,S)<=1e-9)return;let v=s[m];Math.abs(v)>1e-6?b.push(Rs(x,S,v*Ps*d[m])):b.push({kind:"line",end:{...S}}),x=S};for(let S=1;S<=r;S+=1){let m=S%r,v=n[m];I(g[m],(S-1)%r),f[m]>1e-6&&Z(g[m],h[m])>1e-9&&(b.push({kind:"bezier",control1:Tn(g[m],v,nr),control2:Tn(h[m],v,nr),end:{...h[m]}}),x=h[m])}if(!b.length)return null;let y=b[b.length-1];Z(y.end,p)>1e-9&&(y.kind==="line"?y.end={...p}:b.push({kind:"line",end:{...p}}));let w={version:1,closed:!0,start:p,segments:b};return $t(w)?w:null}function Ms(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function at(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function Kt(e,t,n){let o=at(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 _s(e,t,n,o){let r=at(e,t,n),a=at(e,t,o),i=at(n,o,e),s=at(n,o,t);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(i>1e-7&&s<-1e-7||i<-1e-7&&s>1e-7)?!0:Math.abs(r)<=1e-7&&Kt(n,e,t)||Math.abs(a)<=1e-7&&Kt(o,e,t)||Math.abs(i)<=1e-7&&Kt(e,n,o)||Math.abs(s)<=1e-7&&Kt(t,n,o)}function ks(e){return e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)}function Ls(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 r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&_s(e[t],e[n],e[o],e[r]))return!0}}return!1}function ar(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)=>Ms(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(ks(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Ls(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}var Nn=64;function Es(e){let t=e.points??[];if(e.kind!=="polygon"||t.length<3||!Array.isArray(e.edgeCurvature))return[];let n=t.map((o,r)=>{let a=e.edgeCurvature[r];return Number.isFinite(a)?Math.min(100,Math.max(-100,a)):0});return n.some(o=>Math.abs(o)>.5)?n:[]}function Ts(e){let t=Es(e);return t.length?Bt(e.points,{edgeCurvature:t}):null}function st(e,t=2){let n=Ts(e);return n?rt(n,t):e.points??[]}function sr(e){return e.kind==="polygon"?ee(e.holes):[]}function cr(e,t){let n=st(e);return n.length<3||t.length<3||!t.flatMap((r,a)=>{let i=t[(a+1)%t.length];return[r,{x:(r.x+i.x)/2,y:(r.y+i.y)/2}]}).every(r=>zt(r,n)||Dn(r,n))?!1:!t.some((r,a)=>{let i=t[(a+1)%t.length];return n.some((s,c)=>js(r,i,s,n[(c+1)%n.length]))})}function js(e,t,n,o){let r=(l,d,f)=>(d.x-l.x)*(f.y-l.y)-(d.y-l.y)*(f.x-l.x),a=r(e,t,n),i=r(e,t,o),s=r(n,o,e),c=r(n,o,t);return a*i<-1e-9&&s*c<-1e-9}var lr="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Fs="ABCDEFGHJKLMNPQRSTUVWXYZ",Ns="abcdefghijklmnopqrstuvwxyz";function dr(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let a=o%n;r=t[a]+r,o=Math.floor(o/n)}return r}function Ds(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?Fs:lr;return dr(o,r)}function ct(e,t=!1){let n=t?Ns:lr;return dr(Math.max(0,Math.floor(e)-1),n)}var Gs=[[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 ur(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Gs)for(;t>=o;)n+=r,t-=o;return n}function fr(e,t){let n=e.length;return e.map((o,r)=>{let a=t.reverse?n-1-r:r;return{...o,label:Ds(a,t)}})}function $s(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 lt(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",i=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,c=e.seatCount;if(a==="updown"||a==="updown-descending"){let h=Math.ceil(c/2),b=a==="updown"?t<h?n+2*t:n-1+2*(c-t):t<h?n+2*(h-1-t):n+1+2*(t-h);return`${i}${b}`}let l=a==="odd"||a==="even"?2:r,d=s!=null&&Number.isFinite(s)?s-(c-1)*l:n,f=o==="center"?$s(c)[t]:o==="rtl"?c-1-t:t,g;switch(a){case"odd":{let h=d%2===1?d:d+1;g=String(h+f*2);break}case"even":{let h=d%2===0?d:d+1;g=String(h+f*2);break}case"roman":g=ur(d+f*r);break;case"letters-upper":g=ct(d+f*r,!1);break;case"letters-lower":g=ct(d+f*r,!0);break;default:g=String(d+f*r);break}return`${i}${g}`}function Bs(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function ge(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${lt(e,t)}`}function Ks(e,t,n,o){if(o?.displayLabel)return null;if(e.seatDisplayLabelMode==="number"||!n)return{row:e.displayLabel||e.label,seat:lt(e,t)};let r=Bs(n);return{row:n.displayLabel,seat:lt(r,n.displayOffset+t)}}function dt(e,t,n,o){let r=Ks(e,t,n,o);return r?e.seatDisplayLabelMode==="number"?r.seat:`${r.row}-${r.seat}`:o.displayLabel}var hr=999,zs=["clockwise","anticlockwise"],Us=["table-number","number","letter"];function Ut(e,t){return`${e.label}-${t+1}`}function Hs(e,t,n){return e?.direction==="anticlockwise"?Math.max(0,t-1-n):n}function Vs(e,t){let n=e.chairNumbering,o=n?.start??1,r=Hs(n,Math.max(0,Math.round(e.seatCount)),t);return n?.format==="letter"?ct(Math.max(1,o)+r):String(o+r)}function Ht(e,t){let n=Vs(e,t);return(e.chairNumbering?.format??"table-number")==="table-number"?`${e.displayLabel??e.label}-${n}`:n}function gr(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))return"chairNumbering must be an object";let t=e,n=Object.keys(t).filter(o=>!["start","direction","format"].includes(o));return n.length?`chairNumbering has unsupported field(s): ${n.join(", ")}`:t.start!==void 0&&(!Number.isInteger(t.start)||t.start<0||t.start>hr)?`chairNumbering.start must be a whole number from 0 to ${hr}`:t.direction!==void 0&&!zs.includes(t.direction)?"chairNumbering.direction must be clockwise or anticlockwise":t.format!==void 0&&!Us.includes(t.format)?"chairNumbering.format must be table-number, number or letter":null}function br(e){let t={};return e.start!==void 0&&e.start!==1&&(t.start=e.start),e.direction==="anticlockwise"&&(t.direction="anticlockwise"),e.format&&e.format!=="table-number"&&(t.format=e.format),Object.keys(t).length?t:void 0}var Vt=.02291666666666667,Gn=1/Vt,Xs=58,rh=Xs*Vt;var mr=[{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."},{key:"pitch-rugby",label:"Rugby pitch",blurb:"100 \xD7 70 m field of play with in-goal areas, 22 m and 10 m lines."},{key:"diamond-baseball",label:"Baseball field",blurb:"Diamond, infield, mound and foul lines out to 99 m poles."},{key:"court-basketball",label:"Basketball court",blurb:"28 \xD7 15 m court with keys and three-point lines."},{key:"court-tennis",label:"Tennis court",blurb:"23.77 \xD7 10.97 m doubles court with run-off and net."},{key:"ring-boxing",label:"Boxing ring",blurb:"Raised ring, 6.1 m inside the ropes, coloured corners."}];var qs={round:{width:6,height:6},"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},Ys={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};function pr(e){let t=qs[e];return t?{width:t.width*Gn,height:t.height*Gn}:{width:300,height:70}}var Js="#232c40",Ws=Math.PI*2;function Zs(e,t,n,o,r,a){return{x:r+e*n-t*o,y:a+e*o+t*n}}function $n(e){let{kind:t,cx:n,cy:o,width:r,height:a}=e,i=(e.rotation??0)*Math.PI/180,s=Math.cos(i),c=Math.sin(i),l=r/2,d=a/2,f=[],g=(h,b)=>{f.push({x:h,y:b})};switch(t){case"rect":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"rounded":{let h=Math.min(r,a)*.18,b=5,p=(x,I,y)=>{for(let w=0;w<=b;w++){let S=y+w/b*(Math.PI/2);g(x+h*Math.cos(S),I+h*Math.sin(S))}};p(l-h,-d+h,-Math.PI/2),p(l-h,d-h,0),p(-l+h,d-h,Math.PI/2),p(-l+h,-d+h,Math.PI);break}case"arc":{let h=a*.45;g(-l,-d),g(l,-d);let b=24;for(let p=0;p<=b;p++){let x=p/b,I=l-x*r,y=d+h*(1-Math.pow(2*I/r,2));g(I,y)}break}case"thrust":{let h=r*.18,b=a*1.1;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"runway":{let h=r*.1,b=a*3;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"round":case"oval-cricket":{for(let b=0;b<40;b++){let p=b/40*Ws;g(l*Math.cos(p),d*Math.sin(p))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"diamond-baseball":{for(let h of tc(l,d))g(h.x,h.y);break}case"rink-hockey":{for(let h of Qs(l,d,l*(8.5/60),d*(8.5/30)))g(h.x,h.y);break}case"track-athletics":{for(let h of ec(l,d))g(h.x,h.y);break}}return f.map(h=>Zs(h.x,h.y,s,c,n,o))}function yr(e,t="stage"){return{type:"shape",id:t,kind:"polygon",points:$n(e),fill:e.fill??Ys[e.kind]??Js,label:e.label??"STAGE",role:"stage",stageKind:e.kind}}function Qs(e,t,n,o){let r=[],i=(s,c,l)=>{for(let d=0;d<=8;d++){let f=l+d/8*(Math.PI/2);r.push({x:s+n*Math.cos(f),y:c+o*Math.sin(f)})}};return i(e-n,-t+o,-Math.PI/2),i(e-n,t-o,0),i(-e+n,t-o,Math.PI/2),i(-e+n,-t+o,Math.PI),r}function ec(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let a=0;a<=r;a++){let i=-Math.PI/2+a/r*Math.PI;o.push({x:n+t*Math.cos(i),y:t*Math.sin(i)})}for(let a=0;a<=r;a++){let i=Math.PI/2+a/r*Math.PI;o.push({x:-n+t*Math.cos(i),y:t*Math.sin(i)})}return o}var ut=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=r+70,i=[],s=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let l=0;l<=24;l++){let d=s+(c-s)*l/24;i.push({x:a*Math.cos(d),y:r+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:i}})();function tc(e,t){let n=e/ut.half,o=t/ut.half;return[{x:-ut.backstop*n,y:t},{x:ut.backstop*n,y:t},...ut.fence.map(r=>({x:r.x*n,y:r.y*o}))]}function wr(e){switch(e){case"pitch-football":return"PITCH";case"rink-hockey":return"RINK";case"track-athletics":return"TRACK";case"oval-cricket":return"OVAL";case"pitch-rugby":return"PITCH";case"diamond-baseball":return"FIELD";case"court-basketball":case"court-tennis":return"COURT";case"ring-boxing":return"RING";default:return"STAGE"}}var nc=2e6,oc=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,rc=/[\s"'<>`\\]/;function xr(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return oc.test(e);if(rc.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ye(e){let t=e.trim();return xr(t)?t:null}function ft(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var qt=Math.PI/180,ic=9,we=16;function Kn(e,t,n,o){let r=n*qt,a=Math.cos(r),i=Math.sin(r);return{x:o.x+e*a-t*i,y:o.y+e*i+t*a}}function Q(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:a}=e,i=[];if(e.path)return Gt(e.path,t);if(t<=1)return t===1&&i.push({x:a.x,y:a.y}),i;if(o===0){for(let l=0;l<t;l++)i.push(Kn(l*n,0,r,a));return i}let s=o/(t-1)*qt,c=n/(2*Math.sin(Math.abs(s)/2));for(let l=0;l<t;l++){let d=l*s,f=c*Math.sin(d),g=-c+c*Math.cos(d);i.push(Kn(f,g,r,a))}return i}function zn(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function ac(e,t){let n=zn(e);return Q(e).map((o,r)=>{let a=n.get(r),i=ft(a),s=ge(e,r,a),c={...e.commercial,...a?.commercial};return{index:r,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:dt(e,r,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:i.length>0,accessibility:i,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 ie(e){let t=[];for(let n of ac(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 sc(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 r=Math.max(0,Math.round(e.seatCount));for(let a=0;a<r;a++)o[n[a%n.length]]+=1;return o}function cc(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])),r=(d,f,g,h)=>{let b=o.get(d),p=ft(b),x=b?.label??Ut(e,d);return{index:d,label:x,displayLabel:b?.displayLabel??Ht(e,d),x:f+(b?.dx??0),y:g+(b?.dy??0),categoryKey:b?.categoryKey??e.categoryKey,skipped:!!b?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:b?.wheelchairSpaceType,commercial:b?.commercial,glyph:b?.glyph,viewUrl:b?.viewFromSeatUrl,viewMeta:b?.viewFromSeatUrl?b.viewFromSeatMeta:void 0,labelStyle:b?.labelStyle,...h?{side:h}:{}}};if(e.shape==="round"){let d=(e.radius??40)+we,f=e.rotation*qt,g=Math.max(0,Math.min(360,e.seatArc??360));if(g>=360||n===1){for(let x=0;x<n;x++){let I=f+x/n*2*Math.PI;t.push(r(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let h=g*qt,b=(2*Math.PI-h)/2,p=f+b;for(let x=0;x<n;x++){let I=p+x/(n-1)*h;t.push(r(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,i=e.height??50,s=sc(e),c=["top","bottom","left","right"],l=0;for(let d of c){let f=s[d];for(let g=0;g<f;g++){let h,b;d==="top"?(h=-a/2+(g+.5)*a/f,b=-i/2-we):d==="bottom"?(h=-a/2+(g+.5)*a/f,b=i/2+we):d==="left"?(h=-a/2-we,b=-i/2+(g+.5)*i/f):(h=a/2+we,b=-i/2+(g+.5)*i/f);let p=Kn(h,b,e.rotation,e.center);t.push(r(l++,p.x,p.y,d))}}return t}function be(e){return cc(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 Ir(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",...e.commercial?.note?{commercial:{note:e.commercial.note}}:{}}]}function zt(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let a=t[o].x,i=t[o].y,s=t[r].x,c=t[r].y;i>e.y!=c>e.y&&e.x<(s-a)*(e.y-i)/(c-i)+a&&(n=!n)}return n}function Dn(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],a=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(a)>1e-7)return!1;let i=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),s=(r.x-n.x)**2+(r.y-n.y)**2;return i>=-1e-7&&i<=s+1e-7})}function ee(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function H(e,t,n){return zt(e,t)&&!ee(n).some(o=>zt(e,o)||Dn(e,o))}function Bn(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 V(e){switch(e.type){case"row":{let t=Q(e),n=zn(e),o=0,r=0,a=0;for(let i=0;i<t.length;i++){let s=n.get(i);s?.skip||(o+=t[i].x+(s?.dx??0),r+=t[i].y+(s?.dy??0),a++)}return a?{x:o/a,y:r/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 Bn(e.points);case"section":return Bn(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Bn(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 Sr(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function lc(e,t){if(e.type!=="gaArea"||!Sr(e.points,t.outline))return!1;let n=ee(e.holes),o=ee(t.holes);return n.length===o.length&&n.every((r,a)=>Sr(r,o[a]))}function Yt(e,t,n=e.filter(r=>r.type==="section"),o=V(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(i=>(i.logicalSectionId??i.id)===r&&(lc(t,i)||H(o,i.outline,i.holes))):void 0)??n.find(i=>H(o,i.outline,i.holes))??(t.type==="row"&&dc(t)?uc(t,n):void 0)}function dc(e){return(e.overrides??[]).some(t=>t.skip===!0)}function uc(e,t){let n=Q(e),o=zn(e),r,a=0;for(let i of t){let s=0;for(let c=0;c<n.length;c++){let l=o.get(c);if(l?.skip)continue;let d={x:n[c].x+(l?.dx??0),y:n[c].y+(l?.dy??0)};H(d,i.outline,i.holes)&&s++}s>a&&(r=i,a=s)}return r}function T(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 te(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var Xt=40;function ue(e,t){let n=t?.freeText==="exclude",o=1/0,r=1/0,a=-1/0,i=-1/0,s=(l,d)=>{l<o&&(o=l),d<r&&(r=d),l>a&&(a=l),d>i&&(i=d)},c=l=>{if(Array.isArray(l))for(let d of l)!d||typeof d!="object"||s(d.x,d.y)};for(let l of te(e))if(l.type==="row"){let d=new Map((l.overrides??[]).map(f=>[f.index,f]));Q(l).forEach((f,g)=>{let h=d.get(g);h?.skip||s(f.x+(h?.dx??0),f.y+(h?.dy??0))})}else if(l.type==="gaArea")c(l.points);else if(l.type==="section")c(l.outline);else if(l.type==="decorImage")s(l.x,l.y),s(l.x+l.width,l.y+l.height);else if(l.type==="shape")l.points&&l.points.length?c(st(l)):l.x!=null&&l.y!=null&&l.width!=null&&l.height!=null&&(s(l.x,l.y),s(l.x+l.width,l.y+l.height));else if(l.type==="table"){let d=we+ic,f=l.shape==="round"?(l.radius??40)+d:Math.max((l.width??80)/2,(l.height??50)/2)+d;s(l.center.x-f,l.center.y-f),s(l.center.x+f,l.center.y+f)}else if(l.type==="booth"){let d=Math.max(l.width,l.height)/2;s(l.center.x-d,l.center.y-d),s(l.center.x+d,l.center.y+d)}else if(l.type==="text"){if(n)continue;let d=Zo(l);s(l.position.x,l.position.y),s(l.position.x+d.width,l.position.y+d.height)}for(let l of[e.referenceImage,e.backgroundImage]){if(!l)continue;let{center:d,width:f}=l;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(f))continue;let g=f*3/4;s(d.x-f/2,d.y-g/2),s(d.x+f/2,d.y+g/2)}if(!isFinite(o)){let l=e.focalPoint??{x:0,y:0};return{x:l.x-200,y:l.y-200,width:400,height:400}}return{x:o-Xt,y:r-Xt,width:a-o+Xt*2,height:i-r+Xt*2}}function ht(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}function vr(e){return e.type!=="shape"&&e.type!=="text"||e.labelImportance==="detail"?!1:e.labelImportance==="orientation"||e.referenceAnnotationSource?.kind==="direct-landmark-v1"}var fc=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Ar(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function bt(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Un(e){let t=bt(e),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o),a={};for(let i of fc){let s=r?.[i];s!==void 0&&(a[i]=s)}n.push([ge(e,o,r),dt(e,o,void 0,r),r?.categoryKey??e.categoryKey,r?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function hc(e){return JSON.parse(JSON.stringify(e))}function Jt(e,t){let n=hc(e);return t(n)&&Un(n)===Un(e)?n:e}function gc(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=bt(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let r=t.get(o)?.labelStyle;if(!r)return!1;if(!n)n=r;else if(!Ar(n,r))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function bc(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Rr(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 i=bc(a.slice(n.length+1));if(i===void 0)return;o.push(i)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let r=o[1]-o[0];if(!(r!==1&&r!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==r)return;return r===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function mc(e){if(e.seatCount<1)return!1;let t=bt(e);if(!(e.overrides??[]).some(r=>r.label!==void 0))return!1;let n=[];for(let r=0;r<e.seatCount;r+=1)n.push(ge(e,r,t.get(r)));let o=Rr(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 r of e.overrides??[])delete r.label;return!0}function pc(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=bt(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==lt(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Zt(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Ar(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===ge(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===dt(e,t.index)&&delete t.displayLabel}function Mr(e){return Object.keys(e).every(t=>t==="index")}function yc(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Zt(e,n);let t=e.overrides.filter(n=>!Mr(n));return t.length?e.overrides=t:delete e.overrides,!0}function wc(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=bt(t);for(let r=0;r<t.seatCount;r+=1)if(o.get(r)?.displayLabel===void 0)return!1;return!0}function _r(e){if(e.type!=="row")return e;let t=Jt(e,gc);return t=Jt(t,mc),t=Jt(t,pc),t=Jt(t,yc),wc(e,t)?t:e}function kr(e){if(!e.overrides?.length)return e;let t=[];for(let o of e.overrides){let r={...o};r.label===Ut(e,r.index)&&delete r.label,r.displayLabel===Ht(e,r.index)&&delete r.displayLabel,r.categoryKey===e.categoryKey&&delete r.categoryKey,r.dx===0&&delete r.dx,r.dy===0&&delete r.dy,Mr(r)||t.push(r)}let n={...e};return t.length?n.overrides=t:delete n.overrides,n}function Cr(e){return e.type==="row"?_r(e):e.type==="table"?kr(e):e}function xc(e){let t=e.objects.map(Cr),n=e.floors?.map(o=>({...o,objects:o.objects.map(Cr)}));return{...e,objects:t,...n?{floors:n}:{}}}var Or=2,Sc=3,Pr=6;function gt(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 Wt(e){return{...e,x:gt(e.x,Or),y:gt(e.y,Or)}}function Ic(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Wt(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Wt)),Array.isArray(t.points)&&(t.points=t.points.map(Wt)),typeof t.rotation=="number"&&(t.rotation=gt(t.rotation,Pr)),typeof t.seatSpacing=="number"&&(t.seatSpacing=gt(t.seatSpacing,Pr));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Wt(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let r={...o};for(let a of["dx","dy"]){let i=r[a];if(typeof i!="number")continue;let s=gt(i,Sc);s===0?delete r[a]:r[a]=s}return r})),t}function Lr(e){let t=e.backgroundImage;return t?.url&&!t.assetId?t:void 0}var vc=36,Cc=160;function Er(e,t=360){let n=ot(Math.round(Number.isFinite(e)?e:1),1,40),o=ot(Number.isFinite(t)?t:360,120,360);return Math.round(ot(n*4*(360/o),vc,Cc))}var Tr=["horizontal","vertical","auto"];var mt=[{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"}],Oh=new Map(mt.map(e=>[e.key,e]));var Oc=[{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"}],Ph=new Map(Oc.map(e=>[e.key,e]));var Fe=8,Hn=24,jr=["start","end","both","none"],Fr=["inline","corner","peninsula","island"],Pc=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Ah=new Set(Pc);var u=class extends Error{constructor(n,o,r={}){super(o);this.code=n;this.details=r;this.name="ChartOperationError"}};function O(e,t){let n=T(e),o=t?n.find(r=>r.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 D(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 E(e,t,n,o){let r=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(i=>i.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let i=n(t);if(i&&!r.has(i))return o.add(i),i}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Ac(e){let t=e.slice().sort((a,i)=>a.x-i.x||a.y-i.y);if(t.length<3)return t;let n=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.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 r=[];for(let a=t.length-1;a>=0;a--){let i=t[a];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}return o.pop(),r.pop(),o.concat(r)}function Rc(e,t){if(!e.length)return e;let n={x:e.reduce((o,r)=>o+r.x,0)/e.length,y:e.reduce((o,r)=>o+r.y,0)/e.length};return e.map(o=>{let r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a)||1;return{x:o.x+r/i*t,y:o.y+a/i*t}})}function Oe(e){let t=[];for(let o of e)o.type==="row"?t.push(...ie(o).map(r=>({x:r.x,y:r.y}))):o.type==="table"?t.push(...be(o).map(r=>({x:r.x,y:r.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Rc(Ac(t),22);return n.length>=3?n:null}function me(e,t){let n=O(e,t),o=T(e).find(r=>r.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Nr=24,Dr=80;function Vn(e,t){let n=e.normalize("NFKC").trim();if(n.length>Nr)throw new u("invalid_operation",`${t} displayed type must be at most ${Nr} characters`);return n}function Qt(e,t){if(e.displayType===void 0)return!1;let n=Vn(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function Ne(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Dr)throw new u("invalid_operation",`${t} displayed label must be at most ${Dr} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function N(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 Gr(e,t){if(!Number.isFinite(e)||e<Fe||e>Hn)throw new u("invalid_operation",`${t} label size must be from ${Fe} to ${Hn}`)}function xe(e,t){e.size!==void 0&&e.size!==null&&Gr(e.size,t),e.color!==void 0&&e.color!==null&&N(e.color,`${t} label color`)}function en(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&&Gr(n.size,t),n.color!==void 0&&N(n.color,`${t} label color`))}function De(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=N(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 Xn(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(r=>r.id!==n&&r.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 ce(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var pe=Math.PI/180,fe=Math.PI/180;function Pe(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 Mc=0,tn=120,qn=4;function _c(e){if(!Number.isFinite(e)||e<Mc||e>tn)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function kc(e,t){let n=T(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(tn,(e.floors.length-1)*qn),i=Math.min(tn,a+qn),s=E(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:i,objects:[],focalPoint:{...e.focalPoint}}),Ae(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:i}}function Lc(e,t){let n=T(e),o=n.find(i=>i.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let r=t.name.normalize("NFKC").trim();if(!r||r.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(i=>i.id!==o.id&&i.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${r}`);let a=o.name!==r;return a&&(o.name=r),{changed:a,floorId:o.id,floorName:r}}function Ec(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(r=>r.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});_c(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 Tc(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(r=>r.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[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else Ae(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:T(e).length}}function jc(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:E(e,"zone",t.idFactory,new Set),label:Xn(e,t.label),color:N(t.color,"Zone color"),...t.focalPoint?{focalPoint:pt(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function Fc(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])),r=n.filter(c=>!o.has(c));if(r.length)throw new u("object_not_found",`Unknown zone id(s): ${r.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:r});let a=structuredClone(e),i=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=i.get(c.zoneId);c.patch.label!==void 0&&(d.label=Xn(a,c.patch.label,d.id)),c.patch.color!==void 0&&(d.color=N(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(i.get(c)))}}function Nc(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=T(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 r=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:r,zoneCount:e.zones?.length??0}}var yt=[{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 nn(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])),r=(a,i=1)=>{a&&i>0&&t.set(a,(t.get(a)??0)+i)};r(e.categoryKey,n-o.size);for(let a of o.values())a.skip||r(a.categoryKey??e.categoryKey);return t}var Yn="__sl_ga__";function Re(e){return e.startsWith(Yn)}var Dc=Yn,ne=1e5;function Gc(e,t){return`${Dc}${encodeURIComponent(e)}__${t+1}`}function Jn(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 r of t){if(!r||typeof r.sourceAreaId!="string"||!r.sourceAreaId.trim()||r.sourceAreaId.length>160||!Number.isInteger(r.startIndex)||r.startIndex<0||!Number.isInteger(r.count)||r.count<1||r.startIndex+r.count>ne||(n+=r.count,n>ne))return!1;let a=o.get(r.sourceAreaId)??[],i=r.startIndex+r.count;if(a.some(s=>r.startIndex<s.end&&i>s.start))return!1;a.push({start:r.startIndex,end:i}),o.set(r.sourceAreaId,a)}return n===e.capacity}function on(e){let t=Math.min(ne,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Jn(e)?e.inventorySegments.map(n=>({...n})):[]}var rn=100,$r=`An area sold to one party holds at most ${rn} guests.`;function Ge(e){return e.variableOccupancy?"variable":e.bookAsWhole?"whole":null}function le(e){return $c(e,2)}function $c(e,t){return t===2&&Ge(e)&&e.inventorySegments===void 0?e.label.trim()?[e.label]:[]:on(e).flatMap(n=>Array.from({length:n.count},(o,r)=>Gc(n.sourceAreaId,n.startIndex+r)))}function Wn(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=on(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),i=n[n.length-1];if(i?.sourceAreaId===e.id&&i.startIndex+i.count===a)i.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var Bc="__ungrouped__";function Kc(e){return e.type==="row"?ie(e).map(t=>t.label):e.type==="table"?be(e).map(t=>t.label):e.type==="booth"?Ir(e).map(t=>t.label):e.type==="gaArea"?le(e):[]}function zc(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Uc(e){return e.displayLabel||e.label||"Section"}function Hc(e){let t=new Map;for(let n of te(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:Uc(n),zone:n.zone})}return t}function Vc(e,t){let n=te(e),o=n.filter(s=>s.type==="section"),r=new Map;for(let[s,c]of Hc(e))r.set(s,{id:s,label:c.label,zone:c.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:Bc,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},i=new Map;for(let s of n){if(!zc(s))continue;let c=Kc(s);if(c.length===0)continue;let l;if(t)l=t.get(s.id);else{let f=Yt(n,s,o);l=f?f.logicalSectionId??f.id:void 0}let d=l?r.get(l):a;d.seatCount+=c.length,d.objectIds.push(s.id),d.seatLabels.push(...c),i.set(s.id,d.id)}return{sections:[...r.values()],ungrouped:a.objectIds.length?a:null,objectToSection:i}}function wt(e){return Vc(e,null)}var Me={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 xt(e,t,n,o,r,a,i=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*r/2,y:n},rotation:0,curve:i,seatCount:o,seatSpacing:r,categoryKey:a}}function Xc(e,t,n,o,r,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:r,categoryKey:a}}function Br(e,t,n,o,r,a){let i=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-i,y:-s},{x:i,y:-s},{x:i,y:s},{x:-i,y:s}],capacity:r,categoryKey:a}}function qc(e,t,n,o,r){let a=n*2,i=[];for(let s=0;s<a;s++){let c=s%2===0,l=c?["wheelchair"]:["companion"];i.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:r,overrides:i}}var Kr=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[Me.balcony],sectionLabel:"Balcony",build:()=>[xt("blk-b0","A",-45,18,24,"balcony",18),xt("blk-b1","B",-15,20,24,"balcony",18),xt("blk-b2","C",15,22,24,"balcony",18),xt("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[Me.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>xt(`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:[Me.standard],build:()=>[Br("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[Me.premium],build:()=>Array.from({length:6},(e,t)=>Xc(`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:[Me.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:[Me.standard],build:()=>[Br("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:[Me.standard],build:()=>[qc("blk-wc","A",4,40,"standard")]}];function B(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 an(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 Se=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"],zr="#a4508b";var Yc=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Jc(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Be(e){let t=Yc.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Qn(e,t){let n=a=>{let i=Be(a);if(!i)return null;let s=y=>{let w=y/255;return w<=.04045?w/12.92:((w+.055)/1.055)**2.4},c=s(i[0]),l=s(i[1]),d=s(i[2]),f=(.4124*c+.3576*l+.1805*d)/.95047,g=.2126*c+.7152*l+.0722*d,h=(.0193*c+.1192*l+.9505*d)/1.08883,b=y=>y>.008856?Math.cbrt(y):7.787*y+16/116,p=b(f),x=b(g),I=b(h);return[116*x-16,500*(p-x),200*(x-I)]},o=n(e),r=n(t);return o&&r?Math.hypot(o[0]-r[0],o[1]-r[1],o[2]-r[2]):null}function $e(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Ur(e){let{r:t,g:n,b:o}=Jc(e);return .2126*$e(t)+.7152*$e(n)+.0722*$e(o)}function Zn(e){return .2126*$e(e[0])+.7152*$e(e[1])+.0722*$e(e[2])}function sn(e,t){let n=Ur(e),o=Ur(t);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}function St(e,t){let n=Be(e),o=Be(t);if(!n||!o)return null;let r=Zn(n),a=Zn(o);return(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function Hr(e,t,n){return sn(t,e)>=sn(n,e)?t:n}var Vr=.85,Wc=12;function Xr(e,t){return e*t>=Wc}var Zc={wheelchair:"M7.8 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM8 7L10.5 7L10.5 15L8 15ZM8 12.5L18 12.5L18 15L8 15ZM16 15L18 15L18 18L16 18ZM5.5 16a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0 -11 0zM8 16a3 3 0 1 1 6 0a3 3 0 1 1 -6 0z",companion:"M5.5 6.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM4.5 18.5L6 11.5L11 11.5L12.5 18.5ZM12.5 7.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM11.5 19L13 12.5L18 12.5L19.5 19Z","semi-ambulatory":"M8.3 3.8a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM9 6.2L12 6.6L11 13.5L8.6 13L9 6.2ZM8.6 13L11 13L9.5 21L7 21ZM10.4 13L12.6 13L13.6 21L11.2 21ZM11.2 7.2L14 8L14.6 9.6L11.9 8.9ZM14.4 6.8L15.9 6.8L16.4 21L14.8 21Z","designated-aisle":"M3 5L6 5L6 14L3 14ZM3 12L13 12L13 15L3 15ZM5 15L7 15L7 20L5 20ZM11 15L13 15L13 20L11 20ZM13 7L20 7L17 4L19 4L23 8.5L19 13L17 13L20 10L13 10Z","step-free":"M4 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM4.4 7L7.5 7L7.5 13L11 15L9.5 17L5 14L4.4 7ZM2 19L8 19L17 10L22 10L22 13L18 13L10 21L2 21Z",hearing:"M15.5 3.5C9 2.2 5.5 6 5.5 11.5C5.5 16 8 19.5 10.5 21C13.2 22.6 16.4 20.8 15.4 18C14.8 16.4 12.9 16.1 13 14C13.1 11.9 15.8 11.4 15.8 8.5C15.8 5.4 13 4 15.5 3.5Z",cart:"M5.5 6L18.5 6a2.5 2.5 0 0 1 2.5 2.5L21 15.5a2.5 2.5 0 0 1 -2.5 2.5L11 18L7 20.5L7.5 18L5.5 18a2.5 2.5 0 0 1 -2.5 -2.5L3 8.5a2.5 2.5 0 0 1 2.5 -2.5zM6.5 11L17.5 11L17.5 12.6L6.5 12.6zM6.5 14L17.5 14L17.5 15.6L6.5 15.6z","sign-language":"M7 11L17 11L17 18a2 2 0 0 1 -2 2L9 20a2 2 0 0 1 -2 -2zM7.6 5L9.4 5L9.4 12L7.6 12zM9.9 3.5L11.7 3.5L11.7 12L9.9 12zM12.3 3.5L14.1 3.5L14.1 12L12.3 12zM14.6 5L16.4 5L16.4 12L14.6 12zM7.2 12.5L5 10.2L6.4 8.9L8.6 11.2Z","low-vision":"M2.5 12C6 6 18 6 21.5 12C18 18 6 18 2.5 12ZM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM17.5 3L19 3L19 6L17.5 6ZM19 4L22 4L22 5.5L19 5.5Z","sensory-friendly":"M4 11C4 5 7 2.5 12 2.5S20 5 20 11L17 11C17 7 15.5 5.5 12 5.5S7 7 7 11ZM3 10L8 10L8 19L5 19a2 2 0 0 1 -2 -2ZM16 10L21 10L21 17a2 2 0 0 1 -2 2L16 19ZM9 12L15 12L15 14L9 14ZM10 16L14 16L14 18L10 18Z","plus-size":"M9.4 4.3a2.6 2.6 0 1 0 5.2 0a2.6 2.6 0 1 0 -5.2 0zM5 20L4 13C4 10.5 7 9.5 12 9.5C17 9.5 20 10.5 20 13L19 20Z","lift-armrest":"M5 6L8 6L8 19L5 19zM5 16L18 16L18 19L5 19zM8 12L17 12L17 14.5L8 14.5zM14 7L16 7L16 12L14 12zM12 7L18 7L15 3Z"},ng=Zc.wheelchair;function qr(e,t,n){let o=Be(e),r=Be(t);if(!o||!r)return t;let a=Math.max(0,Math.min(1,n));return`#${o.map((s,c)=>Math.round(s*a+r[c]*(1-a))).map(s=>s.toString(16).padStart(2,"0")).join("")}`}var eo={facilities:zr,"food-drink":Se[5],navigation:Se[2],accessibility:Se[4]};var ig={minDiameterPx:12,glyphScale:.66,ringRatio:1/14,largeFromPx:24};var G=e=>{let t=Math.round(e*100)/100;return Object.is(t,-0)?"0":String(t)},He=e=>`${G(e[0])} ${G(e[1])}`,Ue=(e,t,n,o)=>[e+n*Math.cos(o*Math.PI/180),t+n*Math.sin(o*Math.PI/180)];function si(e){let t=`M${He(e.from)}`;for(let n of e.segs)t+=n.arc?`A${G(n.arc.r)} ${G(n.arc.r)} 0 ${n.arc.large} ${n.arc.sweep} ${He(n.to)}`:`L${He(n.to)}`;return`${t}Z`}function K(e){let t=[e.from,...e.segs.map(o=>o.to)],n=[];for(let o=e.segs.length-1;o>=0;o--){let r=e.segs[o].arc;n.push({to:t[o],arc:r&&{...r,sweep:r.sweep?0:1}})}return{from:t[t.length-1],segs:n}}function z(e,t,n){let o={r:n,large:0,sweep:1};return{from:[e-n,t],segs:[{to:[e+n,t],arc:o},{to:[e-n,t],arc:o}]}}function _(e,t,n,o,r){let a=Math.min(r,n/2,o/2),i={r:a,large:0,sweep:1};return a<=0?q([[e,t],[e+n,t],[e+n,t+o],[e,t+o]]):{from:[e+a,t],segs:[{to:[e+n-a,t]},{to:[e+n,t+a],arc:i},{to:[e+n,t+o-a]},{to:[e+n-a,t+o],arc:i},{to:[e+a,t+o]},{to:[e,t+o-a],arc:i},{to:[e,t+a]},{to:[e+a,t],arc:i}]}}function q(e){let t=0;for(let o=0;o<e.length;o++){let[r,a]=e[o],[i,s]=e[(o+1)%e.length];t+=r*s-i*a}let n=t>0?e:[...e].reverse();return{from:n[0],segs:[...n.slice(1).map(o=>({to:o})),{to:n[0]}]}}function F(e,t,n){let o=n/2,r=t[0]-e[0],a=t[1]-e[1],i=Math.hypot(r,a);if(i<1e-6)return z(e[0],e[1],o);let s=[a/i*o,-r/i*o],c={r:o,large:0,sweep:1},l=[e[0]+s[0],e[1]+s[1]];return{from:l,segs:[{to:[t[0]+s[0],t[1]+s[1]]},{to:[t[0]-s[0],t[1]-s[1]],arc:c},{to:[e[0]-s[0],e[1]-s[1]]},{to:l,arc:c}]}}function X(e,t,n=!1){let o=[],r=n?e.length:e.length-1;for(let a=0;a<r;a++)o.push(F(e[a],e[(a+1)%e.length],t));return o}function de(e,t,n,o,r,a){let i=a/2,s=r-o>180?1:0,c={r:i,large:0,sweep:1},l=Ue(e,t,n+i,o);return{from:l,segs:[{to:Ue(e,t,n+i,r),arc:{r:n+i,large:s,sweep:1}},{to:Ue(e,t,n-i,r),arc:c},{to:Ue(e,t,n-i,o),arc:{r:n-i,large:s,sweep:0}},{to:l,arc:c}]}}var k=(...e)=>e.flat().map(si).join(" "),ae=(e,t,n)=>`M${G(e-n)} ${G(t)}a${G(n)} ${G(n)} 0 1 0 ${G(2*n)} 0a${G(n)} ${G(n)} 0 1 0 ${G(-2*n)} 0`,he=(e,t,n,o,r)=>si(_(e,t,n,o,r)),ln=e=>`M${e.map(He).join("L")}`,cn=(e,t,n,o,r)=>`M${He(Ue(e,t,n,o))}A${G(n)} ${G(n)} 0 ${r-o>180?1:0} 1 ${He(Ue(e,t,n,r))}`;function Ke(e,t,n,o=1){let r=a=>[a[0]*o+t,a[1]*o+n];return{head:[e.head[0]*o+t,e.head[1]*o+n,e.head[2]*o],limbs:e.limbs.map(a=>a.map(r)),arcs:e.arcs?.map(([a,i,s,c,l])=>[a*o+t,i*o+n,s*o,c,l])}}function It(e){return[ae(e.head[0],e.head[1],e.head[2]),...e.limbs.map(ln),...(e.arcs??[]).map(([t,n,o,r,a])=>cn(t,n,o,r,a))].join(" ")}function ze(e,t=2.6){return[z(e.head[0],e.head[1],e.head[2]+1),...e.limbs.flatMap(n=>X(n,t)),...(e.arcs??[]).map(([n,o,r,a,i])=>de(n,o,r,a,i,t-.2))]}var _e={head:[10,4,2],limbs:[[[10,8.2],[10,14],[15.5,14],[18,19.5],[20.5,19.5]],[[10,10.6],[14.5,10.6]]],arcs:[[9.5,16,5.5,35,235]]},Yr={head:[10.6,3.9,1.9],limbs:[[[9.6,7.8],[7.6,12]],[[5.4,8.2],[9.4,8.4],[12.8,10]],[[4,15.6],[7.6,12],[11,13.6],[10.6,16.4]]]},Jr={cx:12,hr:1.9,arm:5,leg:3,r:2},Wr={cx:12,hr:1.9,sh:2.2,hem:6,leg:3},Zr={cx:6.2,hr:1.8,arm:3.6,leg:2.2,r:1.4},Qr={cx:17.8,hr:1.8,sh:1.4,hem:4.1,leg:2.2};function ei({cx:e,hr:t,arm:n,leg:o,r}){return[ae(e,2+t,t),`M${G(e-n+r)} 8.5H${G(e+n-r)}a${r} ${r} 0 0 1 ${r} ${r}V15H${G(e+o)}V22H${G(e-o)}V15H${G(e-n)}V${G(8.5+r)}a${r} ${r} 0 0 1 ${r} ${-r}Z`,`M${G(e)} 15V22`].join(" ")}function ti({cx:e,hr:t,arm:n,leg:o,r}){return[z(e,2+t,t+1),_(e-n-.5,7.8,2*n+1,7.7,r+.5),_(e-o-.5,13,o,9.5,1),_(e+.5,13,o,9.5,1)]}function ni({cx:e,hr:t,sh:n,hem:o,leg:r}){return[ae(e,2+t,t),ln([[e-n,8.5],[e+n,8.5],[e+o,16],[e+r,16],[e+r,22],[e-r,22],[e-r,16],[e-o,16]])+"Z",`M${G(e)} 16V22`].join(" ")}function oi({cx:e,hr:t,sh:n,hem:o,leg:r}){return[z(e,2+t,t+1),q([[e-n-.6,7.8],[e+n+.6,7.8],[e+o+.9,16.8],[e-o-.9,16.8]]),_(e-r-.1,15,r-.4,7.5,.9),_(e+.5,15,r-.4,7.5,.9)]}var Qc=[[14.6,1.5],[5.2,13.6],[11,13.6],[9.4,22.5],[18.8,10.4],[13,10.4]],el="M8.5 3.5 4 5.5l-1.5 5 3 1 1-2v11h11v-11l1 2 3-1-1.5-5-4.5-2c-.5 1.5-1.8 2.5-3.5 2.5s-3-1-3.5-2.5Z",tl="M12 2.5S5 9.5 5 14.5a7 7 0 0 0 14 0c0-5-7-12-7-12Z",nl="M2.5 21.5h19V3h-6v6.2H9.2v6.2H2.5Z",ri=[[9,3],[15,3],[15,9],[21,9],[21,15],[15,15],[15,21],[9,21],[9,15],[3,15],[3,9],[9,9]],ol={from:[3.8,5.2],segs:[{to:[20.2,5.2]},{to:[22,7],arc:{r:1.8,large:0,sweep:1}},{to:[22,9.7]},{to:[22,14.3],arc:{r:2.3,large:0,sweep:0}},{to:[22,17]},{to:[20.2,18.8],arc:{r:1.8,large:0,sweep:1}},{to:[3.8,18.8]},{to:[2,17],arc:{r:1.8,large:0,sweep:1}},{to:[2,14.3]},{to:[2,9.7],arc:{r:2.3,large:0,sweep:0}},{to:[2,7]},{to:[3.8,5.2],arc:{r:1.8,large:0,sweep:1}}]},rl={from:[12,1.6],segs:[{to:[20.4,4.9]},{to:[20.4,11.2]},{to:[12,22.4],arc:{r:13,large:0,sweep:1}},{to:[3.6,11.2],arc:{r:13,large:0,sweep:1}},{to:[3.6,4.9]},{to:[12,1.6]}]};function ii(e,t,n){return{from:[e-n,t],segs:[{to:[e+n,t],arc:{r:n,large:0,sweep:1}},{to:[e-n,t]}]}}var ai={head:[13.2,4.3,2.2],limbs:[[[12.6,8.6],[11.2,15],[17.8,18.4],[9.4,18.4]],[[12.4,9.8],[16,14.4]]]},il=[[6,10.5],[15,10.5],[16.5,7],[18.5,5.5],[20,6.5],[21.5,8.5],[19.5,10],[18,12],[18,19],[16.5,19],[15.5,14],[9.5,14],[8.5,19],[7,19],[6.5,13]],al=[[5.4,9.8],[14.6,9.8],[16.1,6.4],[18.4,4.6],[20.5,5.9],[22.4,8.6],[19.9,10.6],[18.8,12.3],[18.8,19.8],[15.8,19.8],[15,14.8],[10.1,14.8],[9.2,19.8],[6.2,19.8],[5.6,13.2]],to=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:ei(Jr),solid:k(ti(Jr))},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:ni(Wr),solid:k(oi(Wr))},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:[he(2.5,2.5,19,19,3.5),It(Ke(_e,4.6,4.3,.66))].join(" "),solid:k(ze(_e)),solidLarge:k(_(1.5,1.5,21,21,4.5),K(_(3.9,3.9,16.2,16.2,2.6)),ze(Ke(_e,4.9,4.7,.62),2.2))},{key:"first-aid",label:"First aid",group:"facilities",path:ln(ri)+"Z",solid:k(q(ri.map(([e,t])=>[e+(e-12)*.08,t+(t-12)*.08])))},{key:"coat-check",label:"Coat check",group:"facilities",path:"M10 6.5a2 2 0 1 1 2 2V10 M12 10 3.4 16.9a1.4 1.4 0 0 0 .9 2.6h15.4a1.4 1.4 0 0 0 .9-2.6Z",solid:k(de(12,6.2,2.2,180,450,2.3),F([12,8.4],[12,10.5],2.3),X([[12,10.2],[3.2,18.8],[20.8,18.8]],2.8,!0))},{key:"atm",label:"ATM / cash",group:"facilities",path:[he(2,6,20,12,2),ae(12,12,2.75),"M6 12h.01 M18 12h.01"].join(" "),solid:k(_(1.5,5.5,21,13,2.4),K(z(12,12,3.2)))},{key:"info",label:"Info point",group:"facilities",path:[ae(12,12,9.5),"M10.8 11H12v5.8 M12 7.6h.01"].join(" "),solid:k(z(12,4.9,2.4),_(10.3,9.2,3.4,12.3,1),_(8.2,9.2,4,3,1),_(8.2,18.5,7.6,3,1))},{key:"lost-found",label:"Lost & found",group:"facilities",path:[ae(10.5,10.5,7.5),"M16 16l5.5 5.5","M8.4 8.4a2.1 2.1 0 1 1 3 1.9c-.6.4-.9.8-.9 1.6 M10.5 14.6h.01"].join(" "),solid:k(de(12,7.6,4.2,180,405,3.4),X([[14.97,10.57],[12,13],[12,15]],3.4),z(12,20,2.1))},{key:"restrooms",label:"Toilets",group:"facilities",path:[ei(Zr),ni(Qr)].join(" "),solid:k(ti(Zr),oi(Qr))},{key:"charging",label:"Charging point",group:"facilities",path:[he(6,2,12,20,2.5),"M13.2 6.2 9.6 12h4.8l-3.6 5.8"].join(" "),solid:k(q(Qc))},{key:"smoking",label:"Smoking area",group:"facilities",path:[he(2,14.5,14.5,4,1),"M6.5 14.5v4","M15.5 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4 M19 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4"].join(" "),solid:k(_(1.5,14,4.2,5,1.2),_(6.8,14,10.4,5,1.2),X([[15.9,11.4],[17.3,8.9],[15.9,6.4],[17.1,3.9]],2.2),X([[19.6,11.4],[21,8.9],[19.6,6.4],[20.8,3.9]],2.2))},{key:"no-smoking",label:"No smoking",group:"facilities",path:[ae(12,12,9.5),"M5.3 5.3l13.4 13.4","M5.5 10.5h13v3h-13Z"].join(" "),solid:k(z(12,12,10.6),K(z(12,12,8)),F([6,6],[18,18],2.8),_(5,10.4,3,3.2,.6),_(16,10.4,3,3.2,.6))},{key:"food",label:"Food",group:"food-drink",path:"M5 2.5V8a2.5 2.5 0 0 0 5 0V2.5 M7.5 2.5v19 M18.5 13.5h-2c-1.3 0-2-1-2-2.5 0-4 1.5-7 4-8.5v19",solid:k(X([[4.9,2.6],[4.9,8]],2.2),X([[10.1,2.6],[10.1,8]],2.2),X([[7.5,2.6],[7.5,8]],2.2),de(7.5,8,2.6,0,180,2.2),F([7.5,10],[7.5,21.4],3),q([[19.4,2.2],[19.4,14.2],[16.2,14.2],[14.1,12],[14.1,9.4],[15.2,5.8],[17.3,3.3]]),F([18,13],[18,21.4],3))},{key:"bar",label:"Bar",group:"food-drink",path:"M3.5 3.5h17L12 13Z M6.2 6.5h11.6 M12 13v7.5 M8 20.5h8",solid:k(q([[2.8,3],[21.2,3],[12,13.6]]),F([12,12],[12,20.6],2.8),F([7.4,21],[16.6,21],2.8))},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 9h12v4.5a5.5 5.5 0 0 1-5.5 5.5h-1A5.5 5.5 0 0 1 4 13.5Z M16 10.5h1.2a2.75 2.75 0 0 1 0 5.5H16 M8 3v3 M12 3v3 M3 21.5h14",solid:k({from:[3.4,8.4],segs:[{to:[16.6,8.4]},{to:[16.6,13.4]},{to:[11,19.4],arc:{r:5.8,large:0,sweep:1}},{to:[9,19.4]},{to:[3.4,13.4],arc:{r:5.8,large:0,sweep:1}},{to:[3.4,8.4]}]},de(17.2,13.25,2.5,270,450,2.4),F([7.8,2.6],[7.8,5.6],2.4),F([12.2,2.6],[12.2,5.6],2.4),F([2.6,21.6],[17.4,21.6],2.6))},{key:"water",label:"Water / drinks",group:"food-drink",path:tl,solid:"M12 1.2S4 8.9 4 14.5a8 8 0 0 0 16 0c0-5.6-8-13.3-8-13.3Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:el,solid:"M8.4 2.8 3.5 5l-1.9 6 4.2 1.4.4-.8v9.4h11.6v-9.4l.4.8 4.2-1.4-1.9-6-4.9-2.2c-.4 1.5-1.8 2.6-3.6 2.6s-3.2-1.1-3.6-2.6Z"},{key:"screen",label:"Screen",group:"facilities",path:[he(2,3.5,20,13.5,2),"M12 17v3.5 M8 20.5h8","M10 7.8v5.9l5-2.95Z"].join(" "),solid:k(_(1.5,3,21,14.4,2.4),K(q([[9.6,6.7],[16,10.2],[9.6,13.7]])),_(10.6,16.5,2.8,4,0),F([7.4,21],[16.6,21],2.8))},{key:"sound-booth",label:"Sound booth",group:"facilities",path:["M6 3v9 M6 16v5 M12 3v3 M12 10v11 M18 3v10 M18 17v4",ae(6,14,2),ae(12,8,2),ae(18,15,2)].join(" "),solid:k(F([6,2.8],[6,21.2],1.8),F([12,2.8],[12,21.2],1.8),F([18,2.8],[18,21.2],1.8),_(3.2,11.6,5.6,4.8,1.4),_(9.2,5.6,5.6,4.8,1.4),_(15.2,12.6,5.6,4.8,1.4))},{key:"entrance",label:"Entrance",group:"navigation",path:"M11 7V3.5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v17a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V17 M2.5 12h13.5 M12.5 8.5 16 12l-3.5 3.5",solid:k(X([[11,6.5],[11,2.6],[21,2.6],[21,21.4],[11,21.4],[11,17.5]],2.6),F([2.8,12],[13.5,12],3.2),q([[12.6,7.8],[18,12],[12.6,16.2]]))},{key:"exit",label:"Exit",group:"navigation",path:"M13 7V3.5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v17a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V17 M8 12h13.5 M18 8.5l3.5 3.5-3.5 3.5",solid:k(X([[13,6.5],[13,2.6],[3,2.6],[3,21.4],[13,21.4],[13,17.5]],2.6),F([7.2,12],[17,12],3.2),q([[16.2,7.8],[21.6,12],[16.2,16.2]]))},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:[It(Ke(Yr,-2,1.4,1.15)),"M15.5 13h6 M19 10.5l2.5 2.5-2.5 2.5"].join(" "),solid:k(ze(Ke(Yr,-2,1.4,1.15),2.7),F([15.6,13],[19.5,13],2.8),q([[18.4,9.4],[22.4,13],[18.4,16.6]]))},{key:"stairs",label:"Stairs",group:"navigation",path:nl,solid:"M1.5 22.5h21V2h-7.8v6.4H8.4v6.4H1.5Z"},{key:"elevator",label:"Elevator",group:"navigation",path:[he(3.5,2.5,17,19,2.5),"M8.5 9.5 12 5.5l3.5 4Z M8.5 14.5l3.5 4 3.5-4Z"].join(" "),solid:k(q([[12,1.6],[19.6,10.2],[4.4,10.2]]),q([[4.4,13.8],[19.6,13.8],[12,22.4]]))},{key:"parking",label:"Parking",group:"navigation",path:[he(3,3,18,18,3),"M9.5 17V7h3.75a3 3 0 0 1 0 6H9.5"].join(" "),solid:"M6.5 21V3H12a5.5 5.5 0 0 1 0 11h-1.9v7Z M10.1 6.6v3.8H12a1.9 1.9 0 0 0 0-3.8Z"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:It(_e),solid:k(ze(_e))},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:["M4 9a6 6 0 1 1 12 0c0 3-1.8 4.3-3 5.2-1.1.8-1.6 1.7-1.6 3.1a3.6 3.6 0 0 1-6.2 2.1","M7.5 9a2.5 2.5 0 0 1 5 0c0 1.2-.7 1.9-1.6 2.5","M18.5 5.5a6.5 6.5 0 0 1 0 8"].join(" "),solid:k(de(10,9,6,180,380,3),X([[15.64,11.05],[12.8,14.3],[11.5,17.2]],3),de(8.2,17.2,3.3,0,150,3),de(10,9,2.2,180,400,2.4),de(13.38,9.5,6.5,322,398,2.6))},{key:"box-office",label:"Box office / tickets",group:"navigation",path:"M3 7.5A1.5 1.5 0 0 1 4.5 6h15A1.5 1.5 0 0 1 21 7.5V10a2 2 0 0 0 0 4v2.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 16.5V14a2 2 0 0 0 0-4Z M15 6v2 M15 11v2 M15 16v2",solid:k(ol,K(_(14.1,7,1.8,2.2,.9)),K(_(14.1,10.9,1.8,2.2,.9)),K(_(14.1,14.8,1.8,2.2,.9)))},{key:"escalator",label:"Escalator",group:"navigation",path:"M2.5 17H7l9-9h5.5v4h-4l-9 9h-6Z M11 4.5h.01 M11 8.2v3.3",solid:k(q([[2,16.4],[6.8,16.4],[15.8,7.4],[22,7.4],[22,12.6],[17.8,12.6],[8.8,21.6],[2,21.6]]),z(11,4.3,2.3),F([11,8],[11,11],2.6))},{key:"ramp",label:"Ramp",group:"navigation",path:"M2.5 19.5h19v-10Z M4.5 13.2 14 8.2 M10.53 7.76 14 8.2l-1.6 3.11",solid:k(q([[1.6,20.4],[22.4,20.4],[22.4,8.6]]),F([4.2,13.4],[13.2,8.6],2.6),q([[15.4,7.5],[13.16,11.84],[10.56,6.88]]))},{key:"taxi",label:"Taxi / rideshare",group:"navigation",path:["M9.5 2.5h5V5h-5Z M6.5 11 8 7h8l1.5 4",he(3.5,11,17,6,2),"M6.5 17v2.5 M17.5 17v2.5 M7 14h.01 M17 14h.01"].join(" "),solid:k(_(9,1.8,6,3.4,.8),q([[6,11.4],[7.6,6.4],[16.4,6.4],[18,11.4]]),_(2.8,10.6,18.4,7,2.2),K(z(6.8,14,1.3)),K(z(17.2,14,1.3)),_(4.8,16,3.6,5.2,1.2),_(15.6,16,3.6,5.2,1.2))},{key:"transit",label:"Bus / transit",group:"navigation",path:[he(4.5,2.5,15,16,3),"M4.5 10.5h15 M9 5.5h6 M7.5 18.5V21 M16.5 18.5V21 M8 14.5h.01 M16 14.5h.01"].join(" "),solid:k(_(4,2,16,17,3.2),K(_(6.2,5.8,11.6,5,1)),K(z(8,14.5,1.3)),K(z(16,14.5,1.3)),_(6,17,3.4,5,1.2),_(14.6,17,3.4,5,1.2))},{key:"bike-parking",label:"Bike parking",group:"navigation",path:[ae(6,14.5,4),ae(18,14.5,4),"M6 14.5 9 7.5h6.5L18 14.5 M9 7.5l2.5 7H6 M11.5 14.5l4-7 M7.5 6h3 M15.5 7.5 15 5.5h2"].join(" "),solid:k(z(6,14.5,4.9),K(z(6,14.5,2.7)),z(18,14.5,4.9),K(z(18,14.5,2.7)),X([[6,14.5],[9,7.5],[15.5,7.5],[18,14.5]],2.2),X([[9,7.5],[11.5,14.5],[15.5,7.5]],2.2),F([6,14.5],[11.5,14.5],2.2),F([7.2,5.8],[10.6,5.8],2.2),X([[15.4,7.3],[15,5.4],[17.2,5.4]],2.2))},{key:"meeting-point",label:"Meeting point",group:"navigation",path:["M9.5 2.5 12 5l2.5-2.5 M9.5 21.5 12 19l2.5 2.5 M2.5 9.5 5 12l-2.5 2.5 M21.5 9.5 19 12l2.5 2.5",ae(10,9.6,1.5),ae(14,9.6,1.5),"M7.5 15.5a2.5 2.5 0 0 1 5 0 M11.5 15.5a2.5 2.5 0 0 1 5 0"].join(" "),solid:k(X([[9.4,2.4],[12,5],[14.6,2.4]],2.6),X([[9.4,21.6],[12,19],[14.6,21.6]],2.6),X([[2.4,9.4],[5,12],[2.4,14.6]],2.6),X([[21.6,9.4],[19,12],[21.6,14.6]],2.6),z(9.7,9.3,2.2),z(14.3,9.3,2.2),ii(9.7,16,3),ii(14.3,16,3))},{key:"security",label:"Security / bag check",group:"facilities",path:"M12 2.5 19.5 5.5v6c0 4.6-3.2 8.4-7.5 10-4.3-1.6-7.5-5.4-7.5-10v-6Z M8.5 12l2.5 2.5 4.5-5",solid:k(rl,K(q([[7.4,12.2],[9,10.6],[10.9,12.5],[15,8.4],[16.6,10],[10.9,15.7]])))},{key:"lockers",label:"Lockers",group:"facilities",path:[he(3.5,2.5,17,19,1.5),"M12 2.5v19 M6 6h3 M15 6h3 M9.5 11.5v2.5 M14.5 11.5v2.5"].join(" "),solid:k(_(3,2,8.4,20,1.4),K(_(5,5,4.4,1.7,.8)),K(_(8.6,10.8,1.5,3.8,.7)),_(12.6,2,8.4,20,1.4),K(_(14.6,5,4.4,1.7,.8)),K(_(13.9,10.8,1.5,3.8,.7)))},{key:"baby-change",label:"Baby change",group:"facilities",path:"M10 6.5l.8-3.3a1.2 1.2 0 0 1 2.4 0l.8 3.3 M8.5 6.5h7 M9.5 6.5l-.9 2.2a3 3 0 0 0-.1.9V19a2.5 2.5 0 0 0 2.5 2.5h2a2.5 2.5 0 0 0 2.5-2.5V9.6a3 3 0 0 0-.1-.9l-.9-2.2 M8.5 12.5h3 M8.5 16h3",solid:k(q([[9.6,6.2],[10.6,1.8],[13.4,1.8],[14.4,6.2]]),_(7.6,5.4,8.8,2.6,1),_(7.8,7.4,8.4,15,2.6),K(_(7.8,11.8,3.4,1.5,0)),K(_(7.8,15.4,3.4,1.5,0)))},{key:"prayer-room",label:"Prayer room",group:"facilities",path:[It(ai),"M3 21.5h18"].join(" "),solid:k(ze(ai),_(2.4,20.2,19.2,2.6,1.3))},{key:"quiet-room",label:"Quiet room",group:"facilities",path:"M4 9h3.5l5-4v14l-5-4H4Z M15.5 9.5l5 5 M20.5 9.5l-5 5",solid:k(q([[2.6,8.4],[7.2,8.4],[13,3.6],[13,20.4],[7.2,15.6],[2.6,15.6]]),F([15.4,9.2],[20.8,14.8],2.8),F([20.8,9.2],[15.4,14.8],2.8))},{key:"wifi",label:"Wi-Fi",group:"facilities",path:[cn(12,19,11.5,218,322),cn(12,19,7.5,218,322),cn(12,19,3.5,218,322),"M12 19h.01"].join(" "),solid:k(de(12,19.2,11,218,322,2.8),de(12,19.2,6.9,218,322,2.8),z(12,19.2,2.2))},{key:"vip-lounge",label:"VIP lounge",group:"facilities",path:["M6.5 11V7a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v4","M3.5 11.5a1.5 1.5 0 0 1 3 0V14h11v-2.5a1.5 1.5 0 0 1 3 0v6h-17Z","M5.5 17.5V20 M18.5 17.5V20"].join(" "),solid:k(_(6,4,12,8.5,2.2),_(2.4,9.6,4.6,9,2.2),_(17,9.6,4.6,9,2.2),_(6,13.2,12,5.4,.6),F([5,18],[5,20.6],2.4),F([19,18],[19,20.6],2.4))},{key:"accessible-entrance",label:"Accessible entrance",group:"accessibility",path:[It(Ke(_e,.3,5,.62)),"M12.5 3.5H20a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-7.5"].join(" "),solid:k(ze(Ke(_e,.3,5,.62),2.2),X([[13,2.8],[21.2,2.8],[21.2,21.2],[13,21.2]],2.6))},{key:"assistance-dog",label:"Assistance-dog area",group:"accessibility",path:[ln(il)+"Z","M6 10.8 3.5 7.5","M10.5 10.5V6h4.5l1 2.5"].join(" "),solid:k(q(al),F([6.2,11],[3.2,7.2],2.4),X([[10.5,11],[10.5,5.6],[15.2,5.6],[16.2,8.2]],2.2))}],ag=new Map(to.map(e=>[e.key,e]));var ci=to;var li=new Map(ci.map(e=>[e.key,e]));function di(e){return e?li.get(e):void 0}function ui(e){return typeof e=="string"&&li.has(e)}var lg=ci.map(e=>e.key);function sl(e){if(!Number.isFinite(e))return 0;let t=(e%360+360)%360;return Object.is(t,-0)||Math.abs(t)<1e-9?0:t}function dn(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 cl(e){return e==="row"?"signed180":"unsigned360"}function Ie(e,t){return cl(e)==="signed180"?dn(t):sl(t)}function ve(e,t,n){let o=r=>({x:r.x+t,y:r.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=ee(e.holes).map(r=>r.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=rr(e.outlinePath,t,n)),e.holes&&(e.holes=ee(e.holes).map(r=>r.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.holes&&(e.holes=ee(e.holes).map(r=>r.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 un(e,t,n){return n?Qo(e,t,n):{x:e.x,y:e.y}}function ll(e,t,n){let o=r=>un(r,t,n);e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=it(e.outlinePath,o,1,!1)),e.holes&&(e.holes=ee(e.holes).map(r=>r.map(o)))}function dl(e,t,n){let o=e.rotation??0;if(e.points?.length){let r={x:e.points.reduce((s,c)=>s+c.x,0)/e.points.length,y:e.points.reduce((s,c)=>s+c.y,0)/e.points.length},a=un(r,t,n),i=s=>({x:s.x+a.x-r.x,y:s.y+a.y-r.y});e.points=e.points.map(i),e.holes&&(e.holes=ee(e.holes).map(s=>s.map(i)))}else if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){let r={x:e.x+e.width/2,y:e.y+e.height/2},a=un(r,t,n);e.x+=a.x-r.x,e.y+=a.y-r.y}e.rotation=Ie("shape",o+n)}function fi(e,t,n){if(!Number.isFinite(n)||!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new RangeError("group_rotation_must_be_finite");if(n===0)return;let o=r=>un(r,t,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)}),e.rotation=Ie("row",e.rotation+n);break;case"table":case"booth":e.center=o(e.center),e.rotation=Ie(e.type,e.rotation+n);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=ee(e.holes).map(r=>r.map(o)));break;case"section":ll(e,t,n);break;case"shape":dl(e,t,n);break;case"text":e.position=o(e.position),e.rotation=Ie("text",e.rotation+n);break;case"decorImage":{let r={x:e.x+e.width/2,y:e.y+e.height/2},a=o(r);e.x+=a.x-r.x,e.y+=a.y-r.y,e.rotation=Ie("decorImage",(e.rotation??0)+n);break}}}var ul=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","wheelchairPlaces"],hi=(e,t,n)=>Number.isInteger(e)&&e>=t&&e<=n;function gi(e){let t={};for(let n of ul){if(!(n in e))continue;let o=e[n];delete e[n],o!==void 0&&(t[n]=o)}for(let n of["bookAsWhole","variableOccupancy"])if(t[n]!==void 0&&typeof t[n]!="boolean")throw new u("invalid_operation",`${n} must be true or false`);if(t.bookAsWhole===!0&&t.variableOccupancy===!0)throw new u("invalid_operation","A standing area cannot be sold whole and by party size at the same time");if(t.variableOccupancy===!1&&(t.minOccupancy!==void 0||t.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with party-size selling");for(let n of["minOccupancy","maxOccupancy"])if(t[n]!==void 0&&!hi(t[n],1,ne))throw new u("invalid_operation",`${n} must be a whole number from 1 to ${ne}`);if(t.wheelchairPlaces!==void 0&&!hi(t.wheelchairPlaces,0,ne))throw new u("invalid_operation",`wheelchairPlaces must be a whole number from 0 to ${ne}`);return t}function bi(e,t){if(Object.assign(e,t),t.bookAsWhole===!0&&delete e.variableOccupancy,t.variableOccupancy===!0&&delete e.bookAsWhole,e.bookAsWhole||delete e.bookAsWhole,!e.variableOccupancy){if(t.minOccupancy!==void 0||t.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on an area sold by party size",{gaAreaId:e.id});delete e.variableOccupancy,delete e.minOccupancy,delete e.maxOccupancy}e.wheelchairPlaces||delete e.wheelchairPlaces;let n=Ge(e);if(n&&e.inventorySegments!==void 0)throw new u("invalid_operation",`Joined area "${e.label}" is sold per person: its places keep the identities of the areas it was joined from, so it cannot become one box`,{gaAreaId:e.id});if(n&&e.capacity>rn)throw new u("invalid_operation",$r,{gaAreaId:e.id,capacity:e.capacity,max:rn});if(n&&Re(e.label))throw new u("invalid_operation",`Area label "${e.label}" uses SeatLayer's reserved GA namespace`,{gaAreaId:e.id});if(n==="variable"&&(!Number.isInteger(e.minOccupancy)||!Number.isInteger(e.maxOccupancy)||e.minOccupancy<1||e.maxOccupancy<e.minOccupancy||e.maxOccupancy>e.capacity))throw new u("invalid_operation",`Area "${e.label}" needs whole-number fewest and most guests from 1 to its ${e.capacity}-person capacity`,{gaAreaId:e.id,capacity:e.capacity});if(e.wheelchairPlaces!==void 0&&e.wheelchairPlaces>e.capacity)throw new u("invalid_operation",`Area "${e.label}" has ${e.capacity} places, so at most ${e.capacity} can be wheelchair places`,{gaAreaId:e.id,capacity:e.capacity})}function mi(e,t){let n=t.filter(a=>Ge(a));if(!n.length)return;let o=new Map(t.map(a=>[a.id,a])),r=new Map(n.map(a=>[a.label,a.id]));for(let a of T(e))for(let i of a.objects){let s=i.type==="gaArea"?o.get(i.id)??i:i,c=[];s.type==="row"?c=ie(s).map(l=>l.label):s.type==="table"?c=s.bookAsWhole||s.variableOccupancy?[s.label]:be(s).map(l=>l.label):s.type==="booth"?c=[s.label]:s.type==="gaArea"&&(c=le(s));for(let l of c){let d=r.get(l);if(d&&d!==s.id)throw new u("invalid_operation",`Inventory label "${l}" is already in use; an area sold as one box needs a unique label`,{gaAreaId:d,inventoryLabel:l,conflictingObjectId:s.id})}}}var pi=40,yi=160;function fl(e,t){let n=e.normalize("NFKC").trim();if(n.length>pi)throw new u("invalid_operation",`${t} entrance must be at most ${pi} characters`);return n}function fn(e,t){let n={};if("labelStyle"in e){let o=e.labelStyle;if(delete e.labelStyle,o!==void 0){if(o.color!==void 0)throw new u("invalid_operation",`${t} names use the chart's label colour; only visible and size can change`);if(xe(o,t),o.visible!==void 0&&typeof o.visible!="boolean")throw new u("invalid_operation",`${t} name visibility must be true or false`);n.labelStyle=o}}if("entrance"in e){let o=e.entrance;if(delete e.entrance,o===null)n.entrance=null;else if(o!==void 0){if(typeof o!="string")throw new u("invalid_operation",`${t} entrance must be text`);n.entrance=fl(o,t)||null}}return n}function hn(e,t){if(t.labelStyle){let o=De(e.labelPresentation,t.labelStyle);o?.visible===!0&&delete o.visible,o&&Object.keys(o).length?e.labelPresentation=o:delete e.labelPresentation}let n=e.entrance;t.entrance===null?delete e.entrance:t.entrance!==void 0&&(e.entrance=t.entrance),e.entrance!==n&&delete e.entranceGateId}function wi(e){if(!("chairNumbering"in e))return;let t=e.chairNumbering;if(delete e.chairNumbering,t===null)return null;let n=gr(t);if(n)throw new u("invalid_operation",n);return t}function xi(e,t){if(t===void 0)return;let n=t===null?void 0:br({...e.chairNumbering,...t});n?e.chairNumbering=n:delete e.chairNumbering}function Si(e){let t={};if("boothType"in e){let n=e.boothType;if(delete e.boothType,n===null)t.boothType=null;else if(n!==void 0){if(!Fr.includes(n))throw new u("invalid_operation","boothType must be inline, corner, peninsula or island");t.boothType=n}}if("commercial"in e){let n=e.commercial;if(delete e.commercial,n===null)t.note=null;else if(n!==void 0){let o=Object.keys(n).filter(r=>r!=="note");if(o.length)throw new u("invalid_operation",`Booth commercial supports only a note (got ${o.join(", ")})`);if(n.note===null)t.note=null;else if(n.note!==void 0){if(typeof n.note!="string")throw new u("invalid_operation","Booth note must be text");let r=n.note.normalize("NFKC").trim();if(r.length>yi)throw new u("invalid_operation",`Booth note supports at most ${yi} characters`);t.note=r||null}}}return t}function Ii(e,t){t.boothType===null?delete e.boothType:t.boothType!==void 0&&(e.boothType=t.boothType),t.note===null?delete e.commercial:t.note!==void 0&&(e.commercial={note:t.note})}var hl=[{role:"bar",label:"Bar",icon:"\u{1F378}",kind:"rect",width:160,height:44,fill:"#3a2f4a",blurb:"Drinks counter.",heightM:1.1},{role:"entrance",label:"Entrance",icon:"\u21E5",kind:"rect",width:90,height:30,fill:"#26433a",blurb:"Way in.",heightM:2.7},{role:"exit",label:"Exit",icon:"\u21E4",kind:"rect",width:90,height:30,fill:"#4a2f2f",blurb:"Emergency / way out.",heightM:2.7},{role:"restroom",label:"Restrooms",icon:"\u{1F6BB}",kind:"rect",width:90,height:60,fill:"#2b3550",blurb:"Toilets.",heightM:2.4},{role:"screen",label:"Screen",icon:"\u{1F4FD}\uFE0F",kind:"rect",width:320,height:18,fill:"#203454",blurb:"Projection surface.",heightM:6},{role:"sound",label:"Sound booth",icon:"\u{1F39B}\uFE0F",kind:"rect",width:70,height:50,fill:"#2b2b3a",blurb:"FOH / mixing desk.",heightM:1.45},{role:"concession",label:"Concession",icon:"\u{1F37F}",kind:"rect",width:120,height:44,fill:"#4a3f26",blurb:"Food stand.",heightM:1.1},{role:"coat",label:"Coat check",icon:"\u{1F9E5}",kind:"rect",width:90,height:40,fill:"#2f3a4a",blurb:"Cloakroom.",heightM:1.1},{role:"wall",label:"Wall",icon:"",kind:"rect",width:220,height:14,fill:"#1b2233",blurb:"Structural divider.",heightM:2.8},{role:"rail",label:"Safety rail",icon:"",kind:"rect",width:220,height:7,fill:"#5b6472",blurb:"Guardrail along a tier or balcony edge.",heightM:1.1},{role:"suite",label:"Suite",icon:"\u25C7",kind:"rect",width:180,height:90,fill:"#31394a",blurb:"Open-front hospitality suite.",heightM:3},{role:"obstruction",label:"Obstruction",icon:"\u25CF",kind:"ellipse",width:28,height:28,fill:"#343943",blurb:"Pillar or sightline obstruction.",heightM:4.5}],vi=new Map(hl.map(e=>[e.role,e]));function vt(e){return vi.get(e)}function Ci(e,t,n){let o=vi.get(e);if(!o)throw new Error(`unknown d\xE9cor role: ${e}`);let r=o.icon?`${o.icon} ${o.label}`:o.label;return{type:"shape",id:n,kind:o.kind,x:t.x-o.width/2,y:t.y-o.height/2,width:o.width,height:o.height,fill:o.fill,label:o.role==="wall"?void 0:r,role:e,...o.heightM!==void 0?{heightM:o.heightM}:{}}}var Oi=["in","out","both"];function no(e){return e?.type==="shape"&&e.gate!=null&&typeof e.gate=="object"}function Pi(e){return e?.type==="shape"&&!e.gate&&(e.role==="entrance"||e.role==="exit")&&e.kind!=="line"&&e.kind!=="polyline"}function Ve(e){return e.type==="row"||e.type==="section"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Ai(e){return e==="out"?"exit":"entrance"}function gl(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function oo(e){let t=new Map;for(let n of gl(e))no(n)&&t.set(n.id,n);return t}function ro(e){if(e.gate.hideFromBuyers)return;let t=e.label?.normalize("NFKC").trim();return t?t.slice(0,40):void 0}function io(e){let t=new Set([...oo(e).values()].map(n=>n.label?.trim().toLowerCase()));for(let n=0;n<26;n++){let o=`Gate ${String.fromCharCode(65+n)}`;if(!t.has(o.toLowerCase()))return o}for(let n=27;;n++)if(!t.has(`gate ${n}`))return`Gate ${n}`}function Ri(e,t,n){let o=t*.46,r=Math.max(e.length,2)*o*.6,a=n?o*1.25:0;return Math.round(r+a+t)}var co={color:eo.accessibility,width:4},lo="Step-free route";function gn(e,t,n){if(typeof e!="string")throw new u("invalid_operation",`${n} must be text`);let o=e.normalize("NFKC").trim();if(!o)throw new u("invalid_operation",`${n} cannot be empty`);if(o.length>t)throw new u("invalid_operation",`${n} must be at most ${t} characters`);return o}function ml(e){if(!Oi.includes(e))throw new u("invalid_operation","Gate use must be in, out or both")}function so(e,t){if(typeof e!="boolean")throw new u("invalid_operation",`${t} must be true or false`)}function Ct(e){return T(e).flatMap(t=>t.objects)}function Li(e,t){let n=oo(e).get(t);if(!n)throw new u("object_not_found",`Unknown gate id: ${t}. Call get_chart to list gate ids.`,{gateId:t});return n}function Ei(e){let t=e.height??40,n=Ri(e.label??"",t,e.gate?.stepFree===!0),o=(e.x??0)+(e.width??n)/2;e.x=o-n/2,e.width=n,e.kind==="rect"&&(e.cornerRadius=t/2)}function Ti(e,t){e.type!=="row"&&(t?e.entrance=t:delete e.entrance)}var Mi=e=>e.type==="row"?void 0:e.entrance;function pl(e,t){let n=ro(t),o=[];for(let r of Ct(e))!Ve(r)||r.entranceGateId!==t.id||(Ti(r,n),o.push(r.id));return o}function uo(e,t,n){n.name!==void 0&&(e.label=gn(n.name,40,"Gate name")),n.use!==void 0&&(ml(n.use),t.use=n.use),n.stepFree!==void 0&&(so(n.stepFree,"Step-free"),n.stepFree?t.stepFree=!0:delete t.stepFree),n.opens!==void 0&&(n.opens===null||typeof n.opens=="string"&&!n.opens.trim()?delete t.opens:t.opens=gn(n.opens,40,"Opening time")),n.hideFromBuyers!==void 0&&(so(n.hideFromBuyers,"Hide from buyers"),n.hideFromBuyers?t.hideFromBuyers=!0:delete t.hideFromBuyers),e.gate=t,e.role=Ai(t.use)}function ji(e,t,n,o=0){let r={type:"shape",id:e,kind:"rect",x:t.x,y:t.y-40/2,width:0,height:40,fill:eo.navigation,...o?{rotation:o}:{},heightM:vt("entrance")?.heightM??2.7};return uo(r,{use:"in"},n),Ei(r),r}function yl(e,t){let n=O(e,t.floorId);if(!Number.isFinite(t.center?.x)||!Number.isFinite(t.center?.y))throw new u("invalid_operation","A gate needs a finite centre point");if(t.rotation!==void 0&&(!Number.isFinite(t.rotation)||t.rotation<0||t.rotation>360))throw new u("invalid_operation","Gate rotation must be from 0 to 360");let o=E(e,"gate",t.idFactory,new Set),r=ji(o,t.center,{...t,name:t.name??io(e)},t.rotation??0);return n.objects.push(r),{changed:!0,floorId:n.floorId,gate:structuredClone(r)}}function wl(e,t){let n=Li(e,t.gateId);if(!Object.keys(t.patch).length)throw new u("invalid_operation","At least one gate change is required");let o=JSON.stringify(n),r=structuredClone(n);uo(r,r.gate,t.patch),(t.patch.name!==void 0||t.patch.stepFree!==void 0)&&Ei(r);let a=JSON.stringify(r)!==o;a&&Object.assign(n,r);let i=pl(e,n);return{changed:a,gate:structuredClone(n),servedObjectIds:i}}function xl(e,t){let n=Ct(e).find(a=>a.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.type!=="shape"||!Pi(n))throw new u("invalid_operation","Only an Entrance or Exit landmark can become a gate");let o=n.label?.replace(/^[^\p{L}\p{N}]+/u,"").trim(),r=!o||/^(entrance|exit)$/i.test(o);return uo(n,{use:n.role==="exit"?"out":"in"},{...t,name:t.name??(r?io(e):o.slice(0,40))}),{changed:!0,gate:structuredClone(n)}}function Sl(e,t){if(!t.objectIds.length)throw new u("invalid_operation","At least one object id is required");let n=Ct(e),o=new Map(n.map(f=>[f.id,f])),r=t.objectIds.filter(f=>!o.has(f));if(r.length)throw new u("object_not_found",`Unknown object id(s): ${r.join(", ")}`,{objectIds:r});let a=t.objectIds.filter(f=>!Ve(o.get(f)));if(a.length)throw new u("invalid_operation","Only sections, rows, tables, booths and standing areas have an entrance",{objectIds:a});let i=t.gateId===null?null:Li(e,t.gateId),s=new Set(t.objectIds.flatMap(f=>{let g=o.get(f);return g.type==="section"?[g.logicalSectionId??g.id]:[]})),c=n.filter(f=>Ve(f)&&(t.objectIds.includes(f.id)||f.type==="section"&&s.has(f.logicalSectionId??f.id))),l=i?ro(i):void 0,d=!1;for(let f of c){let g=`${f.entranceGateId??""}|${Mi(f)??""}`;i?f.entranceGateId=i.id:delete f.entranceGateId,Ti(f,l),`${f.entranceGateId??""}|${Mi(f)??""}`!==g&&(d=!0)}return{changed:d,objectIds:c.map(f=>f.id)}}function fo(e,t){let n=new Map(t.filter(no).map(r=>[r.id,r.label?.trim()??""]));if(!n.size)return[];let o=[];for(let r of Ct(e))!Ve(r)||!r.entranceGateId||!n.has(r.entranceGateId)||(r.type!=="row"&&r.entrance?.trim()===n.get(r.entranceGateId)&&delete r.entrance,delete r.entranceGateId,o.push(r.id));return o}function Il(e,t){for(let n of e){if(!Ve(n)||!n.entranceGateId)continue;let o=t.get(n.entranceGateId);o&&(n.entranceGateId=o)}}function Fi(e,t,n=lo,o=!0){return{type:"shape",id:e,kind:t.length===2?"line":"polyline",label:gn(n,40,"Route name"),points:t.map(r=>({x:r.x,y:r.y})),stroke:{...co},lineCap:"round",lineJoin:"round",endEnding:"arrow",route:o?{stepFree:!0}:{}}}function vl(e,t){let n=O(e,t.floorId);if(!Array.isArray(t.points)||t.points.length<2||t.points.length>200||t.points.some(r=>!Number.isFinite(r?.x)||!Number.isFinite(r?.y)))throw new u("invalid_operation","A route needs 2 to 200 finite points");let o=Fi(E(e,"route",t.idFactory,new Set),t.points,t.name,t.stepFree??!0);return n.objects.push(o),{changed:!0,floorId:n.floorId,route:structuredClone(o)}}function Cl(e,t){let n=Ct(e).find(r=>r.type==="shape"&&r.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.kind!=="line"&&n.kind!=="polyline")throw new u("invalid_operation","Only a line or path can be a route");let o=JSON.stringify(n);if(t.route===null)delete n.route;else{let r={...n.route??{}};t.route.stepFree!==void 0?(so(t.route.stepFree,"Step-free"),t.route.stepFree?r.stepFree=!0:delete r.stepFree):n.route||(r.stepFree=!0),t.route.name!==void 0?n.label=gn(t.route.name,40,"Route name"):n.label?.trim()||(n.label=lo),n.route||(n.stroke={...co}),n.route=r}return{changed:JSON.stringify(n)!==o,shape:structuredClone(n)}}function El(e,t){let n=O(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let r=o.map(S=>n.objects.find(m=>m.type==="table"&&m.id===S)),a=o.filter((S,m)=>!r[m]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one table change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&D(e,i.categoryKey),i.fill!==void 0&&i.fill!==null&&(i.fill=N(i.fill,"Table surface color"));let s=i.seatCount!==void 0,c=i.seatCountsBySide!==void 0;if(c){if(i.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(i.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let S=["top","bottom","left","right"],m=Object.keys(i.seatCountsBySide);if(m.length!==S.length||m.some(C=>!S.includes(C)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let C of S){let P=i.seatCountsBySide[C];if(!Number.isInteger(P)||P<0||P>40)throw new u("invalid_operation",`seatCountsBySide.${C} must be a whole number from 0 to 40`)}let v=S.reduce((C,P)=>C+i.seatCountsBySide[P],0);if(v<1||v>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&i.seatCount!==v)throw new u("invalid_operation",`seatCount must equal the ${v}-chair seatCountsBySide total`);i.seatCount=v,i.sides=S.filter(C=>i.seatCountsBySide[C]>0)}if(i.seatCount!==void 0&&(!Number.isInteger(i.seatCount)||i.seatCount<1||i.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(i.shape!==void 0&&i.shape!=="round"&&i.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(i.automaticRadius!==void 0&&typeof i.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(i.shape==="rect"&&i.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(i.bookAsWhole===!0&&i.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(i.variableOccupancy===!1&&(i.minOccupancy!==void 0||i.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(S,m,v,C)=>{if(m!==void 0&&(!Number.isFinite(m)||m<v||m>C))throw new u("invalid_operation",`${String(S)} must be from ${v} to ${C}`)};if(l("rotation",i.rotation,0,360),l("radius",i.radius,24,160),l("seatArc",i.seatArc,120,360),l("width",i.width,40,320),l("height",i.height,30,240),i.minOccupancy!==void 0&&(!Number.isInteger(i.minOccupancy)||i.minOccupancy<1||i.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(i.maxOccupancy!==void 0&&(!Number.isInteger(i.maxOccupancy)||i.maxOccupancy<1||i.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(i.sides!==void 0){let S=new Set(["top","bottom","left","right"]);if(!i.sides.length||i.sides.length>4||new Set(i.sides).size!==i.sides.length||i.sides.some(m=>!S.has(m)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=Ne(i,"Table"),f=Qt(i,"Table"),g=fn(i,"Table"),h=wi(i),b=r.map(S=>{if(S.seatCountsBySide&&!c&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${S.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:S.id});let m=structuredClone(S);if(Object.assign(m,i),hn(m,g),xi(m,h),i.fill===null&&delete m.fill,m.shape==="round")delete m.seatCountsBySide,m.automaticRadius===!0?m.radius=Er(m.seatCount,m.seatArc):delete m.automaticRadius;else{if(i.automaticRadius===!0)throw new u("invalid_operation",`Table "${m.label}" is rectangular and cannot use automatic radius`,{tableId:m.id});delete m.automaticRadius}if(m.overrides&&i.seatCount!==void 0&&(m.overrides=m.overrides.filter(v=>v.index<m.seatCount),m.overrides.length||delete m.overrides),i.bookAsWhole===!1&&delete m.bookAsWhole,i.variableOccupancy===!1&&(delete m.variableOccupancy,delete m.minOccupancy,delete m.maxOccupancy),m.bookAsWhole||delete m.bookAsWhole,m.variableOccupancy||delete m.variableOccupancy,m.bookAsWhole&&m.variableOccupancy)throw new u("invalid_operation",`Table "${m.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:m.id});if((m.bookAsWhole||m.variableOccupancy)&&m.overrides?.length)throw new u("invalid_operation",`Table "${m.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:m.id,overriddenChairIndices:m.overrides.map(v=>v.index)});if(m.bookAsWhole)delete m.minOccupancy,delete m.maxOccupancy;else if(m.variableOccupancy){if(!Number.isInteger(m.minOccupancy)||!Number.isInteger(m.maxOccupancy)||m.minOccupancy<1||m.maxOccupancy<m.minOccupancy||m.maxOccupancy>m.seatCount)throw new u("invalid_operation",`Table "${m.label}" needs whole-number minimum and maximum guests from 1 to its ${m.seatCount}-chair capacity`,{tableId:m.id,seatCount:m.seatCount})}else{if(i.minOccupancy!==void 0||i.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:m.id});delete m.minOccupancy,delete m.maxOccupancy}if(f&&delete m.displayType,d&&delete m.displayLabel,m.shape==="rect"){if(m.width??=80,m.height??=50,m.seatCountsBySide){let v=["top","bottom","left","right"],C=v.reduce((P,j)=>P+m.seatCountsBySide[j],0);if(C!==m.seatCount)throw new u("invalid_operation",`Table "${m.label}" side counts total ${C}, but seatCount is ${m.seatCount}`,{tableId:m.id,seatCount:m.seatCount,seatCountsBySide:m.seatCountsBySide});m.sides=v.filter(P=>m.seatCountsBySide[P]>0)}}else m.radius??=40;if((m.bookAsWhole||m.variableOccupancy)&&Re(m.label))throw new u("invalid_operation",`Grouped table label "${m.label}" uses SeatLayer's reserved GA namespace`,{tableId:m.id});return m}),p=new Map(b.map(S=>[S.id,S])),x=new Set(o),I=new Map;for(let S of T(e))for(let m of S.objects){let v=m.type==="table"?p.get(m.id)??m:m,C=[];v.type==="row"?C=ie(v).map(P=>P.label):v.type==="table"?C=v.bookAsWhole||v.variableOccupancy?[v.label]:be(v).map(P=>P.label):v.type==="booth"?C=[v.label]:v.type==="gaArea"&&(C=le(v));for(let P of C){let j=I.get(P);if(j&&(x.has(j)||x.has(v.id)))throw new u("invalid_operation",`Inventory label "${P}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:P,conflictingObjectIds:[j,v.id]});I.set(P,j??v.id)}}let y=!1,w=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius","chairNumbering","labelPresentation","entrance"];for(let[S,m]of r.entries()){let v=b[S],C=JSON.stringify(m);for(let P of w)P in v||delete m[P];Object.assign(m,v),JSON.stringify(m)!==C&&(y=!0)}return{floorId:n.floorId,changed:y,tableIds:o}}function Tl(e,t){let n=O(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let r=o.map(p=>n.objects.find(x=>x.type==="booth"&&x.id===p)),a=o.filter((p,x)=>!r[x]);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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one booth change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&D(e,i.categoryKey);let s=(p,x,I,y)=>{if(x!==void 0&&(!Number.isFinite(x)||x<I||x>y))throw new u("invalid_operation",`${p} must be from ${I} to ${y}`)};s("width",i.width,30,400),s("height",i.height,30,400),s("rotation",i.rotation,0,360);let c=i.points===null;if(i.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let p=ar(i.points);if(!p.ok)throw new u("invalid_operation",p.message??"The booth outline is not a valid simple polygon")}let l=i.points!=null?i.points.map(p=>({x:p.x,y:p.y})):void 0;delete i.points;let d=Ne(i,"Booth"),f=Qt(i,"Booth"),g=fn(i,"Booth"),h=Si(i),b=!1;for(let p of r){let x=JSON.stringify(p);Object.assign(p,i),hn(p,g),Ii(p,h),d&&delete p.displayLabel,f&&delete p.displayType,c?delete p.points:l&&(p.points=l),JSON.stringify(p)!==x&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function jl(e,t){let n=O(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 r=o.map(h=>n.objects.find(b=>b.type==="gaArea"&&b.id===h)),a=o.filter((h,b)=>!r[b]);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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one GA area change is required");if(i.label!==void 0){if(i.label=i.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(!i.label||i.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(i.categoryKey!==void 0&&D(e,i.categoryKey),i.capacity!==void 0&&(!Number.isInteger(i.capacity)||i.capacity<1||i.capacity>ne))throw new u("invalid_operation",`capacity must be an integer from 1 to ${ne}`);if(i.cornerRadius!==void 0&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=Ne(i,"GA area"),c=Qt(i,"GA area"),l=fn(i,"GA area"),d=gi(i);if(i.capacity!==void 0)for(let h of r){if(h.inventorySegments!==void 0&&i.capacity<h.capacity)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot be reduced below ${h.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:h.id,currentCapacity:h.capacity,requestedCapacity:i.capacity});if(h.inventorySegments!==void 0&&i.capacity>h.capacity&&Wn(h,i.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot append that capacity safely`,{gaAreaId:h.id})}let f=r.map(h=>{let b=structuredClone(h),p=i.capacity===void 0?h.inventorySegments:Wn(h,i.capacity);return Object.assign(b,i),hn(b,l),bi(b,d),p!==void 0&&(b.inventorySegments=p),s&&delete b.displayLabel,c&&delete b.displayType,b});mi(e,f);let g=!1;for(let[h,b]of r.entries()){let p=f[h],x=JSON.stringify(b);for(let I of Object.keys(b))I in p||delete b[I];Object.assign(b,p),JSON.stringify(b)!==x&&(g=!0)}return{floorId:n.floorId,changed:g,gaAreaIds:o}}function go(e,t){if(t.length<3)return 0;let n=r=>H(r,t,void 0),o=0;for(let r of e)n(V(r))&&(r.type==="row"?o+=ie(r).length:r.type==="table"?o+=be(r).length:(r.type==="gaArea"||r.type==="booth")&&(o+=Pe(r)));return o}function Fl(e,t){let n=O(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)),r=t.objectIds.filter((s,c)=>!o[c]);if(r.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:r});let a=o,i=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)i.has(n.objects[s].id)&&n.objects.splice(s,1);return fo(e,a),{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,c)=>s+Pe(c),0),remainingObjectCount:n.objects.length}}function Nl(e,t){let n=O(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let r=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!r[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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one text change is required");if(i.text!==void 0){if(i.text=i.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(!i.text||i.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(i.fontSize!==void 0&&(!Number.isFinite(i.fontSize)||i.fontSize<8||i.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(i.fontFamily!==void 0&&i.fontFamily!==null&&(i.fontFamily=i.fontFamily.normalize("NFKC").trim(),!i.fontFamily||i.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(i.rotation!==void 0&&(!Number.isFinite(i.rotation)||i.rotation<0||i.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(i.color!==void 0&&i.color!==null&&(i.color=N(i.color,"Text color")),i.bold!==void 0&&typeof i.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(i.italic!==void 0&&typeof i.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(i.width!==void 0&&i.width!==null&&(!Number.isFinite(i.width)||i.width<40||i.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(i.align!==void 0&&!["left","center","right"].includes(i.align))throw new u("invalid_operation","Text align must be left, center, or right");if(i.lineHeight!==void 0&&(!Number.isFinite(i.lineHeight)||i.lineHeight<.8||i.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(i.letterSpacing!==void 0&&(!Number.isFinite(i.letterSpacing)||i.letterSpacing<-2||i.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(i.underline!==void 0&&typeof i.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(i.opacity!==void 0&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(i.background!==void 0&&i.background!==null){i.background.color=N(i.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:f=.9}=i.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(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(l=>Object.prototype.hasOwnProperty.call(i,l))&&r.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(i.labelImportance!==void 0&&i.labelImportance!==null&&i.labelImportance!=="orientation"&&i.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(i.iconKey!==void 0){if(!ui(i.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(r.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 r){let d=JSON.stringify(l);i.iconKey!==void 0&&(l.iconKey=i.iconKey),i.text!==void 0&&(l.text=i.text),i.fontSize!==void 0&&(l.fontSize=i.fontSize),i.fontFamily===null?delete l.fontFamily:i.fontFamily!==void 0&&(l.fontFamily=i.fontFamily),i.rotation!==void 0&&(l.rotation=i.rotation),i.color===null?delete l.color:i.color!==void 0&&(l.color=i.color),i.bold!==void 0&&(i.bold?l.bold=!0:delete l.bold),i.italic!==void 0&&(i.italic?l.italic=!0:delete l.italic),i.width===null?delete l.width:i.width!==void 0&&(l.width=i.width),i.align!==void 0&&(i.align==="left"?delete l.align:l.align=i.align),i.lineHeight!==void 0&&(i.lineHeight===1.2?delete l.lineHeight:l.lineHeight=i.lineHeight),i.letterSpacing!==void 0&&(i.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=i.letterSpacing),i.underline!==void 0&&(i.underline?l.underline=!0:delete l.underline),i.opacity!==void 0&&(i.opacity===1?delete l.opacity:l.opacity=i.opacity),i.background===null?delete l.background:i.background!==void 0&&(l.background=i.background),i.labelImportance===null?delete l.labelImportance:i.labelImportance!==void 0&&(l.labelImportance=i.labelImportance),JSON.stringify(l)!==d&&(ht(l),c=!0)}return{floorId:n.floorId,changed:c,textIds:o}}function Dl(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r.slice().sort((g,h)=>g.origin.y-h.origin.y||g.origin.x-h.origin.x),s=g=>g.segmentedRow?.displayLabel??g.displayLabel??g.label,c=fr(i.map(g=>({label:s(g)})),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,f=!1;return i.forEach((g,h)=>{let b=c[h].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(g)!==b&&(f=!0,g.segmentedRow?g.segmentedRow.displayLabel=b:g.displayLabel=b),d!==void 0){if(d===null){g.displayType!==void 0&&(f=!0,delete g.displayType);return}g.displayType!==d&&(f=!0,g.displayType=d)}}),{floorId:n.floorId,changed:f,rows:i.map(g=>({id:g.id,displayLabel:s(g),...g.displayType?{displayType:g.displayType}:{}}))}}function Gl(e,t){let n=Kr.find(d=>d.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=t.rotation??0;if(!Number.isFinite(o))throw new u("invalid_operation","Block rotation must be a finite number of degrees");let r=O(e,t.floorId),a=new Set,i=n.build().map(d=>structuredClone(d));for(let d of i)d.id=E(e,d.type,t.idFactory,a),ve(d,t.center.x,t.center.y),o%360&&fi(d,t.center,o);for(let d of n.categories)e.categories.some(f=>f.key===d.key)||e.categories.push({...d});let s=i.filter(d=>d.type==="row");if(s.length){let d=0;for(let f of r.objects){if(f.type!=="row")continue;let g=an(f.label);g!=null&&(d=Math.max(d,g+1))}for(let f of s)f.label=B(d++)}let c=new Set(r.objects.flatMap(d=>"label"in d&&d.label?[d.label]:[]));for(let d of i){if((d.type==="table"||d.type==="booth")&&c.has(d.label)){let f=/^(.*?)(\d+)$/.exec(d.label),g=f?f[1]:`${d.label} `,h=f?Number.parseInt(f[2],10):1;do h++;while(c.has(`${g}${h}`));d.label=`${g}${h}`}"label"in d&&d.label&&c.add(d.label)}r.objects.push(...i);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let d=Oe(i);if(d){let f={type:"section",id:E(e,"sec",t.idFactory,a),label:n.sectionLabel,outline:d};r.objects.push(f),l=f.id}}return{floorId:r.floorId,blockKey:n.key,createdIds:[...i.map(d=>d.id),...l?[l]:[]],sectionId:l}}function $l(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=Gt(t,97),r=o.slice(1).reduce((a,i,s)=>a+Math.hypot(i.x-o[s].x,i.y-o[s].y),0);if(!Number.isFinite(r)||r<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:r}}function Gi(e,t){let n=O(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 r=$l(t.path),a=ie(o),i=structuredClone(o);i.path=r.path,i.origin={...r.path.start};let s=ie(i),c=a.map((d,f)=>Math.hypot(d.x-s[f].x,d.y-s[f].y)),l=JSON.stringify(o.path)!==JSON.stringify(r.path)||o.origin.x!==r.path.start.x||o.origin.y!==r.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:r.length,averageSeatMovement:c.length?c.reduce((d,f)=>d+f,0)/c.length:0,maxSeatMovement:c.length?Math.max(...c):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Bl(e,t){let n=Gi(e,t);if(!n.changed)return n;let r=O(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return r.path=structuredClone(t.path),r.origin={...t.path.start},delete r.arcFanGeneration,delete r.rowBlockGeneration,n}function Kl(e,t){let n=e.map((o,r)=>[...o,t[r]]);for(let o=0;o<3;o++){let r=o;for(let i=o+1;i<3;i++)Math.abs(n[i][o])>Math.abs(n[r][o])&&(r=i);if(Math.abs(n[r][o])<1e-9)return null;[n[o],n[r]]=[n[r],n[o]];let a=n[o][o];for(let i=o;i<4;i++)n[o][i]/=a;for(let i=0;i<3;i++){if(i===o)continue;let s=n[i][o];for(let c=o;c<4;c++)n[i][c]-=s*n[o][c]}}return[n[0][3],n[1][3],n[2][3]]}function zl(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let r of e){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))return null;let a=[2*r.x,2*r.y,1],i=r.x**2+r.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*i;for(let c=0;c<3;c++)t[s][c]+=a[s]*a[c]}}let o=Kl(t,n);return o?{x:o[0],y:o[1]}:null}function Ni(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function $i(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="section"&&h.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let r=t.strength??100;if(!Number.isFinite(r)||r<0||r>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=T(e).find(h=>h.id===n.floorId),i=t.mode==="outline"?zl(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!i||!Number.isFinite(i.x)||!Number.isFinite(i.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(h=>h.type==="row"&&H(V(h),o.outline,o.holes)),c=s.filter(h=>!!h.path).map(h=>h.id),l=[],d=[],f=r/100;for(let h of s){if(h.path)continue;if(h.seatCount<2){l.push(h.id);continue}let b=Math.hypot(h.origin.x-i.x,h.origin.y-i.y);if(b<=h.seatSpacing/2+1e-6){l.push(h.id);continue}let p=2*Math.asin(h.seatSpacing/(2*b))/pe,x=ie(h),I=Math.atan2(h.origin.x-i.x,h.origin.y-i.y)/pe,w=(h.curve!==0?Math.sign(h.curve):x.length>1&&Math.sign(Ni(Math.atan2(x[1].x-i.x,x[1].y-i.y)/pe-I))||1)*p*(h.seatCount-1);if(Math.abs(w)>320){l.push(h.id);continue}let S=-I,m=h.curve+(w-h.curve)*f,v=h.rotation+Ni(S-h.rotation)*f,C={...h,curve:m,rotation:v},j=ie(C).map((Y,J)=>Math.hypot(Y.x-x[J].x,Y.y-x[J].y));d.push({rowId:h.id,fromCurve:h.curve,targetCurve:w,resultCurve:m,fromRotation:h.rotation,resultRotation:v,rmsMovement:Math.sqrt(j.reduce((Y,J)=>Y+J**2,0)/j.length),maxMovement:Math.max(...j)})}let g=d.map(h=>h.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...i},strength:r,rows:d,skippedPathRowIds:c,skippedInvalidRowIds:l,averageMovement:g.length?g.reduce((h,b)=>h+b,0)/g.length:0,maxMovement:d.length?Math.max(...d.map(h=>h.maxMovement)):0}}function Ul(e,t){let n=$i(e,t),o=O(e,n.floorId),r=o.objects.find(i=>i.type==="section"&&i.id===n.sectionId),a=!1;for(let i of n.rows){let s=o.objects.find(c=>c.type==="row"&&c.id===i.rowId);(s.curve!==i.resultCurve||s.rotation!==i.resultRotation)&&(s.curve=i.resultCurve,s.rotation=i.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(r.smoothing??0)!==n.strength&&(r.smoothing=n.strength,a=!0),{...n,changed:a}}function Bi(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return r*a<-1e-9&&i*s<-1e-9}function Di(e,t){return e.some((n,o)=>{let r=e[(o+1)%e.length];return t.some((a,i)=>Bi(n,r,a,t[(i+1)%t.length]))})}function Hl(e){if(e.length<3||e.length>256||Math.abs(nt(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)&&Bi(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function bn(e,t,n){let o=O(e,t),r=o.objects.find(i=>(i.type==="section"||i.type==="gaArea"||i.type==="shape"&&i.kind==="polygon")&&i.id===n);if(!r)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});let a=r.type==="section"?r.outline:r.type==="shape"?st(r):r.points;return{target:o,object:r,outer:a}}function Ki(e,t,n){return t.type==="shape"?{ids:[],units:0}:{ids:e.objects.filter(r=>r.id!==t.id&&r.type!=="section"&&H(V(r),n,void 0)).map(r=>r.id),units:go(e.objects.filter(r=>r.id!==t.id),n)}}function mn(e,t){let{target:n,object:o,outer:r}=bn(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Hl(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!H(l,r,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Di(a,r))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let i=o.holes??[],s=t.holeIndex??i.length;if(o.type==="shape"&&t.holeIndex==null&&i.length>=Nn)throw new u("invalid_operation",`A shape holds at most ${Nn} cut-outs`);if(!Number.isInteger(s)||s<0||s>i.length||t.holeIndex!=null&&s>=i.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<i.length;l++){if(l===t.holeIndex)continue;let d=i[l];if(Di(a,d)||H(a[0],d,void 0)||H(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let c=Ki(n,o,a);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:c.ids,excludedInventoryUnits:c.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Vl(e,t){let n=mn(e,t),{object:o}=bn(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 zi(e,t){let{target:n,object:o}=bn(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 r=o.holes[t.holeIndex],a=Ki(n,o,r);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:r.length,excludedObjectIds:a.ids,excludedInventoryUnits:a.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Xl(e,t){let n=zi(e,t),{object:o}=bn(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function ql(e){let t=ye(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Ui(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(i=>e.find(s=>s.type==="section"&&s.id===i)),r=n.filter((i,s)=>!o[s]);if(r.length)throw new u("object_not_found",`Unknown section id(s): ${r.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:r});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(i=>i.logicalSectionId??i.id))]}}function Hi(e,t){let n=O(e,t.floorId),o=Ui(n.objects,t.sectionIds),r=wt(me(e,n.floorId)),a=new Map(r.sections.map(h=>[h.id,h])),i=new Map(n.objects.map(h=>[h.id,h])),s=o.logicalSectionIds.flatMap(h=>a.get(h)?.objectIds??[]),c=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)).flatMap(h=>h.editor?.defaultCategoryKey?[h.editor.defaultCategoryKey]:[]));for(let h of s){let b=i.get(h);if(b)if(b.type==="row"||b.type==="table")for(let p of nn(b).keys())c.add(p);else(b.type==="booth"||b.type==="gaArea")&&c.add(b.categoryKey)}let f=o.logicalSectionIds.every(h=>(a.get(h)?.seatCount??0)>0),g=o.logicalSectionIds.every(h=>a.get(h)?.objectIds.some(b=>{let p=i.get(b);return p?.type==="row"||p?.type==="table"||p?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:f,...f&&c.size===1?{categoryKey:[...c][0]}:!f&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:f?c.size!==1:!s.length&&d.size>1,viewApplicable:g}}function Yl(e,t){D(e,t.categoryKey);let n=Hi(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=O(e,n.floorId),r=new Set(n.objectIds),a=!1,i=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(!r.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 f={...d};return delete f.categoryKey,i++,a=!0,Object.keys(f).some(g=>g!=="index")?[f]:[]});l.length?c.overrides=l:delete c.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:i}}function bo(e,t){let n=O(e,t.floorId),o=Ui(n.objects,t.sectionIds),{requested:r}=o,a=structuredClone(t.patch),i=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(h=>!i.has(h));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(),r.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(),r.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=ql(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&&en(a.labelPresentation,"Section"),a.labelStyle!==void 0&&xe(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(h=>h.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=N(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(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)):[],f=new Set,g=!1;for(let h of o.sections){let b=JSON.stringify(h);a.label!==void 0&&(h.label=a.label),a.labelPresentation===null?delete h.labelPresentation:a.labelPresentation!==void 0&&(h.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(h.elevation=a.elevation);let p=x=>{h.physical3dProvenance&&(delete h.physical3dProvenance[x],Object.keys(h.physical3dProvenance).length===0&&delete h.physical3dProvenance)};a.height===null?(delete h.height,p("height")):a.height!==void 0&&(h.height=a.height,h.physical3dProvenance={...h.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete h.rake,p("rake")):a.rake!==void 0&&(h.rake=a.rake,h.physical3dProvenance={...h.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete h.surfaceKind,p("surfaceKind")):a.surfaceKind!==void 0&&(h.surfaceKind=a.surfaceKind,h.physical3dProvenance={...h.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete h.color:a.color!==void 0&&(h.color=a.color),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}for(let h of d){let b=JSON.stringify(h),p=h.viewFromSeatUrl;a.displayLabel===null?delete h.displayLabel:a.displayLabel!==void 0&&(h.displayLabel=a.displayLabel);let x=h.entrance;if(a.entrance===null||a.entrance===""?delete h.entrance:a.entrance!==void 0&&(h.entrance=a.entrance),h.entrance!==x&&delete h.entranceGateId,a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete h.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(h.viewFromSeatUrl=a.viewFromSeatUrl),!h.viewFromSeatUrl||a.viewFromSeatMeta===null?delete h.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?h.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&h.viewFromSeatUrl!==p&&delete h.viewFromSeatMeta,a.labelStyle!==void 0){let I=De(h.labelPresentation,a.labelStyle);I?h.labelPresentation=I:delete h.labelPresentation}a.zone===null?delete h.zone:a.zone!==void 0&&(h.zone=a.zone),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}return{floorId:n.floorId,changed:g,sectionIds:r,affectedSectionIds:[...f]}}function Vi(e,t){let n=O(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 r=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&H(V(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:r.map(a=>a.id),inventoryUnits:r.reduce((a,i)=>a+Pe(i),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function Jl(e,t){let n=Vi(e,t),r=O(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete r.geometry,{...n,changed:!0}}function Xi(e,t){let n=(...s)=>s.every(Number.isFinite),o,r=1,a=!1,i=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");i=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");i=t.factor!==1,r=t.factor;let s=V(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");i=(t.degrees%360+360)%360!==0;let c=t.degrees*Math.PI/180,l=Math.cos(c),d=Math.sin(c),f=V(e);o=g=>{let h=g.x-f.x,b=g.y-f.y;return{x:f.x+h*l-b*d,y:f.y+h*d+b*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 i&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=it(e.outlinePath,o,r,a)),a&&e.edgeCurvature&&(e.edgeCurvature=ir(e.edgeCurvature)),e.holes&&(e.holes=ee(e.holes).map(s=>s.map(o)))),{changed:i,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 Wl(e,t){let n=O(e,t.floorId),o=n.objects.find(r=>r.type==="section"&&r.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Xi(o,t.transform)}}function Zl(e,t){let n=O(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 r=structuredClone(t.path);if(!$t(r))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=rt(r),i=JSON.stringify(o.outlinePath)!==JSON.stringify(r)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return i&&(o.outlinePath=r,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:i,segmentKinds:r.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function Ql(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function ed(e,t){return qi(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function qi(e,t){let n=O(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)],r=new Set,a=new Map,i=!1;try{for(let s of o){let c=n.objects.find(y=>y.type==="section"&&y.id===s);if(!c||!Ql(c))continue;let d=structuredClone(c);a.set(c.id,{section:c,snapshot:d});let f=JSON.stringify(c),g=(c.sourceOutline??c.outline).map(y=>({...y})),h=Math.min(100,Math.max(0,t.cornerSmoothing??c.cornerSmoothing??0)),p=(t.edgeCurvature===void 0?c.edgeCurvature:t.edgeCurvature??void 0)?.map(y=>Math.min(100,Math.max(-100,y))),x=p?.some(y=>Math.abs(y)>.5)===!0,I=h>.5||x?Bt(g,{cornerSmoothing:h,...x?{edgeCurvature:p}:{}}):null;I?(c.sourceOutline=g,c.outlinePath=I,c.outline=rt(I),h>.5?c.cornerSmoothing=h:delete c.cornerSmoothing,x?c.edgeCurvature=[...p]:delete c.edgeCurvature):(c.outline=g,delete c.outlinePath,delete c.sourceOutline,delete c.cornerSmoothing,delete c.edgeCurvature);for(let y=0;y<(c.holes?.length??0);y+=1)mn(e,{floorId:n.floorId,objectId:c.id,points:c.holes[y],holeIndex:y});JSON.stringify(c)!==f&&(i=!0,r.add(c.id))}}catch(s){for(let{section:c,snapshot:l}of a.values()){let d=c;for(let f of Object.keys(d))delete d[f];Object.assign(c,structuredClone(l))}throw s}return{floorId:n.floorId,changed:i,sectionIds:o,affectedSectionIds:[...r]}}function td(e,t,n={}){let o=!1;for(let r of t){let a=bo(e,{floorId:r.floorId,sectionIds:[r.sectionId],patch:{height:r.height,rake:r.rake,surfaceKind:r.surfaceKind}});o||=a.changed}if(n.stage){let r=O(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);r&&r.role!=="stage"&&(r.role="stage",o=!0),r&&n.stage.stageKind&&!r.stageKind&&(r.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:r,floorId:a,role:i}of n.roles??[]){let s=O(e,a).objects.find(c=>c.type==="shape"&&c.id===r);s&&!s.role&&(s.role=i,o=!0)}for(let{floorId:r,point:a}of n.focal??[]){let i=pt(a,"focalPoint"),s=r?e.floors?.find(l=>l.id===r):void 0,c=s?s.focalPoint:e.focalPoint;c?.x===i.x&&c?.y===i.y||(s?s.focalPoint=i:e.focalPoint=i,o=!0)}return e.floors?.length&&Ae(e),{changed:o}}var mo=.15,po=1.6;function Xe(e){return typeof e=="string"&&jr.includes(e)}function yo(e,t){return e&&t?"both":e?"start":t?"end":"none"}function wo(e){let t=Xe(e.aisleSeats)?e.aisleSeats:"none";return{start:t==="start"||t==="both",end:t==="end"||t==="both"}}function xo(e,t){e.aisleSeats=t}function Yi(e,t,n){if(!Xe(e.aisleSeats)){delete t.aisleSeats,delete n.aisleSeats;return}let o=wo(e);xo(t,yo(o.start,!0)),xo(n,yo(!0,o.end))}function Ji(e,t){let n=e[0],o=e[e.length-1];if(!n||!o||!Xe(n.aisleSeats)&&!Xe(o.aisleSeats)){delete t.aisleSeats;return}xo(t,yo(wo(n).start,wo(o).end))}var Wi=["butt","round","square"],Zi=["miter","round","bevel"],Qi=["none","arrow"];function So(e){return e==="line"||e==="polyline"}var ea=[{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}}],vb=ea.map(e=>e.key),nd=new Map(ea.map(e=>[e.key,e]));function Ot(e){return typeof e=="string"&&nd.has(e)}var od=new Set(["companion","child","senior","student","membership","custom"]);function qe(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 r of o){let a=r.key.trim(),i=r.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),!i||i.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=i.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:i});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(r.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(r.referenceDirectSeatImport!==void 0){let l=r.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(r.price!=null&&(!Number.isFinite(r.price)||r.price<0||r.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(r.seatGlyph!=null&&!Ot(r.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:r.seatGlyph});if((r.seatGlyph==null||r.seatGlyph==="circle")&&delete r.seatGlyph,r.tiers!=null)if(!r.tiers.length)delete r.tiers;else{if(r.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 f of r.tiers){let g=f.id.trim(),h=f.name.normalize("NFKC").trim(),b=h.toLocaleLowerCase("en");if(!g||g.length>160||l.has(g))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:g});if(!h||h.length>80||d.has(b))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:h});if(!Number.isFinite(f.price)||f.price<0||f.price>1e6)throw new u("invalid_operation",`Ticket tier ${g} price must be from 0 to 1000000`,{categoryKey:a,tierId:g});if(f.restriction!=null&&!od.has(f.restriction))throw new u("invalid_operation",`Ticket tier ${g} has an unknown restriction`,{categoryKey:a,tierId:g});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 ${g} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:g})}if(f.currency!=null&&(f.currency=f.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(f.currency)))throw new u("invalid_operation",`Ticket tier ${g} must use a three-letter ISO currency`,{categoryKey:a,tierId:g});if(f.applicability!=null){let p=f.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),x=f.applicability.accessibility;if(p&&(!p.length||p.length>1e4||p.some(I=>!I||I.length>160)||new Set(p).size!==p.length)||x&&(!x.length||x.some(I=>!mt.some(y=>y.key===I))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${g} has invalid seat applicability`,{categoryKey:a,tierId:g});f.applicability={...p?{seatLabels:p}:{},...x?{accessibility:[...x]}:{}},!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 ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g});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 ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g})}l.add(g),d.add(b)}}}return o}function pn(e,t){let n=new Set,o=structuredClone(e.categories);for(let i of t.updates){if(n.has(i.categoryKey))throw new u("invalid_operation",`Category ${i.categoryKey} may be updated only once`);n.add(i.categoryKey);let s=o.find(f=>f.key===i.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${i.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:i.categoryKey});let c=structuredClone(i.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(f=>{let g={...f,id:f.id.trim(),name:f.name.normalize("NFKC").trim()};return f.buyerMessage?.trim()?g.buyerMessage=f.buyerMessage.normalize("NFKC").trim():delete g.buyerMessage,g})),delete s.referenceDirectSeatImport}let r=qe(o),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,categoryKeys:[...n],categories:e.categories}}function rd(e,t){let n=structuredClone(e.categories),o=n.find(i=>i.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 r=qe(n),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,category:e.categories.find(i=>i.key===t.categoryKey),categories:e.categories}}function id(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 r=new Set(o),a=o.filter(c=>!n.includes(c)),i=n.filter(c=>!r.has(c));if(a.length||i.length)throw new u(i.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:i});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=qe(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}}function ta(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 ad(e,t){let n=ta(e),o=ta(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var sd=3600;function na(e,t,n=Se){return n.find(r=>e.every(a=>ad(r,a)>=sd))??n[t%n.length]}function cd(e,t){let n=t?.palette??Se;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(i=>[i.key,i.color.toLowerCase()])),r=e.categories.map((i,s)=>({categoryKey:i.key,patch:{color:n[s%n.length]}}));return pn(e,{updates:r}),{changed:e.categories.map(i=>({key:i.key,from:o.get(i.key),to:i.color})).filter(i=>i.from!==i.to),categories:e.categories}}function ld(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 r=structuredClone(e.categories),a=r.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 i=qe(r),s=JSON.stringify(i)!==JSON.stringify(e.categories);return s&&(e.categories=i),{changed:s,category:e.categories.find(c=>c.key===t.categoryKey),categories:e.categories}}function yn(e,t){let n=new Set(e.categories.map(i=>i.key)),o="";for(let i=0;i<100;i++){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 r={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(i=>({...i,id:i.id.trim(),name:i.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=qe([...e.categories,r]);return e.categories=a,{changed:!0,category:a.find(i=>i.key===o),categories:a}}var oa=["#3e8e7e","#6e7ff0","#b0700f","#b05fc4"],dd=[...oa,"#4d7c0f","#c026d3","#a86b00","#d6336c","#e5484d","#dc2626"],ud={row:"#6e7ff0",table:"#3e8e7e",booth:"#b05fc4",gaArea:"#b0700f"};function fd(e,t){let n=ud[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var hd="#f5f6f8",gd="#f7f8fb",bd=26;function md(e,t,n){let o=(1-Math.abs(2*n-1))*t,r=(e%360+360)%360/60,a=o*(1-Math.abs(r%2-1)),[i,s,c]=r<1?[o,a,0]:r<2?[a,o,0]:r<3?[0,o,a]:r<4?[0,a,o]:r<5?[a,0,o]:[o,0,a],l=n-o/2,d=f=>Math.round((f+l)*255).toString(16).padStart(2,"0");return`#${d(i)}${d(s)}${d(c)}`}function pd(e,t,n,o,r){let a=d=>e.every(f=>{let g=Qn(d,f);return g==null||g>=bd}),i=[hd,r??gd],s=(d,f)=>St(qr(d,f,Vr),f)??0,c=d=>o==="gaArea"?[...i,"#12151d"].every(f=>s(d,f)>=3):i.every(f=>(St(d,f)??0)>=3),l=t.find(d=>a(d)&&c(d));if(l)return l;for(let d=0;d<360;d+=12)for(let f of[.52,.44,.6]){let g=md(d,.62,f);if(a(g)&&c(g))return g}return n}function ra(e,t){let n=yt.find(a=>a.objectType===t).creationWord,o=e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim();return yt.some(a=>a.creationWord.toLowerCase()===o.toLowerCase())?n:`${o} \u2013 ${n}`}function yd(e){let t=new Map;for(let n of T(e))for(let o of n.objects){let r=yt.find(i=>i.objectType===o.type);if(!r)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let i of nn(o).keys())a.add(i);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let i of a){let s=t.get(i)??new Set;s.add(r.objectType),t.set(i,s)}}return t}function wd(e,t){let n=new Set(e.categories.map(r=>r.label.toLowerCase())),o=t;for(let r=2;n.has(o.toLowerCase());r+=1)o=`${t} ${r}`;return o}function ia(e,t,n){let o=yd(e),r=d=>{let f=o.get(d);return!f||f.size===0||f.size===1&&f.has(n)},a=e.categories.find(d=>d.key===t);if(a&&r(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};let i=e.categories.find(d=>{let f=o.get(d.key);return f?.size===1&&f.has(n)});if(!a&&i)return{kind:"existing",categoryKey:i.key,label:i.label};let s=yt.find(d=>d.objectType===n),c=a?ra(a.label,n):s.creationWord,l=e.categories.find(d=>d.label.toLowerCase()===c.toLowerCase()&&r(d.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:i?{kind:"existing",categoryKey:i.key,label:i.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:wd(e,c)}}function xd(e,t,n,o){let r=ia(e,t,n);if(r.kind==="existing")return r.categoryKey;let a=r.baseCategoryKey?e.categories.find(i=>i.key===r.baseCategoryKey):void 0;return Sd(e,n,a,r.label,o)}function Sd(e,t,n,o,r){let a=r.palette??dd,i=e.categories.map(d=>d.color),s=r.suggestColor?.(i.map(d=>d.toLowerCase()))??na(i,e.categories.length),c=pd(i,fd(t,a),s,t,e.theme?.background),l=yn(e,{label:o,color:c,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:r.idFactory});return e.categories=l.categories,l.category.key}function Id(e,t){let n=new Set;for(let o of T(e))for(let r of o.objects)"categoryKey"in r&&r.categoryKey===t&&n.add(r.id),r.type==="section"&&r.editor?.defaultCategoryKey===t&&n.add(r.id),(r.type==="row"||r.type==="table")&&r.overrides?.some(a=>a.categoryKey===t)&&n.add(r.id);return[...n]}function Io(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=Id(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 r=qe(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=r,{changed:!0,categoryKey:t.categoryKey,categories:r}}function vd(e,t){if(!t.drafts.length)throw new u("invalid_operation","Add at least one category");let n=[];for(let o of t.drafts){let r=aa(e.categories,o.label),a=yn(e,{label:r,color:o.color,...o.price!==void 0?{price:o.price}:{},...o.tiers?.length?{tiers:o.tiers}:{},idFactory:t.idFactory});n.push(a.category.key),(o.notForSale||o.seatGlyph)&&pn(e,{updates:[{categoryKey:a.category.key,patch:{...o.notForSale?{notForSale:!0}:{},...o.seatGlyph?{seatGlyph:o.seatGlyph}:{}}}]})}return{categoryKeys:n,categories:e.categories}}function aa(e,t){let n=t.normalize("NFKC").trim().slice(0,76)||"Category",o=new Set(e.map(r=>r.label.toLocaleLowerCase("en")));if(!o.has(n.toLocaleLowerCase("en")))return n;for(let r=2;r<1e4;r+=1){let a=`${n} ${r}`;if(!o.has(a.toLocaleLowerCase("en")))return a}return`${n} ${Date.now()}`}function Cd(e,t){let{categoryKey:n,toCategoryKey:o}=t;if(!e.categories.some(i=>i.key===n))throw new u("category_not_found",`Unknown chart category: ${n}`,{categoryKey:n});if(o!==void 0){if(o===n)throw new u("invalid_operation","Move the seats to a different category");if(!e.categories.some(i=>i.key===o))throw new u("category_not_found",`Unknown chart category: ${o}`,{categoryKey:o})}let r=new Set;if(o!==void 0)for(let i of T(e))for(let s of i.objects){if((s.type==="row"||s.type==="table"||s.type==="booth"||s.type==="gaArea")&&s.categoryKey===n&&(s.categoryKey=o,r.add(s.id)),(s.type==="row"||s.type==="table")&&s.overrides?.length){for(let l of s.overrides)l.categoryKey===n&&(l.categoryKey=o,r.add(s.id));let c=s.overrides.flatMap(l=>{if(l.categoryKey!==s.categoryKey)return[l];let d={...l};return delete d.categoryKey,Object.keys(d).some(f=>f!=="index")?[d]:[]});c.length?s.overrides=c:delete s.overrides}s.type==="section"&&s.editor?.defaultCategoryKey===n&&(s.editor.defaultCategoryKey=o,r.add(s.id))}let a=Io(e,{categoryKey:n});return{movedObjectIds:[...r],categories:a.categories}}var Od=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],Pd=["seat","deck","shell","fascia"];function Ad(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),r={...e.theme??{}};for(let a of Od){let i=n[a];i===null?delete r[a]:i!==void 0&&(r[a]=N(i,`Theme ${a}`))}if(n.sectionDetail===null)delete r.sectionDetail;else if(n.sectionDetail!==void 0){if(n.sectionDetail!=="rows"&&n.sectionDetail!=="seats")throw new u("invalid_operation","Theme sectionDetail must be rows or seats");r.sectionDetail=n.sectionDetail}if(n.fontFamily===null)delete r.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");r.fontFamily=a}if(n.seatScale===null)delete r.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<mo||n.seatScale>po)throw new u("invalid_operation",`Theme seatScale must be from ${mo} to ${po}`);r.seatScale=n.seatScale}if(n.logoUrl===null)delete r.logoUrl;else if(n.logoUrl!==void 0){let a=ye(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");r.logoUrl=a}if(n.brandName===null)delete r.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");r.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete r.hideBadge:n.hideBadge===!0&&(r.hideBadge=!0),n.venue3d===null)delete r.venue3d;else if(n.venue3d!==void 0){let a={...r.venue3d??{}};for(let s of Pd){let c=n.venue3d[s];c===null?delete a[s]:c!==void 0&&(a[s]=N(c,`3D venue ${s}`))}let i=n.venue3d.roughness;if(i===null)delete a.roughness;else if(i!==void 0){if(!Number.isFinite(i)||i<0||i>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=i}r.venue3d=Object.keys(a).length?a:void 0,r.venue3d||delete r.venue3d}return e.theme=Object.keys(r).length?r:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Rd(e,t){let n=t.url===null?null:ye(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 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 r=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(r?e.viewFromSeatMeta:void 0):void 0,i=!r||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:i,scope:"venue",url:e.viewFromSeatUrl??null}}function ke(e,t){let n=me(e,t.floorId),o=ue(n),r=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return r==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:r==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:r==="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 wn(e,t){D(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 r=t.fit??"seat-pitch";if(r==="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,i=t.skewDegrees??0;if(!n(a,i)||Math.abs(a)>120||Math.abs(i)>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=O(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:r,facing:t.facing??"inward",taperDegrees:a,skewDegrees:i,aisleGaps:s,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function Md(e,t,n){let o=n*pe;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function _d(e,t,n,o){let r=Math.abs(o-n)*pe,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let f=e.aisleGaps[l];if(!f)return[];let g=f/t/r/2;return[[Math.max(0,d-g),Math.min(1,d+g)]]}).sort((l,d)=>l[0]-d[0]),i=[];for(let l of a){let d=i[i.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):i.push([...l])}let s=[],c=0;for(let l of i)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*r*(d-l)>=e.seatPitch*.75)}function kd(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,r=e.reduce((c,l)=>c+l,0),a=e.map(c=>o*c/r),i=a.map(c=>2+Math.floor(c)),s=t-i.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&&i[c]++}),i}function xn(e,t,n){let o=[];for(let r=0;r<e.rowCount;r++){let a=e.rowCount===1?0:r/(e.rowCount-1),i=e.innerRadius+r*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 ${r+1} below a 5\xB0 sweep`);let d=_d(e,i,c,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${r+1}`);e.facing==="outward"&&(d=d.slice().reverse());let f=d.map(([b,p])=>i*Math.abs(l-c)*pe*(p-b)),g=e.fit==="fixed-count"?kd(f,e.seatsPerRow):f.map(b=>Math.max(2,Math.round(b/e.seatPitch)+1)),h=e.seatLabelStart;d.forEach(([b,p],x)=>{let I=c+(l-c)*b,y=c+(l-c)*p;e.facing==="outward"&&([I,y]=[y,I]);let w=g[x];if(w>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let S=Math.abs(y-I)*pe/(w-1),m=2*i*Math.sin(S/2),v={type:"row",id:n(r,x),label:B(e.rowLabelStart+r),origin:Md(e.center,i,I),rotation:-I,curve:y-I,seatCount:w,seatSpacing:m,categoryKey:e.categoryKey,seatLabelStart:h,...d.length>1?{aisleSeats:x===0?"end":x===d.length-1?"start":"both"}:{},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:r,segmentIndex:x}};o.push(v),h+=w})}return o}function vo(e,t){let n=wn(e,t),o=O(e,t.floorId),r=xn(n,"preview-arc-fan",(c,l)=>`preview-fan-${c}-${l}`),a=r.map(c=>c.seatSpacing),i=Math.max(...a.map(c=>Math.abs(c-n.seatPitch))),s=[];return i>n.seatPitch*.12&&s.push(`Seat spacing differs from the setting by up to ${Math.round(i*Vt*100)} cm, so each row keeps its seat count`),r.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:r,logicalRowCount:n.rowCount,rowSegmentCount:r.length,totalSeats:r.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:i,aisleCount:Object.values(n.aisleGaps).filter(c=>c>0).length,warnings:s}}function Co(e,t){let n=wn(e,t),o=O(e,t.floorId),r=new Set,a=E(e,"fan",t.idFactory,r),i=xn(n,a,()=>E(e,"r",t.idFactory,r)),s=vo(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 f=Oe(i);f&&(c=E(e,"sec",t.idFactory,r),d={type:"section",id:c,label:l,outline:f,arcFanGroupId:a})}return o.objects.push(...i,...d?[d]:[]),{floorId:o.floorId,rowIds:i.map(f=>f.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 sa(e,t){let n=O(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 r=o[0].arcFanGeneration,a=f=>{let g=f.arcFanGeneration;return JSON.stringify({center:g.center,innerRadius:g.innerRadius,rowCount:g.rowCount,rowGap:g.rowGap,startAngle:g.startAngle,endAngle:g.endAngle,seatPitch:g.seatPitch,fit:g.fit,seatsPerRow:g.seatsPerRow,facing:g.facing,taperDegrees:g.taperDegrees,skewDegrees:g.skewDegrees,aisleGaps:g.aisleGaps,rowLabelStart:g.rowLabelStart,seatLabelStart:g.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 i=n.objects.find(f=>f.type==="section"&&f.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...r.center},innerRadius:r.innerRadius,rowCount:r.rowCount,rowGap:r.rowGap,startAngle:r.startAngle,endAngle:r.endAngle,seatPitch:r.seatPitch,fit:r.fit,seatsPerRow:r.seatsPerRow,facing:r.facing,taperDegrees:r.taperDegrees,skewDegrees:r.skewDegrees,aisleGaps:{...r.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:r.rowLabelStart,seatLabelStart:r.seatLabelStart,sectionLabel:i?.label},c=wn(e,s),l=new Set(xn(c,t.groupId,(f,g)=>`${f}:${g}`).map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].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 Ld(e,t){sa(e,{floorId:t.floorId,groupId:t.groupId});let n=wn(e,t),o=O(e,t.floorId),r=o.objects.filter(p=>p.type==="row"&&p.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(p=>p.type==="section"&&p.arcFanGroupId===t.groupId),i=new Map(r.map(p=>[`${p.arcFanGeneration.rowIndex}:${p.arcFanGeneration.segmentIndex}`,p.id])),s=new Set,c=xn(n,t.groupId,(p,x)=>i.get(`${p}:${x}`)??E(e,"r",t.idFactory,s)),l=vo(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 p=Oe(c);p&&(f={type:"section",id:a?.id??E(e,"sec",t.idFactory,s),label:d,outline:p,arcFanGroupId:t.groupId})}let g=new Set([...r.map(p=>p.id),...a?[a.id]:[]]),h=Math.min(...o.objects.map((p,x)=>g.has(p.id)?x:1/0)),b=o.objects.filter(p=>!g.has(p.id));return b.splice(Number.isFinite(h)?h:b.length,0,...c,...f?[f]:[]),o.objects.splice(0,o.objects.length,...b),{floorId:o.floorId,rowIds:c.map(p=>p.id),sectionId:f?.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 ca(e,t){let n=Ed(e?.trim()??"");if(n){let r=n(1);for(let a=2;t.has(r)&&a<1e3;a+=1)r=n(a);if(!t.has(r))return r}let o=0;for(;t.has(B(o));)o+=1;return B(o)}function Ed(e){if(!e)return null;let t=/^([A-Za-z])\1+$/.exec(e);if(t){let i=e===e.toLowerCase(),s=t[1].toUpperCase().charCodeAt(0)-65;return c=>{let l=s+c,f=String.fromCharCode(65+l%26).repeat(e.length+Math.floor(l/26));return i?f.toLowerCase():f}}let n=/^(.*?)(\d+)$/.exec(e);if(n){let[,i,s]=n,c=s.startsWith("0")?s.length:0;return l=>`${i}${String(Number(s)+l).padStart(c,"0")}`}let o=e.toUpperCase(),r=an(o);if(r==null)return null;let a=e===e.toLowerCase();return i=>{let s=B(r+i);return a?s.toLowerCase():s}}function Oo(e){return e.segmentedRow?.displayLabel??e.displayLabel??e.label}function Td(e,t=[]){let n=new Set([...te(e),...t].filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=0;return()=>{for(;n.has(B(o));)o+=1;let r=B(o);return n.add(r),o+=1,r}}function jd(e){let t=new Set(e.flatMap(o=>o.type==="row"?[Oo(o)]:o.type==="table"||o.type==="booth"?[o.label]:[])),n=0;return()=>{for(;t.has(B(n));)n+=1;let o=B(n);return t.add(o),o}}function Fd(e,t){let n=e.filter(c=>c.type==="section"),o=n.find(c=>H(t,c.outline,c.holes));if(!o)return jd(e);let r=e.filter(c=>c.type==="row"&&Yt(e,c,n)===o),a=new Set(r.map(Oo)),i=r[r.length-1],s=i?Oo(i):void 0;return()=>{let c=ca(s,a);return a.add(c),s=c,c}}function la(e,t){let n=t.pending??[],o=Td(e,n),r=Fd([...O(e,t.floorId).objects,...n],t.origin);return Array.from({length:Math.max(0,t.count)},()=>{let a=o(),i=r?.();return i&&i!==a?{label:a,displayLabel:i}:{label:a}})}var da=1,Po=.01;function ua(e,t){let n=Q(e),o=n[n.length-1],r=Q(t)[0];if(!o||!r)return null;let a=Math.hypot(r.x-o.x,r.y-o.y),i=a>Po?{x:(r.x-o.x)/a,y:(r.y-o.y)/a}:{x:Math.cos(t.rotation*Math.PI/180),y:Math.sin(t.rotation*Math.PI/180)};return{distance:a,direction:i,pitch:(e.seatSpacing+t.seatSpacing)/2}}function fa(e,t){return t==="break"?e*(1+da):e}function Nd(e,t){let n=e[t-1],o=e[t];if(!n||!o||o.segmentedRow?.boundaryBefore!=="break")return!1;let r=ua(n,o);return!!r&&fa(r.pitch,"break")-r.distance>=Po}function Pt(e,t,n){let o=e[t-1],r=e[t];if(!o||!r)return!1;let a=ua(o,r);if(!a)return!1;let i=fa(a.pitch,n),s=n==="break"?Math.max(0,i-a.distance):Math.min(0,i-a.distance);if(Math.abs(s)<Po)return!1;for(let c of e.slice(t))ve(c,a.direction.x*s,a.direction.y*s);return!0}function ha(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 Ao(e,t){if(D(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 r=O(e,t.floorId),a=new Set,i=la(e,{floorId:t.floorId,origin:t.origin,count:t.rowCount}),s=dn(t.rotation??0),c=t.curve??0,l=t.style,d=l?E(e,"rowblock",t.idFactory,a):void 0,f=l?ha({style:l,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:c}):void 0,g={x:Math.cos(s*fe),y:Math.sin(s*fe)},h={x:-g.y,y:g.x},b=Array.from({length:t.rowCount},(I,y)=>{let w=l==="intertwined"&&y%2===1?o/2:0,S={type:"row",id:E(e,"r",t.idFactory,a),...i[y],origin:{x:t.origin.x+h.x*y*n+g.x*w,y:t.origin.y+h.y*y*n+g.y*w},rotation:s,curve:c,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&f&&(S.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:y,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:c,signature:f}),S});r.objects.push(...b);let p=null,x=t.sectionLabel?.trim();if(x){let I=Oe(b);if(I){let y={type:"section",id:E(e,"sec",t.idFactory,a),label:x,outline:I};r.objects.push(y),p=y.id}}return{floorId:r.floorId,rowIds:b.map(I=>I.id),sectionId:p,createdIds:[...b.map(I=>I.id),...p?[p]:[]]}}function ga(e,t){let n=new Set(te(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let r=`${t}${o}`;return n.add(r),o+=1,r}}function Dd(e,t){let n=new Set(te(e).filter(r=>r.type==="gaArea").map(r=>r.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Gd=456;function Sn(e){let t=Math.sqrt(Math.max(1,e)*Gd);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ro(e,t){if(D(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=O(e,t.floorId),o=new Set,{width:r,height:a}=Sn(t.capacity),i=Dd(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:E(e,"ga",t.idFactory,o),label:i,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y+a/2},{x:t.center.x-r/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:i,createdIds:[s.id]}}function Mo(e,t){if(D(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 r=O(e,t.floorId),a=new Set,i=ga(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:E(e,"t",t.idFactory,a),label:i(),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 r.objects.push(...s),{floorId:r.floorId,tableIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function _o(e,t){if(D(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 r=O(e,t.floorId),a=new Set,i=ga(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:E(e,"booth",t.idFactory,a),label:i(),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 r.objects.push(...s),{floorId:r.floorId,boothIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function At(e,t){let n=O(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(g=>g!=="continuous"&&g!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);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 i=r,s=i.filter(g=>g.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(g=>g.id)});let c=(t.displayLabel??i[0].displayLabel??i[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(g=>g.type==="row"?[g.segmentedRow?.groupId,g.rowBlockGeneration?.groupId].filter(h=>!!h):[])),d="";for(let g=0;g<100;g+=1){let h=t.idFactory("rowgroup");if(h&&!l.has(h)){d=h;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let f=i[0];return i.forEach((g,h)=>{g.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:h,componentCount:i.length,boundaryBefore:h===0?"start":t.boundaries[h-1],displayLabel:c,...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 $d(e,t){let n=O(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),r=t.groupId??o?.segmentedRow?.groupId;if(!r)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===r);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let i=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:r,rowIds:i,changed:!0}}function Bd(e,t){let n=O(e,t.floorId),o=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId).sort((s,c)=>s.segmentedRow.componentIndex-c.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(s=>s!=="continuous"&&s!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=t.displayLabel?.normalize("NFKC").trim();if(r!==void 0&&(!r||r.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(s=>s.segmentedRow)),i=!1;return t.boundaries?.forEach((s,c)=>{s==="break"&&(i=Pt(o,c+1,"break")||i)}),o.forEach((s,c)=>{let l=s.segmentedRow,d=l.viewFromSeatUrl;r!==void 0&&(l.displayLabel=r),t.boundaries&&c>0&&(l.boundaryBefore=t.boundaries[c-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!==d&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(s=>s.id),changed:i||JSON.stringify(o.map(s=>s.segmentedRow))!==a,...i?{seatsMoved:!0}:{}}}function Kd(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=O(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,oe)=>R.rowBlockGeneration.rowIndex-oe.rowBlockGeneration.rowIndex),r=o[0]?.rowBlockGeneration;if(!r||o.length!==r.rowCount||o.some((R,oe)=>{let M=R.rowBlockGeneration;return M.kind!=="row-block-v1"||M.rowIndex!==oe||M.signature!==r.signature||JSON.stringify(M)!==JSON.stringify({...r,rowIndex:oe})}))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),i=t.style??r.style,s=t.rowCount??r.rowCount,c=t.seatsPerRow??r.seatsPerRow,l=t.rowGap??r.rowGap,d=t.seatSpacing??r.seatSpacing,f=t.curve??r.curve,g=Number.isFinite(t.rotation??r.rotation)?dn(t.rotation??r.rotation):t.rotation??r.rotation,h=t.origin?{...t.origin}:{...r.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(f)||!Number.isFinite(g)||!Number.isFinite(h.x)||!Number.isFinite(h.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let b=ha({style:i,origin:h,rotation:g,rowCount:s,seatsPerRow:c,rowGap:l,seatSpacing:d,curve:f}),p={x:Math.cos(g*fe),y:Math.sin(g*fe)},x={x:-p.y,y:p.x},I=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),y=new Set,w=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,m=()=>{for(;w.has(B(S));)S+=1;let R=B(S);return w.add(R),S+=1,R},v=[],C=[];for(let R=0;R<s;R+=1){let oe=i==="intertwined"&&R%2===1?d/2:0,M=I.get(R);M||(M={type:"row",id:E(e,"r",t.idFactory,y),label:m(),origin:{...h},rotation:g,curve:f,seatCount:c,seatSpacing:d,categoryKey:o[0].categoryKey},C.push(M.id)),M.origin={x:h.x+x.x*R*l+p.x*oe,y:h.y+x.y*R*l+p.y*oe},M.rotation=g,M.curve=f,M.seatCount=c,M.seatSpacing=d,delete M.path,delete M.arcFanGeneration,M.overrides&&(M.overrides=M.overrides.filter(re=>re.index<c),M.overrides.length||delete M.overrides),M.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:i,rowIndex:R,rowCount:s,seatsPerRow:c,origin:{...h},rotation:g,rowGap:l,seatSpacing:d,curve:f,signature:b},v.push(M)}let P=o.slice(s).map(R=>R.id),j=Math.min(...o.map(R=>n.objects.indexOf(R))),Y=new Set(o.map(R=>R.id)),J=n.objects.filter(R=>!Y.has(R.id));return J.splice(j,0,...v),n.objects.splice(0,n.objects.length,...J),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(R=>R.id),createdRowIds:C,removedRowIds:P,changed:a!==JSON.stringify(v)||C.length>0||P.length>0}}function ba(e){let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t/Math.max(1,e.length-1)}function zd(e){let t=e.length,n=e.reduce((I,y)=>I+y.x,0)/t,o=e.reduce((I,y)=>I+y.y,0)/t,r=0,a=0,i=0,s=0,c=0,l=0,d=0;for(let I of e){let y=I.x-n,w=I.y-o;r+=y*y,a+=w*w,i+=y*w,s+=y*y*y,c+=w*w*w,l+=y*w*w,d+=w*y*y}let f=r*a-i*i;if(Math.abs(f)<1e-9)return null;let g=(s+l)/2,h=(c+d)/2,b=(g*a-h*i)/f,p=(h*r-g*i)/f,x=Math.sqrt(b*b+p*p+(r+a)/t);return Number.isFinite(x)?{center:{x:b+n,y:p+o},radius:x}:null}function Rt(e){let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=e.length;return{origin:{...t},rotation:o>0?Math.atan2(n.y-t.y,n.x-t.x)*180/Math.PI:0,curve:0,seatSpacing:r>1&&o>0?o/(r-1):ba(e),seatCount:r,ordered:e}}function Ud(e){if(e.length<3)return Rt(e);let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=ba(e);if(o<=0||r<=0)return Rt(e);let a=0;for(let g of e){let h=Math.abs((n.x-t.x)*(t.y-g.y)-(t.x-g.x)*(n.y-t.y))/o;a=Math.max(a,h)}if(a<r*.2)return Rt(e);let i=zd(e);if(!i||i.radius<=r/2)return Rt(e);let s=g=>{let h=g[0],b=g[1],p=h.x-i.center.x,I=-(h.y-i.center.y),y=p;I*(b.x-h.x)+y*(b.y-h.y)<0&&(I=-I,y=-y);let w=Math.hypot(I,y)||1;I/=w,y/=w;let S=(i.center.x-h.x)*y+(i.center.y-h.y)*-I;return{tx:I,ty:y,centreSide:S}},c=e,l=s(c);l.centreSide<0&&(c=[...e].reverse(),l=s(c));let f=2*Math.asin(Math.min(1,r/(2*i.radius)))*(c.length-1)*180/Math.PI;return!Number.isFinite(f)||f>=359?Rt(e):{origin:{...c[0]},rotation:Math.atan2(l.ty,l.tx)*180/Math.PI,curve:f,seatSpacing:r,seatCount:c.length,ordered:c}}function In(e,t){let n=Ud(e);if(e.length<6)return[n];let o=t(n),r=-1,a=0;if(n.ordered.forEach((s,c)=>{let l=o[c]?Math.hypot(s.x-o[c].x,s.y-o[c].y):1/0;l>a&&(a=l,r=c)}),a<=n.seatSpacing/3)return[n];let i=Math.min(n.ordered.length-3,Math.max(3,r));return[...In(n.ordered.slice(0,i),t),...In(n.ordered.slice(i),t)]}function ko(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Lo(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Eo(e){return Lo(ko(e),40)}function ma(e,t=39){return Lo(ko(e),Math.max(1,t))}function Ye(e,t=80){return Lo(ko(e),Math.max(1,t))}function pa(e){return Ye(e).toLocaleLowerCase("en")}function To(e){return pa(e)}function ya(e){return new Map((e??[]).map(t=>[t.index,t]))}function Hd(e){let t=ya(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(ge(e,o,r))}return n}function Vd(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=ya(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(r?.label??`${e.label}-${o+1}`)}return n}function Xd(e){return e.type==="row"?[e.label,...Hd(e)]:e.type==="table"?[e.label,...Vd(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...le(e)]:[]}function wa(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let r of Xd(o)){let a=To(r);a&&n.add(a)}return n}function qd(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[To(e)];for(let r=0;r<t;r+=1)o.push(To(ge(n,r)));return o.filter(Boolean)}function xa(e,t,n){let o=qd(t,n);if(!o.length||o.some(r=>e.has(r)||Re(r)))return!1;for(let r of o)e.add(r);return!0}var Yd=1e-6,Jd=160,Wd=.001,Zd=1e-5;function Je(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>Jd)return;for(let a of t){let i=a.codePointAt(0)??0;if(i<32||i===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),r=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(r)||!Number.isSafeInteger(Number(r))))return t}function Sa(e){return typeof e=="string"&&ma(e)||void 0}function Ia(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(jo(e.origin)&&jo(t.start)&&jo(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)},r=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Wd+Math.max(1,r)*Zd;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||r<=Yd)return!0;let i=r/(e.seatCount-1);if(Math.abs(e.seatSpacing-i)>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,r))*180/Math.PI);return c<=l}function jo(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var Qd=300;function eu(e){let t=new Set(te(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(Boolean)),n=0,o=()=>{for(;t.has(B(n));)n+=1;let r=B(n);return n+=1,t.add(r),r};return r=>{let a=Eo(r),i=0;return()=>{for(;a&&i<4096;i+=1){let s=`${a}-${B(i)}`;if(!t.has(s))return t.add(s),i+=1,s}return o()}}}function tu(e){let t=wa(te(e));return(n,o)=>{let r=Ye(n);for(let a=1;a<4096;a+=1){let i=a===1?"":` ${a}`,s=i?`${Ye(r,80-i.length)}${i}`:r;if(s&&xa(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function nu(e){return{ordinaryFor:eu(e),direct:tu(e)}}function Fo(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function va(e,t,n){return e.type==="table"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function ou(e,t,n){let o=new Map;for(let i of t.sections)if(!(n&&i.sectionId!==n)&&i.sourceGroupId)for(let[s,c]of i.rows.entries()){let l=Je(`${i.sourceGroupId}:${s}`),d=l&&Je(c.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:c)}let r=new Map;for(let i of e){let s=Je(i.referenceScan?.directSourceRowId);if(!s){if(!i.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:i.id})}let c=r.get(s)??[];c.push(i),r.set(s,c)}let a=new Map;for(let[i,s]of r){let c=s.filter(g=>g.overrides?.length);if(!c.length)continue;let l=o.get(i),d=c[0],f=d.overrides;if(s.length!==1||c.length!==1||!f||!l||!Ia(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:i,rowIds:s.map(g=>g.id)});a.set(i,structuredClone(f))}return a}function Ca(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!Fo(o,t,n)&&!va(o,t,n))}function ru(e,t,n,o,r,a,i){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=Ca(t,n,i).filter(f=>H(V(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 c=[],l=0;for(let[d,f]of e.rows.entries()){let g=Math.min(Qd,Math.max(1,Math.round(f.seatCount)));if(!Number.isFinite(g)||g<1)continue;let h=f.end.x-f.start.x,b=f.end.y-f.start.y,p=Math.hypot(h,b),x=g>1&&p>0?p/(g-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let I=p>0?Math.atan2(b,h)*180/Math.PI:0,y={x:f.start.x,y:f.start.y},w=0,S=x,m,v=f.seats?.length===g&&f.seats.every(M=>Number.isFinite(M.x)&&Number.isFinite(M.y))?f.seats:null;if(v&&f.table&&g>=3){let M=f.table.center,re=v.reduce(($,W)=>$+Math.hypot(W.x-M.x,W.y-M.y),0)/g,se=v.map($=>Math.atan2($.y-M.y,$.x-M.x)).sort(($,W)=>$-W),Ce=0,Nt=0;se.forEach(($,W)=>{let Ee=W+1<se.length?se[W+1]:se[0]+Math.PI*2;Ee-$>Ce&&(Ce=Ee-$,Nt=(W+1)%se.length)});let A=Ce>1.6*(Math.PI*2/g),L=A?(Math.PI*2-Ce)*180/Math.PI:void 0;m={center:{...M},radius:Math.max(1,re-we),...L!==void 0?{seatArc:L}:{}},I=A?(se[Nt]-Ce/2)*180/Math.PI:se[0]*180/Math.PI,y={...M}}let C=[];if(v&&!m&&g>=3){C=In(v,re=>Q({origin:re.origin,rotation:re.rotation,curve:re.curve,seatCount:re.seatCount,seatSpacing:re.seatSpacing}));let M=C[0];y=M.origin,I=M.rotation,w=M.curve,S=M.seatSpacing}if(!Number.isFinite(S)||S<=0)continue;let P=e.sourceGroupId?Je(`${e.sourceGroupId}:${d}`):void 0,j=P&&Je(f.directSourceRowId)===P?P:void 0,Y=j?Sa(f.directReviewedSuffix):void 0,J=e.sourceGroupId&&f.rowLabel?Ye(f.rowLabel):"",R=e.sourceGroupId&&f.rowDisplayLabel?Ye(f.rowDisplayLabel):"",oe=!!e.sourceGroupId&&f.rowDisplayLabel==="";c.push({label:J?a(J,g):r(),displayLabel:R||(oe?"":String(d+1)),origin:y,rotation:I,curve:w,seatCount:C[0]?.seatCount??g,seatSpacing:S,...m?{table:m}:{},...v&&!m?{measured:!0}:{},...j?{directSourceRowId:j}:{},...Y?{directReviewedSuffix:Y}:{}});for(let M of C.slice(1))c.push({label:r(),displayLabel:String(d+1),origin:M.origin,rotation:M.rotation,curve:M.curve,seatCount:M.seatCount,seatSpacing:M.seatSpacing,measured:!0});l+=g}return{skip:null,rows:c,seats:l}}function iu(e,t,n){D(e,n.categoryKey);let o=O(e,n.floorId),r=t.assetId,a=n.sectionId?o.objects.find(y=>y.type==="section"&&y.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let i=new Map;for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=n.categoryKeyForSection?.(y)??n.categoryKey;D(e,w),i.set(y,w)}if(a&&!t.sections.some(y=>y.sectionId===a.id&&y.seatCount>0))return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(y=>y.sectionId===a.id&&y.seatCount>0):void 0;if(a&&s){let y=Ca(o.objects,r,a.id).filter(w=>H(V(w),a.outline,a.holes));if(y.length)return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:y.map(w=>w.id)}]}}let c=o.objects.filter(y=>Fo(y,r,a?.id)),l=ou(c,t,a?.id),d=[],f=o.objects.filter(y=>Fo(y,r,a?.id)||va(y,r,a?.id)?(d.push(y.id),!1):!0);o.objects.splice(0,o.objects.length,...f);let g=[],h=[],b=[],p=new Set,x=0,I=nu(e);for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=ru(y,o.objects,r,t.seatPitch,I.ordinaryFor(y.name),I.direct,a?.id);if(w.skip){h.push(w.skip);continue}let S=[],m=[],v=0;for(let C of w.rows){let P={assetId:r,...y.sectionId?{sectionId:y.sectionId}:{}},j=i.get(y)??n.categoryKey;if(C.table){v+=1,S.push({type:"table",id:E(e,"t",n.idFactory,p),referenceScan:P,label:C.label,displayLabel:String(v),center:C.table.center,shape:"round",radius:C.table.radius,...C.table.seatArc!==void 0?{seatArc:C.table.seatArc}:{},rotation:C.rotation,seatCount:C.seatCount,categoryKey:j});continue}let Y={type:"row",id:E(e,"r",n.idFactory,p),referenceScan:{...P,...C.directSourceRowId?{directSourceRowId:C.directSourceRowId}:{},...C.directReviewedSuffix?{directReviewedSuffix:C.directReviewedSuffix}:{}},label:C.label,...C.displayLabel!==void 0?{displayLabel:C.displayLabel}:{},origin:C.origin,rotation:C.rotation,curve:C.curve,seatCount:C.seatCount,seatSpacing:C.seatSpacing,categoryKey:j,...C.directSourceRowId&&l.has(C.directSourceRowId)?{overrides:structuredClone(l.get(C.directSourceRowId))}:{}};S.push(Y),C.measured&&m.push(Y)}if(o.objects.push(...S),m.length&&!y.sourceGroupId){let C=T(e).find(P=>P.id===o.floorId);au(e,m,C?.focalPoint??e.focalPoint,o.floorId,n.idFactory)}for(let C of S)b.push(C.id);g.push({sectionId:y.sectionId,name:y.name,seats:w.seats,rows:S.length}),x+=w.seats}return{floorId:o.floorId,assetId:r,createdRowIds:b,removedRowIds:d,totalSeats:x,perSection:g,skipped:h}}function au(e,t,n,o,r){let a=t.map(h=>Q(h)),i=a.flat(),s=n??{x:i.reduce((h,b)=>h+b.x,0)/i.length,y:Math.min(...i.map(h=>h.y))-1},c=t.map((h,b)=>{let p=a[b],x=p.map((y,w)=>{let S=p[Math.max(0,w-1)],m=p[Math.min(p.length-1,w+1)],v=Math.hypot(m.x-S.x,m.y-S.y);return v<=0?Math.hypot(y.x-s.x,y.y-s.y):Math.abs((y.x-s.x)*(-(m.y-S.y)/v)+(y.y-s.y)*((m.x-S.x)/v))}).sort((y,w)=>y-w),I=p.reduce((y,w)=>y+w.x,0)/p.length;return{row:h,depth:x[Math.floor(x.length/2)],along:I}}).sort((h,b)=>h.depth-b.depth||h.along-b.along),l=c.slice(1).map((h,b)=>h.depth-c[b].depth).filter(h=>h>1e-6).sort((h,b)=>h-b),d=l.length?l[Math.floor(l.length*.75)]:1/0,f=[],g=-1/0;for(let h of c)(!f.length||h.depth-g>d*.45)&&(f.push([]),g=h.depth),f[f.length-1].push(h.row);f.forEach((h,b)=>{let p=B(b);h.sort((x,I)=>{let y=Q(x),w=Q(I);return y.reduce((S,m)=>S+m.x,0)/y.length-w.reduce((S,m)=>S+m.x,0)/w.length});for(let x of h)x.displayLabel=p;h.length>=2&&h.length<=64&&At(e,{floorId:o,rowIds:h.map(x=>x.id),boundaries:h.slice(1).map(()=>"break"),displayLabel:p,idFactory:r})})}function Pa(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.objectIds)];if(!r.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=r.map(p=>o.objects.find(x=>(x.type==="table"||x.type==="booth")&&x.id===p)),i=r.filter((p,x)=>!a[x]);if(i.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:i});let s=a[0].type;if(a.some(p=>p.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[p,x,I]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(x)||x<1||x>I)throw new u("invalid_operation",`${p} must be a whole number from 1 to ${I}`);for(let[p,x]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(x)||x<30||x>2e3)throw new u("invalid_operation",`${p} 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=r.length*(c-1);if(l>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((p,x)=>p+(x.type==="table"?x.seatCount:1),0),g=(e.floors?.length?e.floors.flatMap(p=>p.objects):e.objects).reduce((p,x)=>p+(x.type==="row"||x.type==="table"?x.seatCount:x.type==="gaArea"?Math.max(0,Math.floor(x.capacity)):x.type==="booth"?1:0),0),h=d*(c-1),b=n.maxInventory??1e5;if(g+h>b)throw new u("invalid_operation",`Grid inventory would exceed the ${b} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:r,sourceCount:r.length,cells:c,createdCount:l,addedInventory:h,resultingInventory:g+h,provenanceRemovedCount:a.filter(p=>!!p.referenceInventorySource).length*(c-1)}}}function su(e,t,n={}){return Pa(e,t,n).preview}function cu(e,t,n={}){let{target:o,sources:r,preview:a}=Pa(e,t,n),i=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]:[])),c=[],l=(f,g)=>{let h=Math.max(2,g),b=x=>{let I=`-${x}`;return`${f.slice(0,Math.max(1,80-I.length))}${I}`},p=b(h);for(;s.has(p);)p=b(++h);return s.add(p),p},d=1;for(let f=0;f<t.rows;f++)for(let g=0;g<t.columns;g++)if(!(f===0&&g===0)){d+=1;for(let h of r){let b=structuredClone(h);b.id=E(e,b.type,t.idFactory,i),b.label=l(h.label,d),b.center={x:h.center.x+g*t.stepX,y:h.center.y+f*t.stepY},delete b.referenceInventorySource,c.push(b)}}return o.objects.push(...c),{...a,createdIds:c.map(f=>f.id)}}function lu(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=N(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var du=new Set(mt.map(e=>e.key));function Mt(e){return`${e.rowId}:${e.index}`}function uu(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 fu(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,Ot(e.glyph)||delete e.glyph;let n=ft(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),r={};typeof e.commercial.restrictedView=="boolean"&&(r.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(r.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(r.premium=e.commercial.premium),o&&(r.note=o),Object.keys(r).length?e.commercial=r: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"&&Zt(t,e)}function hu(e){return Object.keys(e).every(t=>t==="index")}function Aa(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=O(e,t),r=[],a=new Set,i=new Map;for(let s of n){let c=Mt(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});r.push({rowId:s.rowId,index:s.index}),i.set(l.id,l)}return{floorId:o.floorId,refs:r,owners:i}}function No(e,t){let n=Aa(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&&D(e,t.patch.categoryKey),t.patch.glyph!=null&&!Ot(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(i=>!du.has(i));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 i=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??i?.wheelchairSpaceType,c=t.patch.skip===null?!1:t.patch.skip??i?.skip??!1;if(s&&c)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Mt(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=ye(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 i=t.patch[a];if(i!=null&&!Number.isFinite(i))throw new u("invalid_operation",`${a} must be finite`,{[a]:i})}t.patch.labelStyle!=null&&xe(t.patch.labelStyle,"Seat");let r=!1;return n.refs.forEach((a,i)=>{let s=n.owners.get(a.rowId),c=JSON.stringify(s.overrides??[]),l=s.overrides??(s.overrides=[]),d=l.find(g=>g.index===a.index);d||(d={index:a.index},l.push(d));let f=d.viewFromSeatUrl;for(let g of o){let h=t.patch[g];if(g==="wheelchairSpaceType"&&h==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(b=>b!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(h==null)delete d[g];else if(g==="accessibility")d.accessibility=[...new Set(h)],delete d.accessible;else if(g==="commercial")d.commercial={...d.commercial,...h};else if(g==="labelStyle"){let b=lu(d.labelStyle,h);b?d.labelStyle=b:delete d.labelStyle}else Object.assign(d,{[g]:h})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==f&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${i+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${i+1}`),fu(d,s),hu(d)&&(s.overrides=l.filter(g=>g!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==c&&(r=!0)}),{floorId:n.floorId,changed:r,seatIds:n.refs.map(Mt)}}function gu(e,t){let n=Aa(e,t.floorId,t.seats),o=!1;for(let[r,a]of n.owners){if(!a.overrides?.length)continue;let i=new Set(n.refs.filter(c=>c.rowId===r).map(c=>c.index)),s=a.overrides.filter(c=>!i.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(Mt)}}function bu(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(w=>n.objects.find(S=>S.type==="row"&&S.id===w)),a=o.filter((w,S)=>!r[S]);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&&D(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 w=t.patch.seatNumbering,S=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(w.scheme!==void 0&&!S.includes(w.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${w.scheme}. Expected one of ${S.join(", ")}.`);if(w.prefix!==void 0&&(typeof w.prefix!="string"||w.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(w.endAt!==void 0&&w.endAt!==null&&(!Number.isInteger(w.endAt)||w.endAt<0||w.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:i,labelPosition:s,labelRotation:c,labelStyleShape:l,displayLabel:d,displayType:f,aisleSeats:g,...h}=t.patch,b=d===void 0?{}:{displayLabel:d},p=Ne(b,"Row"),x=f===void 0?void 0:Vn(f,"Row");if(i!==void 0&&xe(i,"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");if(h.labelPresentation!==void 0&&en(h.labelPresentation,"Row"),g!=null&&!Xe(g))throw new u("invalid_operation","Row aisleSeats must be one of start, end, both, none (or null to unmark)");let I=w=>JSON.stringify({origin:w.origin,rotation:w.rotation,curve:w.curve,seatCount:w.seatCount,seatSpacing:w.seatSpacing,path:w.path??null}),y=!1;for(let w of r){let S=JSON.stringify(w),m=I(w),v=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?V(w):null;if(Object.assign(w,structuredClone(h)),w.overrides&&t.patch.seatCount!==void 0&&(w.overrides=w.overrides.filter(C=>C.index<w.seatCount),w.overrides.length||(w.overrides=void 0)),v){let C=V(w);w.origin={x:w.origin.x+v.x-C.x,y:w.origin.y+v.y-C.y}}if(JSON.stringify(w)!==S&&(y=!0),I(w)!==m&&(delete w.arcFanGeneration,delete w.rowBlockGeneration),i!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=De(w.labelPresentation,i);P?w.labelPresentation=P:delete w.labelPresentation,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(s!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(c!==void 0||l!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};c===null?delete P.rotation:c!==void 0&&(P.rotation=c),l!==void 0&&(P.style=l),w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(x!==void 0){let C=w.displayType;x?w.displayType=x:delete w.displayType,w.displayType!==C&&(y=!0)}if(g!==void 0){let C=w.aisleSeats;g===null?delete w.aisleSeats:w.aisleSeats=g,w.aisleSeats!==C&&(y=!0)}if(d!==void 0){let C=w.displayLabel;p?delete w.displayLabel:w.displayLabel=b.displayLabel,w.displayLabel!==C&&(y=!0)}}return{floorId:n.floorId,changed:y,rowIds:o}}var mu=3;function vn(e){return(e%360+360)%360}function pu(e){let t=e.rotation*fe;return{x:Math.cos(t),y:Math.sin(t)}}function yu(e,t){let n=Math.abs(vn(e-t));return n>180&&(n=360-n),n}function We(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Ra(e){let t=0,n=0;for(let r of e){let a=2*r.rotation*fe;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 wu(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=r=>({x:r.x+t,y:r.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 Ma(e,t){let n=Ra(e),o={x:-n.y,y:n.x},r=V(e[0]),a=e.map(c=>({row:c,coord:We(V(c),r,o)})).sort((c,l)=>c.coord-l.coord),i=a[0].coord,s=!1;return a.forEach((c,l)=>{let d=i+l*t-c.coord;Math.abs(d)>1e-6&&(wu(c.row,o.x*d,o.y*d),delete c.row.arcFanGeneration,delete c.row.rowBlockGeneration,s=!0)}),s}function xu(e,t){let n={x:-t.y,y:t.x},o=V(e[0]),r=e.map(i=>We(V(i),o,n)).sort((i,s)=>i-s);if(r.length<2)return 28;let a=(r[r.length-1]-r[0])/(r.length-1);return a>.5?a:28}function Su(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Q(e),n=t[0],o=t[t.length-1],r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,i/(e.seatCount-1))),i>1e-6&&(e.rotation=vn(Math.atan2(a,r)/fe)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function Iu(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let r=`${t}${o}`.slice(0,80);if(!n.has(r))return r}return`${t}-${Date.now().toString(36)}`}function vu(e,t){let n=O(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 r=o.map(m=>n.objects.find(v=>v.type==="row"&&v.id===m)),a=o.filter((m,v)=>!r[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 i=r,s=i.filter(m=>m.path||m.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(m=>m.id)});let c=i[0],l=i.find(m=>yu(m.rotation,c.rotation)>mu);if(l)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[c.id,l.id]});let d=pu(c),f={x:-d.y,y:d.x},g=Math.max(8,c.seatSpacing*.6),h=i.find(m=>Math.abs(We(m.origin,c.origin,f))>g);if(h){let m=Math.round(Math.abs(We(h.origin,c.origin,f)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${m} units from the first.`,{rowIds:[c.id,h.id]})}let b=i.slice().sort((m,v)=>We(m.origin,c.origin,d)-We(v.origin,c.origin,d)),p=b.reduce((m,v)=>m+v.seatCount,0);if(p>300)throw new u("invalid_operation",`A merged row would have ${p} seats, over the 300-seat row limit. Merge fewer rows.`);let x=b[0];Ji(b,x);let I=[],y=0;for(let m of b){if(m.overrides)for(let v of m.overrides)I.push({...structuredClone(v),index:v.index+y});y+=m.seatCount}x.seatCount=p,x.curve=0,delete x.path,I.length?x.overrides=I:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let w=b.slice(1).map(m=>m.id),S=new Set(w);for(let m=n.objects.length-1;m>=0;m--)S.has(n.objects[m].id)&&n.objects.splice(m,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:w,seatCount:p}}function Do(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="row"&&h.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 r=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>r-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${r-1} (the seat where the second row begins)`);let i=Q(o),s=r>1?o.curve/(r-1):0,c=r-a,l={type:"row",id:E(e,"r",t.idFactory,new Set),label:Iu(n.objects,o.label),origin:{...i[a]},rotation:vn(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 h=structuredClone(o.labelPresentation);delete h.position,l.labelPresentation=h}let d=[],f=[];if(o.overrides)for(let h of o.overrides)h.index<a?d.push(structuredClone(h)):f.push({...structuredClone(h),index:h.index-a});Yi(o,o,l),o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,f.length&&(l.overrides=f);let g=n.objects.indexOf(o);return n.objects.splice(g+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:c,newLabel:l.label}}function Cu(e,t){let n=O(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 r=o.map(s=>n.objects.find(c=>c.type==="row"&&c.id===s)),a=o.filter((s,c)=>!r[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 i=Ma(r,t.gap);return{floorId:n.floorId,changed:i,rowIds:o,gap:t.gap}}function Ou(e,t){let n=O(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 r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r,s=()=>JSON.stringify(i.map(g=>[g.origin,g.rotation,g.curve,g.path??null,g.seatSpacing])),c=s();for(let g of i)Su(g);let l=Ra(i),d=vn(Math.atan2(l.y,l.x)/fe);for(let g of i)g.rotation=d;let f=xu(i,l);return Ma(i,f),{floorId:n.floorId,changed:s()!==c,rowIds:o,gap:f}}function Pu(e,t){let n=O(e,t.floorId).objects.find(c=>c.type==="row"&&c.id===t.rowId);if(n?.segmentedRow)throw new u("invalid_operation","This row already has parts: choose Aisle on the join between them.",{rowIds:[t.rowId]});let o=n?.displayLabel??n?.label,r=Do(e,t),a=At(e,{floorId:r.floorId,rowIds:[r.rowId,r.newRowId],boundaries:["break"],...o?{displayLabel:o}:{},idFactory:t.idFactory}),{objects:i}=O(e,r.floorId),s=[r.rowId,r.newRowId].map(c=>i.find(l=>l.type==="row"&&l.id===c));return Pt(s,1,"break"),{floorId:r.floorId,rowId:r.rowId,newRowId:r.newRowId,groupId:a.groupId}}var On=bs(require("polygon-clipping"),1),_a=100,ka=512,Go=8192,Ga=64,La=1e7,U=1e-7;function $a(e,t){return Math.abs(e.x-t.x)<=U&&Math.abs(e.y-t.y)<=U}function Ba(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&$a(t[0],t[t.length-1]);)t.pop();return t}function _t(e,t,n){let o=ce(t,n,e);return Math.abs(o)>U?!1:e.x>=Math.min(t.x,n.x)-U&&e.x<=Math.max(t.x,n.x)+U&&e.y>=Math.min(t.y,n.y)-U&&e.y<=Math.max(t.y,n.y)+U}function Ka(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return(r>U&&a<-U||r<-U&&a>U)&&(i>U&&s<-U||i<-U&&s>U)?!0:Math.abs(r)<=U&&_t(n,e,t)||Math.abs(a)<=U&&_t(o,e,t)||Math.abs(i)<=U&&_t(e,n,o)||Math.abs(s)<=U&&_t(t,n,o)}function Au(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 r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&Ka(e[t],e[n],e[o],e[r]))return!0}}return!1}function Ea(e,t){return e.some((n,o)=>t.some((r,a)=>Ka(n,e[(o+1)%e.length],r,t[(a+1)%t.length])))}function $o(e,t){return!t.some((n,o)=>_t(e,n,t[(o+1)%t.length]))&&H(e,t,void 0)}function Pn(e,t,n){let o=Ba(e);if(o.length<3||o.length>ka||o.some((r,a)=>!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>La||Math.abs(r.y)>La||$a(r,o[(a+1)%o.length]))||Math.abs(nt(o))<=U||Au(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${ka} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Ru(e){let t=Pn(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Ga)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(r=>Pn(r,"cutout",e.id));for(let r=0;r<o.length;r+=1){let a=o[r];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=>$o(s,t))||Ea(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:r});for(let s=r+1;s<o.length;s+=1)if(Ea(a,o[s])||$o(a[0],o[s])||$o(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:r})}return{outer:t,holes:o}}function Cn(e){return e.map(t=>[t.x,t.y])}function Ta(e){return Ba(e.map(([t,n])=>({x:t,y:n})))}function ja(e){return Math.abs(e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n[0]*r[1]-r[0]*n[1]},0))/2}function Mu(e){return e.reduce((t,n)=>t+(ja(n[0]??[])-n.slice(1).reduce((o,r)=>o+ja(r),0)),0)}function Bo(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Bo).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Bo(t[n])}`).join(",")}}`}function Fa(e,t,n){let o=e[t];if(o===void 0)return null;let r=o.normalize("NFKC").trim();if(!r||r!==o||r.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 r}function Na(e){return Bo({categoryKey:e.categoryKey,displayLabel:Fa(e,"displayLabel",80),displayType:Fa(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function Da(e,t){let n=Math.min(...e.points.map(r=>r.y)),o=Math.min(...e.points.map(r=>r.x));return[n,o,t]}function _u(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function za(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.gaAreaIds)];if(r.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(r.length>_a)throw new u("invalid_operation",`Join Areas supports at most ${_a} areas at once`);let a=r.map(A=>o.objects.find(L=>L.type==="gaArea"&&L.id===A)),i=r.filter((A,L)=>!a[L]);if(i.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:i});let s=a,c=s.find(A=>Ge(A));if(c)throw new u("invalid_operation",`"${c.displayLabel??c.label}" is sold as one box. Only areas sold per person can be joined; switch it back to Standing first.`,{gaAreaId:c.id});D(e,s[0].categoryKey);let l=Na(s[0]),d=s.find(A=>Na(A)!==l);if(d)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,d.id]});let f=wt(e).objectToSection,g=f.get(s[0].id)??"__ungrouped__",h=s.find(A=>(f.get(A.id)??"__ungrouped__")!==g);if(h)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,h.id],sectionIds:[g,f.get(h.id)??"__ungrouped__"]});let b=s.reduce((A,L)=>{if(!Number.isInteger(L.capacity)||L.capacity<1||L.capacity>ne)throw new u("invalid_operation",`GA area ${L.id} has invalid capacity`,{gaAreaId:L.id});return A+L.capacity},0);if(b>ne)throw new u("invalid_operation",`Joined GA capacity would be ${b}, over the ${ne}-unit area limit`,{capacity:b});let p=te(e).reduce((A,L)=>A+Pe(L),0),x=n.maxInventory??1e5;if(p>x)throw new u("invalid_operation",`Chart inventory exceeds the ${x}-unit publication limit`,{inventory:p});let I=s.map(Ru),y=I.reduce((A,L)=>A+L.outer.length+L.holes.reduce(($,W)=>$+W.length,0),0);if(y>Go)throw new u("invalid_operation",`Join Areas supports at most ${Go} source vertices`,{vertexCount:y});let w;try{let A=I.map(W=>[Cn(W.outer)]);if(w=On.default.union(A[0],...A.slice(1)),w.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:w.length});let L=I.flatMap(W=>W.holes.map(Ee=>[Cn(Ee)]));L.length&&(w=On.default.difference(w,...L));let $=I.findIndex(W=>{let Ee=[Cn(W.outer),...W.holes.map(Cn)];return Mu(On.default.intersection(Ee,w))<=U});if($>=0)throw new u("invalid_operation",`GA area ${s[$].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[$].id})}catch(A){throw A instanceof u?A:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:A instanceof Error?A.message:"polygon_union_failed"})}if(w.length!==1||!w[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:w.length});let S=Ta(w[0][0]),m=w[0].slice(1).map(Ta),v=S.length+m.reduce((A,L)=>A+L.length,0);if(m.length>Ga||v>Go)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:m.length,vertexCount:v});Pn(S,"outline",s[0].id),m.forEach(A=>Pn(A,"cutout",s[0].id));let C=new Map(o.objects.map((A,L)=>[A.id,L])),P=s.slice().sort((A,L)=>_u(Da(A,C.get(A.id)??Number.MAX_SAFE_INTEGER),Da(L,C.get(L.id)??Number.MAX_SAFE_INTEGER))),j=P[0],Y=structuredClone(e),J=O(Y,o.floorId),R=J.objects.find(A=>A.type==="gaArea"&&A.id===j.id);R.points=structuredClone(S),m.length?R.holes=structuredClone(m):delete R.holes;let oe=new Set(P.slice(1).map(A=>A.id));for(let A=J.objects.length-1;A>=0;A-=1)oe.has(J.objects[A].id)&&J.objects.splice(A,1);let M=wt(Y).objectToSection.get(j.id)??"__ungrouped__";if(M!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:j.id,beforeSectionId:g,afterSectionId:M});let re=[],se=new Set;for(let A of P){if(!Jn(A))throw new u("invalid_operation",`GA area ${A.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:A.id});let L=le(A);if(L.length!==A.capacity||L.some($=>se.has($)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:A.id});L.forEach($=>se.add($)),re.push(...on(A))}if(re.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let Ce=new Set(s.map(A=>A.id));for(let A of te(e).filter(L=>L.type==="gaArea"&&!Ce.has(L.id))){let L=le(A).find($=>se.has($));if(L)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:L,gaAreaId:A.id})}let Nt=P.slice(1).map(A=>A.id);return{floorId:o.floorId,areaId:j.id,survivorLabel:j.label,removedAreaIds:Nt,sourceAreaCount:P.length,capacity:b,inventorySegmentCount:re.length,outerVertexCount:S.length,holeCount:m.length,sectionId:g,points:S,...m.length?{holes:m}:{},segments:re}}function ku(e,t,n={}){let{segments:o,...r}=za(e,t,n);return r}function Lu(e,t,n={}){let o=za(e,t,n),r=O(e,o.floorId),a=r.objects.find(d=>d.type==="gaArea"&&d.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes;let i=r.objects.filter(d=>d.type==="gaArea"&&(d.id===o.areaId||o.removedAreaIds.includes(d.id))).reduce((d,f)=>d+(f.wheelchairPlaces??0),0);a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments),i>0&&(a.wheelchairPlaces=Math.min(i,o.capacity));let s=new Set(o.removedAreaIds);for(let d=r.objects.length-1;d>=0;d-=1)s.has(r.objects[d].id)&&r.objects.splice(d,1);let{segments:c,...l}=o;return{...l,changed:!0}}function Eu(e,t){let n=O(e,t.floorId),o=n.objects.find(c=>c.type==="shape"&&c.id===t.shapeId);if(!o)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(o.role==="stage")throw new u("invalid_operation","A stage keeps its generated outline; turn it back into a shape first");if(o.kind==="polygon")return{floorId:n.floorId,changed:!1,shapeId:o.id};if(o.kind!=="rect"||o.x==null||o.y==null||o.width==null||o.height==null||![o.x,o.y,o.width,o.height].every(Number.isFinite)||o.width<=0||o.height<=0)throw new u("invalid_operation","Only a rectangle can become a custom outline");let{x:r,y:a,width:i,height:s}=o;return o.points=[{x:r,y:a},{x:r+i,y:a},{x:r+i,y:a+s},{x:r,y:a+s}],o.kind="polygon",delete o.x,delete o.y,delete o.width,delete o.height,delete o.cornerRadius,ht(o),{floorId:n.floorId,changed:!0,shapeId:o.id}}function Tu(e,t){let n=O(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let r=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!r[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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one shape change is required");if(i.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(i.label!==null){if(i.label=i.label.normalize("NFKC").trim(),!i.label)i.label=null;else if(i.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(i.labelStyle!==void 0){let l=r.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(i.labelStyle.size!==void 0&&i.labelStyle.size!==null&&(!Number.isFinite(i.labelStyle.size)||i.labelStyle.size<Fe||i.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${Fe} to ${72}`);if(i.labelStyle.color!==void 0&&i.labelStyle.color!==null&&(i.labelStyle.color=N(i.labelStyle.color,"Shape label color")),i.labelStyle.fontFamily!==void 0&&i.labelStyle.fontFamily!==null&&(i.labelStyle.fontFamily=i.labelStyle.fontFamily.normalize("NFKC").trim(),!i.labelStyle.fontFamily||i.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");if(i.labelStyle.direction!==void 0&&i.labelStyle.direction!==null&&!Tr.includes(i.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");for(let d of["bold","italic","underline"]){let f=i.labelStyle[d];if(f!=null&&typeof f!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(i.fill!==void 0&&i.fill!==null&&(i.fill=N(i.fill,"Shape fill")),i.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(i.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(i.stroke!==void 0&&i.stroke!==null){if(!Number.isFinite(i.stroke.width)||i.stroke.width<.5||i.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");i.stroke={color:N(i.stroke.color,"Shape stroke"),width:i.stroke.width}}if(i.cornerRadius!==void 0&&i.cornerRadius!==null&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(i.opacity!==void 0&&i.opacity!==null&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(i.heightM!==void 0&&i.heightM!==null&&(!Number.isFinite(i.heightM)||i.heightM<.05||i.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(i.rotation!==void 0&&i.rotation!==null){if(!Number.isFinite(i.rotation))throw new u("invalid_operation","Shape rotation must be a finite number of degrees");i.rotation=Ie("shape",i.rotation)}if(i.edgeCurvature!==void 0){if(o.length!==1)throw new u("invalid_operation","edgeCurvature can be changed only for one shape at a time");let l=r[0];if((i.kind??l.kind)!=="polygon"||(l.points?.length??0)<3)throw new u("invalid_operation","Curved sides apply only to custom outline (polygon) shapes",{shapeIds:[l.id]});if(i.edgeCurvature!==null){if(!Array.isArray(i.edgeCurvature)||i.edgeCurvature.some(f=>!Number.isFinite(f)||f<-100||f>100))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");if(i.edgeCurvature.length&&i.edgeCurvature.length!==l.points.length)throw new u("invalid_operation",`edgeCurvature needs one value per side: this shape has ${l.points.length} sides`,{shapeIds:[l.id]});i.edgeCurvature.some(f=>Math.abs(f)>.5)||(i.edgeCurvature=null)}let d={kind:"polygon",points:l.points,edgeCurvature:i.edgeCurvature??void 0,holes:l.holes};sr(d).forEach((f,g)=>{if(!cr(d,f))throw new u("invalid_operation",`That curve would cross cut-out ${g+1}. Move the cut-out or use less curve.`,{shapeIds:[l.id]})})}if(i.eventConfigurationIds!==void 0&&i.eventConfigurationIds!==null){let l=i.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");i.eventConfigurationIds=l}if(i.lineCap!==void 0&&i.lineCap!==null&&!Wi.includes(i.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(i.lineJoin!==void 0&&i.lineJoin!==null&&!Zi.includes(i.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",i.startEnding],["endEnding",i.endEnding]])if(d!=null&&!Qi.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(i.lineCap!=null||i.lineJoin!=null||i.startEnding!=null||i.endEnding!=null){let l=r.filter(d=>!So(i.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 r){let d=JSON.stringify(l);if(i.label===null?delete l.label:i.label!==void 0&&(l.label=i.label),i.labelStyle!==void 0){let f={...l.labelStyle};i.labelStyle.size===null?delete f.size:i.labelStyle.size!==void 0&&(f.size=i.labelStyle.size),i.labelStyle.color===null?delete f.color:i.labelStyle.color!==void 0&&(f.color=i.labelStyle.color),i.labelStyle.fontFamily===null?delete f.fontFamily:i.labelStyle.fontFamily!==void 0&&(f.fontFamily=i.labelStyle.fontFamily),i.labelStyle.bold===null?delete f.bold:i.labelStyle.bold!==void 0&&(f.bold=i.labelStyle.bold),i.labelStyle.italic===null||i.labelStyle.italic===!1?delete f.italic:i.labelStyle.italic===!0&&(f.italic=!0),i.labelStyle.underline===null||i.labelStyle.underline===!1?delete f.underline:i.labelStyle.underline===!0&&(f.underline=!0),i.labelStyle.direction===null||i.labelStyle.direction==="horizontal"?delete f.direction:i.labelStyle.direction!==void 0&&(f.direction=i.labelStyle.direction),Object.keys(f).length?l.labelStyle=f:delete l.labelStyle}if(i.fill===null?delete l.fill:i.fill!==void 0&&(l.fill=i.fill),i.kind!==void 0&&(l.kind=i.kind,So(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),i.stroke===null?delete l.stroke:i.stroke!==void 0&&(l.stroke={...i.stroke}),i.opacity===null?delete l.opacity:i.opacity!==void 0&&(l.opacity=i.opacity),i.heightM===null?delete l.heightM:i.heightM!==void 0&&(l.heightM=i.heightM),i.rotation===null||i.rotation===0?delete l.rotation:i.rotation!==void 0&&(l.rotation=i.rotation),i.edgeCurvature===null?delete l.edgeCurvature:i.edgeCurvature!==void 0&&(l.edgeCurvature=[...i.edgeCurvature]),i.kind!==void 0&&i.kind!=="polygon"&&(delete l.edgeCurvature,delete l.holes),i.eventConfigurationIds===null?delete l.eventConfigurationIds:i.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...i.eventConfigurationIds]),i.lineCap===null?delete l.lineCap:i.lineCap!==void 0&&(l.lineCap=i.lineCap),i.lineJoin===null?delete l.lineJoin:i.lineJoin!==void 0&&(l.lineJoin=i.lineJoin),i.startEnding===null?delete l.startEnding:i.startEnding!==void 0&&(l.startEnding=i.startEnding),i.endEnding===null?delete l.endEnding:i.endEnding!==void 0&&(l.endEnding=i.endEnding),i.cornerRadius===null)delete l.cornerRadius;else if(i.cornerRadius!==void 0){let f=Math.min(l.width??1/0,l.height??1/0),g=Number.isFinite(f)?f/2:i.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(i.cornerRadius,g)):i.cornerRadius}JSON.stringify(l)!==d&&(ht(l),c=!0)}return{floorId:n.floorId,changed:c,shapeIds:o}}function Ha(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),r=Math.min(...n),a=Math.max(...n),i=Math.min(...o),s=Math.max(...o),c=Math.max(1,a-r),l=Math.max(1,s-i);return{cx:r+c/2,cy:i+l/2,width:c,height:l}}function ju(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(i=>i.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let r=t.updates.map(i=>{if(![i.width,i.height].every(Number.isFinite)||i.width<8||i.height<8||i.width>1e4||i.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:i.shapeId});let s=n.objects.find(l=>l.type==="shape"&&l.id===i.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${i.shapeId}`,{shapeId:i.shapeId});let c=s.role==="stage"?Ha(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let l=s.points??[];if(l.length<3||l.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=l.map(x=>x.x),f=l.map(x=>x.y),g=Math.min(...d),h=Math.max(...d),b=Math.min(...f),p=Math.max(...f);return{cx:(g+h)/2,cy:(b+p)/2,width:Math.max(1,h-g),height:Math.max(1,p-b)}})();return{shape:s,update:i,box:c}}),a=!1;for(let{shape:i,update:s,box:c}of r)if(!(Math.abs(c.width-s.width)<1e-9&&Math.abs(c.height-s.height)<1e-9)){if(i.kind==="rect"||i.kind==="ellipse")i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height;else{let l=s.width/c.width,d=s.height/c.height,f=g=>({x:c.cx+(g.x-c.cx)*l,y:c.cy+(g.y-c.cy)*d});i.points=(i.points??[]).map(f),i.holes&&(i.holes=i.holes.map(g=>g.map(f))),(i.x!=null||i.y!=null||i.width!=null||i.height!=null||i.role==="stage")&&(i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:r.map(({shape:i,update:s})=>({id:i.id,width:s.width,height:s.height}))}}function Fu(e,t){let n=O(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 r=new Set(mr.map(s=>s.key)),a=t.updates.map(s=>{if(!r.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:Ha(c)}}),i=!1;for(let s of a)s.box&&(s.shape.points=$n({kind:s.stageKind,...s.box}),s.shape.kind="polygon",delete s.shape.edgeCurvature,delete s.shape.holes,s.shape.stageKind=s.stageKind,i=!0);return{floorId:n.floorId,changed:i,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Du(e){return[...Ho(e)].map(([t,n])=>({key:t,...n}))}function Gu(e){if(!Array.isArray(e))return Ho(e);let t=new Map;for(let{key:n,target:o,evidence:r}of e)t.set(n,{target:o,evidence:r});return t}function Ho(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of T(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let r=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(r,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${r}: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(`${r}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function An(e){return Array.isArray(e)?e.map(An):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,An(n)]))}function $u(e,t){return JSON.stringify(An(e))===JSON.stringify(An(t))}function Ko(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Bu(e){return e?e.status==="retracted"?"retract":Ko(e)?"approve":"set":"clear"}function Va(e,t){let n=Gu(e),o=Ho(t),r=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let i of r){let s=n.get(i),c=o.get(i);if(s&&c&&$u(s.evidence,c.evidence))continue;let l=c?.target??s?.target;l&&a.push({...l,operation:Bu(c?.evidence),...s?{before:s.evidence}:{},...c?{after:c.evidence}:{}})}return a}function Ku(e,t){return Va(e,t).some(n=>Ko(n.before)||Ko(n.after))}var zu=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Uu=new Set(["generated","geometry-verified","configuration-verified"]),Hu=new Set(["none","comparable-build-reference","actual-build-checked"]),Vu=new Set(["clear","partial","obstructed"]);function zo(e){return e.toISOString().slice(0,10)}function Uo(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function Qe(e,t,n){if(!Uo(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function Ze(e,t,n){if(e!==void 0)return Qe(e,t,n)}function Rn(e,t,n){let o=n?[O(e,n)]:T(e).map(r=>({floorId:r.id,objects:r.objects}));for(let r of o){let a=r.objects.find(i=>i.id===t);if(a)return{floorId:r.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function Xa(e,t){let n=T(e),o=t?n.find(r=>r.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function kt(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return Xa(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=Rn(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(r=>r.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=Rn(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 Mn(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let r=Xa(e,t.floorId);return n?r.confidenceEvidence=n:delete r.confidenceEvidence,{floorId:r.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let r=Rn(e,t.objectId,t.floorId);return No(e,{floorId:r.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:r.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=Rn(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 Xu(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!Uo(e.label,80)||!Uo(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(!Vu.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>Qe(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 qa(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(!zu.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Uu.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Hu.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=Ze(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 r=e.limitations?.map(f=>Qe(f,160,"limitation"));if(r&&r.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=Ze(e.assessedAt,40,"assessedAt")??zo(t),i=Date.parse(a);if(!Number.isFinite(i))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=Ze(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:zo(new Date(i+365*24*60*60*1e3))),c=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(c)||c<i||c>i+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=Ze(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=Ze(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:Qe(e.evidenceId,120,"evidenceId"),modelVersion:Qe(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}:{},...d?{sourceLabel:e.sourceLabel}:{},...r?.length?{limitations:r}:{},...e.modeledTarget?{modeledTarget:Xu(e.modeledTarget)}:{}}}function et(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 qu(e,t){let n=qa(t.evidence,t.now),o=JSON.stringify(kt(e,t)??null),r=Mn(e,t,n),a=JSON.stringify(kt(e,t)??null);return et(t,{changed:o!==a,...r,evidenceId:n.evidenceId,status:"draft"})}function Yu(e,t){let n=kt(e,t);if(!n)return et(t,{changed:!1});let o=Mn(e,t,void 0);return et(t,{changed:!0,...o,evidenceId:n.evidenceId})}function Ju(e,t){let n=kt(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=Qe(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),r=Ze(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!r)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 i={...n,status:"approved",approvedByRole:o,assessedAt:zo(t.now??new Date),...r?{eventConfigurationId:r}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete i.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(i.basisSha256=s);let c=JSON.stringify(n),l=Mn(e,t,i);return et(t,{changed:c!==JSON.stringify(i),...l,evidenceId:i.evidenceId,status:"approved"})}function Wu(e,t){let n=kt(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 et(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let r=Mn(e,t,o);return et(t,{changed:!0,...r,evidenceId:n.evidenceId,status:"retracted"})}var Zu={width:960,height:600};function Qu(e,t,n=e){let o={...e,objects:t,floors:void 0,referenceImage:void 0,backgroundImage:Lr(n)},r=ue(o,{freeText:"exclude"}),{width:a,height:i}=Zu;return Math.min(a/Math.max(r.width,1e-6),i/Math.max(r.height,1e-6))}function ef(e,t){return!e.text.trim()||e.semanticKind==="icon"||e.labelImportance==="detail"||vr(e)?!1:!Xr(e.fontSize,t)}function Ya(e){let t=[],n=!!e.floors?.length;for(let o of T(e)){let r=o.objects.filter(i=>i.type==="text");if(!r.length)continue;let a=Qu(e,o.objects,n?o:e);for(let i of r)ef(i,a)&&t.push({floorId:o.id,text:i,renderedPx:i.fontSize*a})}return t}var _n=40,Ja=96,tf=48,Le=24;function Lt(e,t){let n=ue({...e,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"});return{x:n.x+_n,y:n.y+_n,width:Math.max(0,n.width-2*_n),height:Math.max(0,n.height-2*_n)}}function nf(e){if(!e.length)return null;let t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),o=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:o-t,height:r-n}}function of(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}var Vo=e=>e.type==="shape"&&e.role==="stage";function rf(e,t){let n=t.x-(e.x+e.width/2),o=t.y-(e.y+e.height/2);return Math.abs(n)>Math.abs(o)?{dx:n>=0?1:-1,dy:0}:{dx:0,dy:o>=0?1:-1}}function af(e,t){return t.dy===1?e.y+e.height:t.dy===-1?-e.y:t.dx===1?e.x+e.width:-e.x}function Xo(e,t){return t.dy===1?e.y:t.dy===-1?-(e.y+e.height):t.dx===1?e.x:-(e.x+e.width)}function kn(e,t){let n=me(e,t.floorId),o=nf(n.objects.filter(Vo).map(y=>Lt(n,y)));if(!o)return null;let r=rf(o,n.focalPoint),a=r.dy!==0?t.height:t.width,i=af(o,r),s=n.objects.filter(y=>!Vo(y)&&of(y)).map(y=>Lt(n,y)).filter(y=>Xo(y,r)>=i-1),c=s.length?Math.min(...s.map(y=>Xo(y,r))):1/0,l=Ja+a+tf,d=c-i,f=()=>{let y=i+Ja+a/2;return r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2}};if(!s.length)return{center:f(),movedBack:0};if(d>=a+2*Le){let y=i+d/2;return{center:r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2},movedBack:0}}if(t.makeRoom){let y=l-d,w=O(e,t.floorId);for(let S of w.objects)Vo(S)||Xo(Lt(n,S),r)<i-1||ve(S,r.dx*y,r.dy*y);return{center:f(),movedBack:y}}let g="No room between the stage and the seats, so it went beside the stage. Tell the user; moving seats to make room is done in the Designer.",h=t.width,b=t.height,p=o.x+o.width/2,x=o.y+o.height/2;if(r.dy!==0){let y=r.dy===1?Math.min(x,c-Le-b/2):Math.max(x,-c+Le+b/2);return{center:{x:o.x-Le-h/2,y},note:g,movedBack:0}}return{center:{x:r.dx===1?Math.min(p,c-Le-h/2):Math.max(p,-c+Le+h/2),y:o.y-Le-b/2},note:g,movedBack:0}}var Wa=40,Et=24;function sf(e,t,n){let{objects:o}=O(e,t),r=o.find(a=>a.id===n);if(!r)throw new u("object_not_found",`No object ${n} on this floor. Call get_chart for ids.`,{objectId:n});return r}function tt(e,t){if(!t.nearObjectId&&t.placement==="front"){let n=kn(e,{floorId:t.floorId,width:t.width,height:t.height,makeRoom:t.makeRoom});if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:Za(e,t)}}function cf(e,t){return tt(e,t).center}function Za(e,t){if(t.nearObjectId){let n=sf(e,t.floorId,t.nearObjectId),o=Lt(me(e,t.floorId),n),r=t.side??"rear";return r==="front"?{x:o.x+o.width/2,y:o.y-Et-t.height/2}:r==="left"?{x:o.x-Et-t.width/2,y:o.y+o.height/2}:r==="right"?{x:o.x+o.width+Et+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+Et+t.height/2}}if(t.placement==="center"){let n=ue(me(e,t.floorId),{freeText:"exclude"});return{x:n.x+n.width/2,y:n.y+n.height/2}}return ke(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}function Ln(e,t,n){if(e===void 0)return n;if(!Number.isFinite(e)||e<=0||e>400)throw new u("invalid_operation",`${t} must be between 0 and 400 metres`);return e*Wa}function qo(e,t){if(e===void 0)return;let n=e.trim();if(!n||n.length>80)throw new u("invalid_operation",`${t} must be 1 to 80 characters`);return n}function lf(e){return e.some(t=>t.type==="shape"&&t.role==="stage")}function df(e,t){let n=O(e,t.floorId),o=pr(t.kind),r=Ln(t.widthM,"widthM",o.width),a=Ln(t.depthM,"depthM",o.height),i=Za(e,{...t,placement:t.placement??"front",width:r,height:a}),s=qo(t.label,"label")??wr(t.kind),c=E(e,"stage",t.idFactory,new Set),l={...yr({kind:t.kind,cx:i.x,cy:i.y,width:r,height:a,label:s},c),x:i.x-r/2,y:i.y-a/2,width:r,height:a},d=lf(n.objects);if(n.objects.push(l),!d){let f={x:i.x,y:i.y+a/2+Et},g=T(e).find(h=>h.id===n.floorId);e.floors?.length&&g&&(g.focalPoint=f),(!e.floors?.length||e.floors[0]?.id===n.floorId)&&(e.focalPoint=f)}return{floorId:n.floorId,stageId:c,label:s,focalPointMoved:!d,createdIds:[c]}}function uf(e,t){let n=vt(t.role);if(!n)throw new u("invalid_operation",`Unknown landmark: ${t.role}`);let o=O(e,t.floorId),{center:r,note:a}=tt(e,{...t,width:n.width,height:n.height}),i=E(e,"decor",t.idFactory,new Set),s=Ci(t.role,r,i),c=qo(t.label,"label");return c&&s.label!==void 0&&(s.label=n.icon?`${n.icon} ${c}`:c),o.objects.push(s),{floorId:o.floorId,landmarkId:i,label:s.label??null,createdIds:[i],...a?{note:a}:{}}}var ff={small:16,medium:24,large:36};function En(e){if(e==="always")return"orientation";if(e==="close-up")return"detail"}var hf="#f7f8fb";function gf(e){let t=e.theme?.background??hf,n=e.theme?.textColor;return n&&sn(n,t)>=4.5?n:Hr(t,"#0b1220","#e8ecf4")}function bf(e,t){let n=t.text.trim();if(!n||n.length>120)throw new u("invalid_operation","text must be 1 to 120 characters");let o=O(e,t.floorId),r=ff[t.size??"medium"],a=Math.max(r,n.length*r*.56),i=r*1.2,{center:s,note:c}=tt(e,{...t,width:a,height:i}),l=E(e,"txt",t.idFactory,new Set),d={type:"text",id:l,text:n,position:{x:s.x-a/2,y:s.y-i/2},fontSize:r,rotation:0,color:t.color?N(t.color,"color"):gf(e),...t.bold?{bold:!0}:{},...En(t.showAt)?{labelImportance:En(t.showAt)}:{}};o.objects.push(d);let f=t.showAt===void 0&&Ya(e).some(h=>h.text.id===l)?'Buyers see this text only after zooming in. For a gate, entrance or anything they must see at once, set showAt "always" or size "large".':void 0,g=[c,f].filter(Boolean).join(" ");return{floorId:o.floorId,textId:l,createdIds:[l],...g?{note:g}:{}}}function mf(e,t){let n=di(t.iconKey);if(!n)throw new u("invalid_operation",`Unknown icon: ${t.iconKey}`);let o=O(e,t.floorId),r=28,{center:a,note:i}=tt(e,{...t,width:r,height:r}),s=E(e,"icon",t.idFactory,new Set),c={type:"text",id:s,semanticKind:"icon",iconKey:n.key,text:n.label,position:a,fontSize:r,rotation:0,...En(t.showAt)?{labelImportance:En(t.showAt)}:{}};return o.objects.push(c),{floorId:o.floorId,iconId:s,createdIds:[s],...i?{note:i}:{}}}var Qa="#4b5568";function pf(e,t){let n=qo(t.label,"label"),o=O(e,t.floorId),r=Ln(t.widthM,"widthM",0),a=Ln(t.depthM,"depthM",0),{center:i,note:s}=tt(e,{...t,width:r,height:a}),c=E(e,"shape",t.idFactory,new Set),l={type:"shape",id:c,kind:t.shape??"rect",x:i.x-r/2,y:i.y-a/2,width:r,height:a,fill:t.fill?N(t.fill,"fill"):Qa,...n?{label:n}:{},...t.shape!=="ellipse"?{cornerRadius:8}:{}};return o.objects.push(l),{floorId:o.floorId,areaId:c,createdIds:[c],...s?{note:s}:{}}}function yf(){return["bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"].map(e=>({role:e,label:vt(e)?.label??e}))}var wf=100,xf=300,_p=wf*xf;function es(e,t,n){if(n==="horizontal"||!t||![e.x,e.y,t.x,t.y].every(Number.isFinite))return 0;let o=e.x-t.x,r=e.y-t.y,a=Math.hypot(o,r);if(a<=1e-6)return 0;let i={x:r/a,y:-o/a},s=Math.atan2(i.y,i.x)*180/Math.PI;return Object.is(s,-0)?0:s}function Ft(e,t){if(t.placement==="front"){let n=kn(e,t);if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:ke(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}}var os={straight:0,gentle:15,medium:30,strong:45},Sf=24,If=28,vf=48;function Cf(e,t){let n=t.blocks??1;if(!Number.isInteger(n)||n<1||n>8)throw new u("invalid_operation","blocks must be a whole number from 1 to 8");if(t.sectionLabels&&t.sectionLabels.length!==n)throw new u("invalid_operation",`Give one section name per block (${n})`);if(t.blockSeats&&t.blockSeats.length!==n)throw new u("invalid_operation",`Give one seat count per block (${n})`);let o=I=>t.blockSeats?.[I]??t.seatsPerRow,r=I=>Math.max(24,(I-1)*Sf),a=r(t.seatsPerRow),i=Math.max(28,(t.rowCount-1)*If),s=t.aisleWidth??vf,c=t.placement??"auto",l=os[t.curveStyle??"straight"],d={floorId:"",rowIds:[],sectionIds:[],createdIds:[]},f=(I,y,w)=>{let S=Ao(e,{floorId:t.floorId,origin:I,rowCount:t.rowCount,seatsPerRow:o(w),categoryKey:t.categoryKey,curve:l,...t.blockStyle?{style:t.blockStyle}:{},rotation:y,sectionLabel:t.sectionLabels?.[w],idFactory:t.idFactory});d.floorId=S.floorId,d.rowIds.push(...S.rowIds),S.sectionId&&d.sectionIds.push(S.sectionId),d.createdIds.push(...S.createdIds)};if(n===1&&c==="front"){let I=Ft(e,{floorId:t.floorId,width:a,height:i,placement:c,makeRoom:t.makeRoom});return I.note&&(d.note=I.note),f({x:I.center.x-a/2,y:I.center.y-i/2},0,0),d}if(n===1){let I=ke(e,{floorId:t.floorId,width:a,height:i,placement:c}),y=es(I,e.focalPoint,t.orientation??"horizontal"),w=y*Math.PI/180,S=Math.abs(a*Math.cos(w))+Math.abs(i*Math.sin(w)),m=Math.abs(a*Math.sin(w))+Math.abs(i*Math.cos(w)),v=y===0?I:ke(e,{floorId:t.floorId,width:S,height:m,placement:c});return f({x:v.x-a/2,y:v.y-i/2},y,0),d}let g=Array.from({length:n},(I,y)=>r(o(y))),h=g.reduce((I,y)=>I+y,0)+(n-1)*s,b=Ft(e,{floorId:t.floorId,width:h,height:i,placement:c,makeRoom:t.makeRoom});b.note&&(d.note=b.note);let p=b.center,x=p.x-h/2;for(let I=0;I<n;I+=1)f({x,y:p.y-i/2},0,I),x+=g[I]+s;return d}function Of(e,t){return t===1?[e]:t===2?[`${e} Left`,`${e} Right`]:t===3?[`${e} Left`,`${e} Centre`,`${e} Right`]:Array.from({length:t},(n,o)=>`${e} ${o+1}`)}var Pf=155,Af=150,ts=110;function Rf(e,t){let n=(t.tableColumns-1)*Pf+ts,o=(t.tableRows-1)*Af+ts,{center:r,note:a}=Ft(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=Mo(e,{floorId:t.floorId,center:r,tableRows:t.tableRows,tableColumns:t.tableColumns,seatsPerTable:t.seatsPerTable??8,shape:t.shape??"round",categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}function Mf(e,t){let n=Sn(t.capacity),{center:o,note:r}=Ft(e,{floorId:t.floorId,...n,placement:t.placement,makeRoom:t.makeRoom}),a=Ro(e,{floorId:t.floorId,center:o,capacity:t.capacity,categoryKey:t.categoryKey,...t.label===void 0?{}:{label:t.label},...t.displayLabel===void 0?{}:{displayLabel:t.displayLabel},idFactory:t.idFactory});return r?{...a,note:r}:a}var _f=88,kf=82,Lf=62,Ef=52;function Tf(e,t){let n=(t.boothColumns-1)*_f+Lf,o=(t.boothRows-1)*kf+Ef,{center:r,note:a}=Ft(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=_o(e,{floorId:t.floorId,center:r,boothRows:t.boothRows,boothColumns:t.boothColumns,categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}var jf=40,rs=30,jt=42,Tt=48;function is(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}function Yo(e,t){return ue({...e,floors:void 0,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"})}function Ff(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x,y:e.y+e.height},{x:e.x+e.width,y:e.y+e.height}]}function as(e,t,n){let o=T(e),r=t?o.find(b=>b.id===t):o[0];if(!r)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});let a=r.focalPoint??e.focalPoint,i=r.objects.filter(is),s=0;if(i.length){let b=0,p=0;for(let x of i){let I=Yo(e,x);b+=I.x+I.width/2-a.x,p+=I.y+I.height/2-a.y}Math.hypot(b,p)>1&&(s=Math.atan2(b,p)*180/Math.PI)}let c=n/2,l={x:Math.sin(s*Math.PI/180),y:Math.cos(s*Math.PI/180)},d=0,f=[],g=i.some(b=>b.type==="row");for(let b of i){if(b.type==="section"&&g)continue;let p=b.type==="row"?Q(b):Ff(Yo(e,b)),x=b.type==="row"?b.seatSpacing/2:0;for(let I of p){let y=I.x-a.x,w=I.y-a.y,S=Math.atan2(y,w)*180/Math.PI;if(Math.abs((S-s+540)%360-180)>c+10)continue;let v=Math.hypot(y,w)+x;d=Math.max(d,v),f.push({radius:v,depth:y*l.x+w*l.y+x})}}let h=b=>{let p=Math.cos(b/2*Math.PI/180);return p<.2||!f.length?0:(Math.max(...f.map(x=>x.depth))+jt)/p};return{center:a,bearing:s,occupiedRadius:d,floorId:r.id,clearRadius:h}}var ss=100;function ns(e,t,n){return e===void 0||n<=0?ss:Math.min(180,Math.max(20,Math.round(cs(e,t)/n*(180/Math.PI))))}function cs(e,t){let n=t==="two"?2:t==="center"?1:0;return e*rs+n*Tt}function Nf(e,t,n,o){let r=[],a=o+jt-t.occupiedRadius;if(t.occupiedRadius<=0||a<=0)return r;let i=n/2+10;for(let s of O(e,t.floorId).objects){if(is(s)||s.type==="shape"&&s.role==="stage")continue;let c=Yo(e,s),l=c.x+c.width/2-t.center.x,d=c.y+c.height/2-t.center.y,f=Math.hypot(l,d);if(f<=t.occupiedRadius)continue;let g=Math.atan2(l,d)*180/Math.PI;Math.abs((g-t.bearing+540)%360-180)>i||(ve(s,l/f*a,d/f*a),r.push(s.id))}return r}function Df(e,t){let n=as(e,t.floorId,t.spreadDegrees??ss),o=Math.max((t.firstRowDistanceM??4)*jf,n.occupiedRadius>0?n.occupiedRadius+jt+Tt:0),r=t.spreadDegrees??ns(t.seatsPerRow,t.aisles,o),a=t.spreadDegrees!==void 0&&t.seatsPerRow!==void 0?cs(t.seatsPerRow,t.aisles)/(t.spreadDegrees*Math.PI/180):0,i=Math.max(o,a,n.clearRadius(r)),s=t.spreadDegrees??ns(t.seatsPerRow,t.aisles,i),c=i+(t.rowCount-1)*jt,l=Nf(e,n,s,c);return{...Co(e,{floorId:n.floorId,center:n.center,innerRadius:i,rowCount:t.rowCount,rowGap:jt,startAngle:n.bearing-s/2,endAngle:n.bearing+s/2,seatPitch:rs,fit:t.seatsPerRow===void 0?"seat-pitch":"fixed-count",...t.seatsPerRow===void 0?{}:{seatsPerRow:t.seatsPerRow},facing:"inward",...t.aisles==="center"?{aisleGaps:{center:Tt}}:t.aisles==="two"?{aisleGaps:{left:Tt,right:Tt}}:{},categoryKey:t.categoryKey,...t.sectionLabel===void 0?{}:{sectionLabel:t.sectionLabel},idFactory:t.idFactory}),spreadDegrees:s,movedBackIds:l}}0&&(module.exports={AISLE_EMPTY_SEATS,COLORBLIND_SAFE_PALETTE,ChartOperationError,DECOR_UNITS_PER_METRE,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_ROUTE_NAME,DEFAULT_SECTION_CORNER_SMOOTHING,FIRST_CATEGORY_COLOURS,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,NAMED_AREA_FILL,ROUTE_STROKE,ROW_CURVE_DEGREES,addArcFanRows,addArea,addBookableGridArray,addBoothArray,addChartCategories,addChartCategory,addChartFloor,addChartZone,addCurvedRows,addGAArea,addGate,addIcon,addLandmark,addPlacedBoothArray,addPlacedGAArea,addPlacedRowBlocks,addPlacedTableArray,addRoute,addRowAisle,addRowBlock,addStage,addTableArray,addText,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,blockSectionLabels,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,convertShapeToOutline,countCoveredInventory,curvedRowsPlacement,decorPlacement,decorPlacementCenter,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,fitSegmentedRowJoin,gaAreaFootprint,gateShape,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,landmarkRoles,makeGate,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,releaseGateReferences,remapGateReferences,removeCategoryMovingInventory,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,routeShape,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,segmentedRowAisleTooNarrow,setConfidenceEvidence,setObjectEntrance,setRoute,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,uniqueCategoryLabel,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateGate,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
1
+ "use strict";var ps=Object.create;var Gt=Object.defineProperty;var ys=Object.getOwnPropertyDescriptor;var ws=Object.getOwnPropertyNames;var xs=Object.getPrototypeOf,Ss=Object.prototype.hasOwnProperty;var Is=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})},tr=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ws(t))!Ss.call(e,r)&&r!==n&&Gt(e,r,{get:()=>t[r],enumerable:!(o=ys(t,r))||o.enumerable});return e};var vs=(e,t,n)=>(n=e!=null?ps(xs(e)):{},tr(t||!e||!e.__esModule?Gt(n,"default",{value:e,enumerable:!0}):n,e)),Cs=e=>tr(Gt({},"__esModule",{value:!0}),e);var Yf={};Is(Yf,{AISLE_EMPTY_SEATS:()=>xa,COLORBLIND_SAFE_PALETTE:()=>Ie,ChartOperationError:()=>u,DECOR_UNITS_PER_METRE:()=>ss,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>Wn,DEFAULT_ROUTE_NAME:()=>ho,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Gn,FIRST_CATEGORY_COLOURS:()=>ua,MAX_BUYER_IMAGE_URL_LENGTH:()=>dc,MAX_FLOOR_BASE_HEIGHT_M:()=>nn,NAMED_AREA_FILL:()=>ls,ROUTE_STROKE:()=>fo,ROW_CURVE_DEGREES:()=>hs,addArcFanRows:()=>vn,addArea:()=>vf,addBookableGridArray:()=>gu,addBoothArray:()=>To,addChartCategories:()=>Md,addChartCategory:()=>wn,addChartFloor:()=>Dc,addChartZone:()=>Bc,addCurvedRows:()=>Xf,addGAArea:()=>Lo,addGate:()=>Cl,addIcon:()=>If,addLandmark:()=>pf,addPlacedBoothArray:()=>$f,addPlacedGAArea:()=>jf,addPlacedRowBlocks:()=>_f,addPlacedTableArray:()=>Tf,addRoute:()=>Ml,addRowAisle:()=>Lu,addRowBlock:()=>ko,addStage:()=>mf,addTableArray:()=>Eo,addText:()=>Sf,allocateFixedArcFanSeats:()=>Sn,applyPolygonHole:()=>Zl,applyReferenceScanRows:()=>uu,applySectionCornerSmoothing:()=>ad,applySectionEstimates:()=>sd,applySectionOutlineShaping:()=>na,applySectionRowFit:()=>Jl,approveConfidenceEvidence:()=>nf,arcFanInputForGroup:()=>pa,assignSectionInventoryCategory:()=>td,automaticPlacementCenter:()=>ke,blockSectionLabels:()=>kf,clearConfidenceEvidence:()=>tf,compactChartDoc:()=>Ac,compactRowOverrides:()=>jr,compactTableOverrides:()=>Fr,confidenceEvidenceChangeRequiresPublish:()=>qu,confidenceEvidenceChanges:()=>ns,confidenceEvidenceIndex:()=>Uu,confirmReferenceCategoryOutputColor:()=>bd,convertGeneratedSectionToPolygon:()=>nd,convertShapeToOutline:()=>Gu,countCoveredInventory:()=>po,curvedRowsPlacement:()=>bs,decorPlacement:()=>rt,decorPlacementCenter:()=>gf,detectSeatLabelRun:()=>Er,dropRedundantSeatOverrideFields:()=>Qt,familyCategoryLabel:()=>fa,fitSegmentedRowJoin:()=>Mt,gaAreaFootprint:()=>Cn,gateShape:()=>zi,groupRowsAsSegmented:()=>_t,insertSeatingBlock:()=>Hl,isSafeBuyerImageUrl:()=>Or,joinGAAreas:()=>Nu,landmarkRoles:()=>Cf,makeGate:()=>Pl,mergeRows:()=>Mu,mirrorFirstFloor:()=>Re,normalizeBuyerImageUrl:()=>we,normalizeDraftEvidence:()=>rs,parseSeatRefId:()=>pu,pickColorblindSafeCategoryColor:()=>da,planCreationCategory:()=>ha,previewArcFanRows:()=>Ao,previewBookableGridArray:()=>hu,previewGeneratedSectionPolygonConversion:()=>ea,previewJoinGAAreas:()=>Du,previewPolygonHole:()=>pn,previewRemovePolygonHole:()=>Wi,previewRowCubicPath:()=>Xi,previewSectionRowFit:()=>qi,reassignColorblindSafeCategoryColors:()=>gd,relabelChartRows:()=>Ul,releaseGateReferences:()=>bo,remapGateReferences:()=>Al,removeCategoryMovingInventory:()=>_d,removeChartCategory:()=>Oo,removeChartFloor:()=>$c,removeChartObjects:()=>Kl,removeChartZone:()=>zc,removePolygonHole:()=>Ql,renameChartFloor:()=>Nc,renameDirectSeatImportCategory:()=>dd,reorderChartCategories:()=>ud,replaceArcFanRows:()=>Nd,replaceRowBlock:()=>qd,resetSeatOverrides:()=>xu,resizeShapes:()=>Bu,resolveCreationCategory:()=>Pd,retractConfidenceEvidence:()=>of,roundBuyerCoordinates:()=>_c,routeShape:()=>Ui,seatRefId:()=>Lt,seatSemanticsSignature:()=>Xn,sectionInventorySelectionSummary:()=>Qi,segmentedRowAisleTooNarrow:()=>zd,setConfidenceEvidence:()=>ef,setObjectEntrance:()=>Rl,setRoute:()=>_l,setRowBlockSpacing:()=>_u,splitRow:()=>Ko,straightenAndSpaceRows:()=>ku,transformSectionBoundary:()=>od,transformSectionBoundaryObject:()=>ta,ungroupSegmentedRow:()=>Vd,uniqueCategoryLabel:()=>ga,updateBooths:()=>$l,updateCategoryDefinitions:()=>yn,updateChartFloorBaseHeight:()=>Gc,updateChartTheme:()=>Ed,updateChartZones:()=>Kc,updateGAAreas:()=>Bl,updateGate:()=>Ol,updateRowCubicPath:()=>Xl,updateRows:()=>Su,updateSeatOverrides:()=>Bo,updateSectionExactPath:()=>rd,updateSectionMetadata:()=>yo,updateSegmentedRow:()=>Xd,updateShapes:()=>$u,updateStageKinds:()=>Ku,updateTables:()=>Gl,updateTextObjects:()=>zl,updateViewFromSeatFallback:()=>Td});module.exports=Cs(Yf);var nr=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function Os(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/nr(e))),r=0;for(let a of n){if(!a.length){r+=1;continue}let i=0;for(let s of a.split(/\s+/)){let c=s.length;i&&i+1+c<=o?i+=1+c:(r+=Math.max(1,Math.ceil(c/o)),i=c%o)}}return Math.max(1,r)}function or(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*nr(e),r=e.width??o+t*2,a=Math.max(1,r-t*2),i=Os(e,a);return{width:r,height:i*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:i,padding:t}}var Ps=Math.PI/180;function Z(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Rs(e,t,n){let o=Math.cos(n),r=Math.sin(n),a=e.x-t.x,i=e.y-t.y;return{x:t.x+a*o-i*r,y:t.y+a*r+i*o}}function rr(e,t,n){return n?Rs(e,t,n*Ps):e}function Dn(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ir(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,a=3*n*t*t,i=t*t*t;return{x:o*e.start.x+r*e.control1.x+a*e.control2.x+i*e.end.x,y:o*e.start.y+r*e.control1.y+a*e.control2.y+i*e.end.y}}function $t(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[ir(e,.5)];let o=Array.from({length:n+1},(c,l)=>ir(e,l/n)),r=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;r[c]=r[c-1]+Math.hypot(l,d)}let a=r[r.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let i=[],s=1;for(let c=0;c<t;c+=1){let l=a*c/(t-1);for(;s<r.length-1&&r[s]<l;)s+=1;let d=r[s-1],f=r[s],g=f===d?0:(l-d)/(f-d);i.push({x:o[s-1].x+(o[s].x-o[s-1].x)*g,y:o[s-1].y+(o[s].y-o[s-1].y)*g})}return i}function it(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 at(e,t,n){return Math.max(t,Math.min(n,e))}function As(e){return at(e,0,1)}function ar(e){let t=As(e);return t*t*(3-2*t)}var Fe=Math.PI*2;function De(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Ms(e,t,n){let o=t-e;if(n){for(;o<0;)o+=Fe;for(;o>=Fe;)o-=Fe}else{for(;o>0;)o-=Fe;for(;o<=-Fe;)o+=Fe}return o}function Bt(e){if(e.version!==1||e.closed!==!0||!De(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||!De(n.end))return!1;if(n.kind==="line"){if(Z(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!De(n.control1)||!De(n.control2)||Z(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!De(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(Z(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(Z(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Z(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return Z(t,e.start)<=1e-4}function _s(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 st(e,t=2){if(!Bt(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let i=Math.atan2(r.y-a.center.y,r.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),c=Ms(i,s,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(c)*a.radius/n));for(let d=1;d<=l;d+=1){let f=i+c*d/l;o.push({x:a.center.x+Math.cos(f)*a.radius,y:a.center.y+Math.sin(f)*a.radius})}}else{let i=Z(r,a.control1)+Z(a.control1,a.control2)+Z(a.control2,a.end),s=Math.max(2,Math.ceil(i/n));for(let c=1;c<=s;c+=1)o.push(_s(r,a,c/s))}r=a.end}return Z(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function lr(e,t,n){return ct(e,r=>({x:r.x+t,y:r.y+n}))}function ct(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(r=>r.kind==="line"?{...r,end:t(r.end)}:r.kind==="arc"?{...r,center:t(r.center),radius:r.radius*Math.abs(n),clockwise:o?!r.clockwise:r.clockwise,end:t(r.end)}:{...r,control1:t(r.control1),control2:t(r.control2),end:t(r.end)})}}function dr(e){return e.map(t=>t===0?0:-t)}var Gn=45,Nn=150,ks=60;function Ls(e){let t=Gn/100;if(e<=t)return Nn;let n=Math.min(1,(e-t)/(1-t));return Nn-n*(Nn-ks)}var sr=.5523;function cr(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Es(e){let t=[],n=[];for(e.forEach((o,r)=>{De(o)&&(t.length&&cr(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&cr(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var Ts=.5,js=4/3;function Fs(e,t,n){let o=t.x-e.x,r=t.y-e.y,a=Math.hypot(o,r);if(a<=1e-9)return{kind:"line",end:{...t}};let i=-r/a,s=o/a,c=n*js;return{kind:"bezier",control1:{x:e.x+o/3+i*c,y:e.y+r/3+s*c},control2:{x:e.x+o*2/3+i*c,y:e.y+r*2/3+s*c},end:{...t}}}function Kt(e,t){let{points:n,sourceIndex:o}=Es(e),r=n.length;if(r<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,i=t.edgeCurvature,s=new Array(r).fill(0);if(i?.length)for(let x=0;x<r;x+=1){let m=i[o[x]];s[x]=Number.isFinite(m)?Math.min(100,Math.max(-100,m))/100:0}let c=s.some(x=>Math.abs(x)>1e-6);if(a<=0&&!c)return null;let l=t.wideAngleThresholdDeg??Ls(a),d=[];for(let x=0;x<r;x+=1)d[x]=Z(n[x],n[(x+1)%r]);let f=new Array(r).fill(0);for(let x=0;x<r;x+=1){let m=n[(x-1+r)%r],v=n[x],C=n[(x+1)%r],P={x:m.x-v.x,y:m.y-v.y},k={x:C.x-v.x,y:C.y-v.y},Y=Math.hypot(P.x,P.y),J=Math.hypot(k.x,k.y);if(Y<=1e-9||J<=1e-9)continue;let A=Math.min(1,Math.max(-1,(P.x*k.x+P.y*k.y)/(Y*J))),re=Math.acos(A)*180/Math.PI;if(re<l)continue;let M=ar((re-l)/(180-l));f[x]=a*M*.5*Math.min(Y,J)}for(let x=0;x<r;x+=1){let m=(x+1)%r,v=f[x]+f[m];if(v>d[x]&&v>1e-9){let C=d[x]/v;f[x]*=C,f[m]*=C}}let g=new Array(r),h=new Array(r);for(let x=0;x<r;x+=1){let m=n[(x-1+r)%r],v=n[x],C=n[(x+1)%r];if(f[x]<=1e-6){g[x]={...v},h[x]={...v};continue}let P=Z(v,m)||1,k=Z(v,C)||1;g[x]={x:v.x+(m.x-v.x)/P*f[x],y:v.y+(m.y-v.y)/P*f[x]},h[x]={x:v.x+(C.x-v.x)/k*f[x],y:v.y+(C.y-v.y)/k*f[x]}}if(f.every(x=>x<=1e-6)&&!c)return null;let b=[],p={...h[0]},S=p,I=(x,m)=>{if(Z(S,x)<=1e-9)return;let v=s[m];Math.abs(v)>1e-6?b.push(Fs(S,x,v*Ts*d[m])):b.push({kind:"line",end:{...x}}),S=x};for(let x=1;x<=r;x+=1){let m=x%r,v=n[m];I(g[m],(x-1)%r),f[m]>1e-6&&Z(g[m],h[m])>1e-9&&(b.push({kind:"bezier",control1:Dn(g[m],v,sr),control2:Dn(h[m],v,sr),end:{...h[m]}}),S=h[m])}if(!b.length)return null;let y=b[b.length-1];Z(y.end,p)>1e-9&&(y.kind==="line"?y.end={...p}:b.push({kind:"line",end:{...p}}));let w={version:1,closed:!0,start:p,segments:b};return Bt(w)?w:null}function Ds(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function lt(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function zt(e,t,n){let o=lt(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 Ns(e,t,n,o){let r=lt(e,t,n),a=lt(e,t,o),i=lt(n,o,e),s=lt(n,o,t);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(i>1e-7&&s<-1e-7||i<-1e-7&&s>1e-7)?!0:Math.abs(r)<=1e-7&&zt(n,e,t)||Math.abs(a)<=1e-7&&zt(o,e,t)||Math.abs(i)<=1e-7&&zt(e,n,o)||Math.abs(s)<=1e-7&&zt(t,n,o)}function Gs(e){return e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)}function $s(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 r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&Ns(e[t],e[n],e[o],e[r]))return!0}}return!1}function ur(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)=>Ds(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Gs(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:$s(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}var $n=64;function Bs(e){let t=e.points??[];if(e.kind!=="polygon"||t.length<3||!Array.isArray(e.edgeCurvature))return[];let n=t.map((o,r)=>{let a=e.edgeCurvature[r];return Number.isFinite(a)?Math.min(100,Math.max(-100,a)):0});return n.some(o=>Math.abs(o)>.5)?n:[]}function Ks(e){let t=Bs(e);return t.length?Kt(e.points,{edgeCurvature:t}):null}function dt(e,t=2){let n=Ks(e);return n?st(n,t):e.points??[]}function fr(e){return e.kind==="polygon"?te(e.holes):[]}function hr(e,t){let n=dt(e);return n.length<3||t.length<3||!t.flatMap((r,a)=>{let i=t[(a+1)%t.length];return[r,{x:(r.x+i.x)/2,y:(r.y+i.y)/2}]}).every(r=>Ut(r,n)||Bn(r,n))?!1:!t.some((r,a)=>{let i=t[(a+1)%t.length];return n.some((s,c)=>zs(r,i,s,n[(c+1)%n.length]))})}function zs(e,t,n,o){let r=(l,d,f)=>(d.x-l.x)*(f.y-l.y)-(d.y-l.y)*(f.x-l.x),a=r(e,t,n),i=r(e,t,o),s=r(n,o,e),c=r(n,o,t);return a*i<-1e-9&&s*c<-1e-9}var gr="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Us="ABCDEFGHJKLMNPQRSTUVWXYZ",Hs="abcdefghijklmnopqrstuvwxyz";function br(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let a=o%n;r=t[a]+r,o=Math.floor(o/n)}return r}function Vs(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?Us:gr;return br(o,r)}function ut(e,t=!1){let n=t?Hs:gr;return br(Math.max(0,Math.floor(e)-1),n)}var Xs=[[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 mr(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Xs)for(;t>=o;)n+=r,t-=o;return n}function pr(e,t){let n=e.length;return e.map((o,r)=>{let a=t.reverse?n-1-r:r;return{...o,label:Vs(a,t)}})}function qs(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 ft(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",i=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,c=e.seatCount;if(a==="updown"||a==="updown-descending"){let h=Math.ceil(c/2),b=a==="updown"?t<h?n+2*t:n-1+2*(c-t):t<h?n+2*(h-1-t):n+1+2*(t-h);return`${i}${b}`}let l=a==="odd"||a==="even"?2:r,d=s!=null&&Number.isFinite(s)?s-(c-1)*l:n,f=o==="center"?qs(c)[t]:o==="rtl"?c-1-t:t,g;switch(a){case"odd":{let h=d%2===1?d:d+1;g=String(h+f*2);break}case"even":{let h=d%2===0?d:d+1;g=String(h+f*2);break}case"roman":g=mr(d+f*r);break;case"letters-upper":g=ut(d+f*r,!1);break;case"letters-lower":g=ut(d+f*r,!0);break;default:g=String(d+f*r);break}return`${i}${g}`}function Ys(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function be(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${ft(e,t)}`}function Js(e,t,n,o){if(o?.displayLabel)return null;if(e.seatDisplayLabelMode==="number"||!n)return{row:e.displayLabel||e.label,seat:ft(e,t)};let r=Ys(n);return{row:n.displayLabel,seat:ft(r,n.displayOffset+t)}}function ht(e,t,n,o){let r=Js(e,t,n,o);return r?e.seatDisplayLabelMode==="number"?r.seat:`${r.row}-${r.seat}`:o.displayLabel}var yr=999,Ws=["clockwise","anticlockwise"],Zs=["table-number","number","letter"];function Ht(e,t){return`${e.label}-${t+1}`}function Qs(e,t,n){return e?.direction==="anticlockwise"?Math.max(0,t-1-n):n}function ec(e,t){let n=e.chairNumbering,o=n?.start??1,r=Qs(n,Math.max(0,Math.round(e.seatCount)),t);return n?.format==="letter"?ut(Math.max(1,o)+r):String(o+r)}function Vt(e,t){let n=ec(e,t);return(e.chairNumbering?.format??"table-number")==="table-number"?`${e.displayLabel??e.label}-${n}`:n}function wr(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))return"chairNumbering must be an object";let t=e,n=Object.keys(t).filter(o=>!["start","direction","format"].includes(o));return n.length?`chairNumbering has unsupported field(s): ${n.join(", ")}`:t.start!==void 0&&(!Number.isInteger(t.start)||t.start<0||t.start>yr)?`chairNumbering.start must be a whole number from 0 to ${yr}`:t.direction!==void 0&&!Ws.includes(t.direction)?"chairNumbering.direction must be clockwise or anticlockwise":t.format!==void 0&&!Zs.includes(t.format)?"chairNumbering.format must be table-number, number or letter":null}function xr(e){let t={};return e.start!==void 0&&e.start!==1&&(t.start=e.start),e.direction==="anticlockwise"&&(t.direction="anticlockwise"),e.format&&e.format!=="table-number"&&(t.format=e.format),Object.keys(t).length?t:void 0}var Xt=.02291666666666667,Kn=1/Xt,tc=58,gh=tc*Xt;var Sr=[{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."},{key:"pitch-rugby",label:"Rugby pitch",blurb:"100 \xD7 70 m field of play with in-goal areas, 22 m and 10 m lines."},{key:"diamond-baseball",label:"Baseball field",blurb:"Diamond, infield, mound and foul lines out to 99 m poles."},{key:"court-basketball",label:"Basketball court",blurb:"28 \xD7 15 m court with keys and three-point lines."},{key:"court-tennis",label:"Tennis court",blurb:"23.77 \xD7 10.97 m doubles court with run-off and net."},{key:"ring-boxing",label:"Boxing ring",blurb:"Raised ring, 6.1 m inside the ropes, coloured corners."}];var nc={round:{width:6,height:6},"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},oc={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};function Ir(e){let t=nc[e];return t?{width:t.width*Kn,height:t.height*Kn}:{width:300,height:70}}var rc="#232c40",ic=Math.PI*2;function ac(e,t,n,o,r,a){return{x:r+e*n-t*o,y:a+e*o+t*n}}function zn(e){let{kind:t,cx:n,cy:o,width:r,height:a}=e,i=(e.rotation??0)*Math.PI/180,s=Math.cos(i),c=Math.sin(i),l=r/2,d=a/2,f=[],g=(h,b)=>{f.push({x:h,y:b})};switch(t){case"rect":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"rounded":{let h=Math.min(r,a)*.18,b=5,p=(S,I,y)=>{for(let w=0;w<=b;w++){let x=y+w/b*(Math.PI/2);g(S+h*Math.cos(x),I+h*Math.sin(x))}};p(l-h,-d+h,-Math.PI/2),p(l-h,d-h,0),p(-l+h,d-h,Math.PI/2),p(-l+h,-d+h,Math.PI);break}case"arc":{let h=a*.45;g(-l,-d),g(l,-d);let b=24;for(let p=0;p<=b;p++){let S=p/b,I=l-S*r,y=d+h*(1-Math.pow(2*I/r,2));g(I,y)}break}case"thrust":{let h=r*.18,b=a*1.1;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"runway":{let h=r*.1,b=a*3;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"round":case"oval-cricket":{for(let b=0;b<40;b++){let p=b/40*ic;g(l*Math.cos(p),d*Math.sin(p))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"diamond-baseball":{for(let h of lc(l,d))g(h.x,h.y);break}case"rink-hockey":{for(let h of sc(l,d,l*(8.5/60),d*(8.5/30)))g(h.x,h.y);break}case"track-athletics":{for(let h of cc(l,d))g(h.x,h.y);break}}return f.map(h=>ac(h.x,h.y,s,c,n,o))}function vr(e,t="stage"){return{type:"shape",id:t,kind:"polygon",points:zn(e),fill:e.fill??oc[e.kind]??rc,label:e.label??"STAGE",role:"stage",stageKind:e.kind}}function sc(e,t,n,o){let r=[],i=(s,c,l)=>{for(let d=0;d<=8;d++){let f=l+d/8*(Math.PI/2);r.push({x:s+n*Math.cos(f),y:c+o*Math.sin(f)})}};return i(e-n,-t+o,-Math.PI/2),i(e-n,t-o,0),i(-e+n,t-o,Math.PI/2),i(-e+n,-t+o,Math.PI),r}function cc(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let a=0;a<=r;a++){let i=-Math.PI/2+a/r*Math.PI;o.push({x:n+t*Math.cos(i),y:t*Math.sin(i)})}for(let a=0;a<=r;a++){let i=Math.PI/2+a/r*Math.PI;o.push({x:-n+t*Math.cos(i),y:t*Math.sin(i)})}return o}var gt=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=r+70,i=[],s=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let l=0;l<=24;l++){let d=s+(c-s)*l/24;i.push({x:a*Math.cos(d),y:r+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:i}})();function lc(e,t){let n=e/gt.half,o=t/gt.half;return[{x:-gt.backstop*n,y:t},{x:gt.backstop*n,y:t},...gt.fence.map(r=>({x:r.x*n,y:r.y*o}))]}function Cr(e){switch(e){case"pitch-football":return"PITCH";case"rink-hockey":return"RINK";case"track-athletics":return"TRACK";case"oval-cricket":return"OVAL";case"pitch-rugby":return"PITCH";case"diamond-baseball":return"FIELD";case"court-basketball":case"court-tennis":return"COURT";case"ring-boxing":return"RING";default:return"STAGE"}}var dc=2e6,uc=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,fc=/[\s"'<>`\\]/;function Or(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return uc.test(e);if(fc.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function we(e){let t=e.trim();return Or(t)?t:null}function bt(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Yt=Math.PI/180,hc=9,xe=16;function Hn(e,t,n,o){let r=n*Yt,a=Math.cos(r),i=Math.sin(r);return{x:o.x+e*a-t*i,y:o.y+e*i+t*a}}function Q(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:a}=e,i=[];if(e.path)return $t(e.path,t);if(t<=1)return t===1&&i.push({x:a.x,y:a.y}),i;if(o===0){for(let l=0;l<t;l++)i.push(Hn(l*n,0,r,a));return i}let s=o/(t-1)*Yt,c=n/(2*Math.sin(Math.abs(s)/2));for(let l=0;l<t;l++){let d=l*s,f=c*Math.sin(d),g=-c+c*Math.cos(d);i.push(Hn(f,g,r,a))}return i}function Vn(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function gc(e,t){let n=Vn(e);return Q(e).map((o,r)=>{let a=n.get(r),i=bt(a),s=be(e,r,a),c={...e.commercial,...a?.commercial};return{index:r,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:ht(e,r,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:i.length>0,accessibility:i,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 ee(e){let t=[];for(let n of gc(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 bc(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 r=Math.max(0,Math.round(e.seatCount));for(let a=0;a<r;a++)o[n[a%n.length]]+=1;return o}function mc(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])),r=(d,f,g,h)=>{let b=o.get(d),p=bt(b),S=b?.label??Ht(e,d);return{index:d,label:S,displayLabel:b?.displayLabel??Vt(e,d),x:f+(b?.dx??0),y:g+(b?.dy??0),categoryKey:b?.categoryKey??e.categoryKey,skipped:!!b?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:b?.wheelchairSpaceType,commercial:b?.commercial,glyph:b?.glyph,viewUrl:b?.viewFromSeatUrl,viewMeta:b?.viewFromSeatUrl?b.viewFromSeatMeta:void 0,labelStyle:b?.labelStyle,...h?{side:h}:{}}};if(e.shape==="round"){let d=(e.radius??40)+xe,f=e.rotation*Yt,g=Math.max(0,Math.min(360,e.seatArc??360));if(g>=360||n===1){for(let S=0;S<n;S++){let I=f+S/n*2*Math.PI;t.push(r(S,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let h=g*Yt,b=(2*Math.PI-h)/2,p=f+b;for(let S=0;S<n;S++){let I=p+S/(n-1)*h;t.push(r(S,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,i=e.height??50,s=bc(e),c=["top","bottom","left","right"],l=0;for(let d of c){let f=s[d];for(let g=0;g<f;g++){let h,b;d==="top"?(h=-a/2+(g+.5)*a/f,b=-i/2-xe):d==="bottom"?(h=-a/2+(g+.5)*a/f,b=i/2+xe):d==="left"?(h=-a/2-xe,b=-i/2+(g+.5)*i/f):(h=a/2+xe,b=-i/2+(g+.5)*i/f);let p=Hn(h,b,e.rotation,e.center);t.push(r(l++,p.x,p.y,d))}}return t}function me(e){return mc(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 Rr(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",...e.commercial?.note?{commercial:{note:e.commercial.note}}:{}}]}function Ut(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let a=t[o].x,i=t[o].y,s=t[r].x,c=t[r].y;i>e.y!=c>e.y&&e.x<(s-a)*(e.y-i)/(c-i)+a&&(n=!n)}return n}function Bn(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],a=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(a)>1e-7)return!1;let i=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),s=(r.x-n.x)**2+(r.y-n.y)**2;return i>=-1e-7&&i<=s+1e-7})}function te(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function H(e,t,n){return Ut(e,t)&&!te(n).some(o=>Ut(e,o)||Bn(e,o))}function Un(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 V(e){switch(e.type){case"row":{let t=Q(e),n=Vn(e),o=0,r=0,a=0;for(let i=0;i<t.length;i++){let s=n.get(i);s?.skip||(o+=t[i].x+(s?.dx??0),r+=t[i].y+(s?.dy??0),a++)}return a?{x:o/a,y:r/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 Un(e.points);case"section":return Un(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Un(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 Pr(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function pc(e,t){if(e.type!=="gaArea"||!Pr(e.points,t.outline))return!1;let n=te(e.holes),o=te(t.holes);return n.length===o.length&&n.every((r,a)=>Pr(r,o[a]))}function Jt(e,t,n=e.filter(r=>r.type==="section"),o=V(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(i=>(i.logicalSectionId??i.id)===r&&(pc(t,i)||H(o,i.outline,i.holes))):void 0)??n.find(i=>H(o,i.outline,i.holes))??(t.type==="row"&&yc(t)?wc(t,n):void 0)}function yc(e){return(e.overrides??[]).some(t=>t.skip===!0)}function wc(e,t){let n=Q(e),o=Vn(e),r,a=0;for(let i of t){let s=0;for(let c=0;c<n.length;c++){let l=o.get(c);if(l?.skip)continue;let d={x:n[c].x+(l?.dx??0),y:n[c].y+(l?.dy??0)};H(d,i.outline,i.holes)&&s++}s>a&&(r=i,a=s)}return r}function j(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 ne(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var qt=40;function fe(e,t){let n=t?.freeText==="exclude",o=1/0,r=1/0,a=-1/0,i=-1/0,s=(l,d)=>{l<o&&(o=l),d<r&&(r=d),l>a&&(a=l),d>i&&(i=d)},c=l=>{if(Array.isArray(l))for(let d of l)!d||typeof d!="object"||s(d.x,d.y)};for(let l of ne(e))if(l.type==="row"){let d=new Map((l.overrides??[]).map(f=>[f.index,f]));Q(l).forEach((f,g)=>{let h=d.get(g);h?.skip||s(f.x+(h?.dx??0),f.y+(h?.dy??0))})}else if(l.type==="gaArea")c(l.points);else if(l.type==="section")c(l.outline);else if(l.type==="decorImage")s(l.x,l.y),s(l.x+l.width,l.y+l.height);else if(l.type==="shape")l.points&&l.points.length?c(dt(l)):l.x!=null&&l.y!=null&&l.width!=null&&l.height!=null&&(s(l.x,l.y),s(l.x+l.width,l.y+l.height));else if(l.type==="table"){let d=xe+hc,f=l.shape==="round"?(l.radius??40)+d:Math.max((l.width??80)/2,(l.height??50)/2)+d;s(l.center.x-f,l.center.y-f),s(l.center.x+f,l.center.y+f)}else if(l.type==="booth"){let d=Math.max(l.width,l.height)/2;s(l.center.x-d,l.center.y-d),s(l.center.x+d,l.center.y+d)}else if(l.type==="text"){if(n)continue;let d=or(l);s(l.position.x,l.position.y),s(l.position.x+d.width,l.position.y+d.height)}for(let l of[e.referenceImage,e.backgroundImage]){if(!l)continue;let{center:d,width:f}=l;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(f))continue;let g=f*3/4;s(d.x-f/2,d.y-g/2),s(d.x+f/2,d.y+g/2)}if(!isFinite(o)){let l=e.focalPoint??{x:0,y:0};return{x:l.x-200,y:l.y-200,width:400,height:400}}return{x:o-qt,y:r-qt,width:a-o+qt*2,height:i-r+qt*2}}function mt(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}function Ar(e){return e.type!=="shape"&&e.type!=="text"||e.labelImportance==="detail"?!1:e.labelImportance==="orientation"||e.referenceAnnotationSource?.kind==="direct-landmark-v1"}var xc=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Lr(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function yt(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Xn(e){let t=yt(e),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o),a={};for(let i of xc){let s=r?.[i];s!==void 0&&(a[i]=s)}n.push([be(e,o,r),ht(e,o,void 0,r),r?.categoryKey??e.categoryKey,r?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function Sc(e){return JSON.parse(JSON.stringify(e))}function Wt(e,t){let n=Sc(e);return t(n)&&Xn(n)===Xn(e)?n:e}function Ic(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=yt(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let r=t.get(o)?.labelStyle;if(!r)return!1;if(!n)n=r;else if(!Lr(n,r))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function vc(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Er(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 i=vc(a.slice(n.length+1));if(i===void 0)return;o.push(i)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let r=o[1]-o[0];if(!(r!==1&&r!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==r)return;return r===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Cc(e){if(e.seatCount<1)return!1;let t=yt(e);if(!(e.overrides??[]).some(r=>r.label!==void 0))return!1;let n=[];for(let r=0;r<e.seatCount;r+=1)n.push(be(e,r,t.get(r)));let o=Er(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 r of e.overrides??[])delete r.label;return!0}function Oc(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=yt(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==ft(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Qt(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Lr(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===be(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===ht(e,t.index)&&delete t.displayLabel}function Tr(e){return Object.keys(e).every(t=>t==="index")}function Pc(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Qt(e,n);let t=e.overrides.filter(n=>!Tr(n));return t.length?e.overrides=t:delete e.overrides,!0}function Rc(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=yt(t);for(let r=0;r<t.seatCount;r+=1)if(o.get(r)?.displayLabel===void 0)return!1;return!0}function jr(e){if(e.type!=="row")return e;let t=Wt(e,Ic);return t=Wt(t,Cc),t=Wt(t,Oc),t=Wt(t,Pc),Rc(e,t)?t:e}function Fr(e){if(!e.overrides?.length)return e;let t=[];for(let o of e.overrides){let r={...o};r.label===Ht(e,r.index)&&delete r.label,r.displayLabel===Vt(e,r.index)&&delete r.displayLabel,r.categoryKey===e.categoryKey&&delete r.categoryKey,r.dx===0&&delete r.dx,r.dy===0&&delete r.dy,Tr(r)||t.push(r)}let n={...e};return t.length?n.overrides=t:delete n.overrides,n}function Mr(e){return e.type==="row"?jr(e):e.type==="table"?Fr(e):e}function Ac(e){let t=e.objects.map(Mr),n=e.floors?.map(o=>({...o,objects:o.objects.map(Mr)}));return{...e,objects:t,...n?{floors:n}:{}}}var _r=2,Mc=3,kr=6;function pt(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 Zt(e){return{...e,x:pt(e.x,_r),y:pt(e.y,_r)}}function _c(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Zt(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Zt)),Array.isArray(t.points)&&(t.points=t.points.map(Zt)),typeof t.rotation=="number"&&(t.rotation=pt(t.rotation,kr)),typeof t.seatSpacing=="number"&&(t.seatSpacing=pt(t.seatSpacing,kr));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Zt(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let r={...o};for(let a of["dx","dy"]){let i=r[a];if(typeof i!="number")continue;let s=pt(i,Mc);s===0?delete r[a]:r[a]=s}return r})),t}function Dr(e){let t=e.backgroundImage;return t?.url&&!t.assetId?t:void 0}var kc=36,Lc=160;function Nr(e,t=360){let n=at(Math.round(Number.isFinite(e)?e:1),1,40),o=at(Number.isFinite(t)?t:360,120,360);return Math.round(at(n*4*(360/o),kc,Lc))}var Gr=e=>Math.round(e*1e6)/1e6+0;function $r(e){let t=e.map(r=>({x:Gr(r.x),y:Gr(r.y)})).sort((r,a)=>r.x-a.x||r.y-a.y).filter((r,a,i)=>a===0||r.x!==i[a-1].x||r.y!==i[a-1].y);if(t.length<3)return t;let n=(r,a,i)=>{let s=a.x-r.x,c=a.y-r.y,l=i.x-r.x,d=i.y-r.y;return s*d-c*l>1e-6*Math.hypot(s,c)*Math.hypot(l,d)},o=r=>{let a=[];for(let i of r){for(;a.length>=2&&!n(a[a.length-2],a[a.length-1],i);)a.pop();a.push(i)}return a.pop(),a};return[...o(t),...o([...t].reverse())]}function Br(e,t){if(!e.length)return e;let n={x:e.reduce((o,r)=>o+r.x,0)/e.length,y:e.reduce((o,r)=>o+r.y,0)/e.length};return e.map(o=>{let r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a)||1;return{x:o.x+r/i*t,y:o.y+a/i*t}})}var Kr=["horizontal","vertical","auto"];var wt=[{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"}],Fh=new Map(wt.map(e=>[e.key,e]));var Ec=[{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"}],Dh=new Map(Ec.map(e=>[e.key,e]));var Ne=8,qn=24,zr=["start","end","both","none"],Ur=["inline","corner","peninsula","island"],Tc=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Nh=new Set(Tc);var u=class extends Error{constructor(n,o,r={}){super(o);this.code=n;this.details=r;this.name="ChartOperationError"}};function O(e,t){let n=j(e),o=t?n.find(r=>r.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 N(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 T(e,t,n,o){let r=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(i=>i.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let i=n(t);if(i&&!r.has(i))return o.add(i),i}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Ge(e){let t=[];for(let o of e)o.type==="row"?t.push(...ee(o).map(r=>({x:r.x,y:r.y}))):o.type==="table"?t.push(...me(o).map(r=>({x:r.x,y:r.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Br($r(t),22);return n.length>=3?n:null}function pe(e,t){let n=O(e,t),o=j(e).find(r=>r.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Hr=24,Vr=80;function Yn(e,t){let n=e.normalize("NFKC").trim();if(n.length>Hr)throw new u("invalid_operation",`${t} displayed type must be at most ${Hr} characters`);return n}function en(e,t){if(e.displayType===void 0)return!1;let n=Yn(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function $e(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Vr)throw new u("invalid_operation",`${t} displayed label must be at most ${Vr} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function D(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 Xr(e,t){if(!Number.isFinite(e)||e<Ne||e>qn)throw new u("invalid_operation",`${t} label size must be from ${Ne} to ${qn}`)}function Se(e,t){e.size!==void 0&&e.size!==null&&Xr(e.size,t),e.color!==void 0&&e.color!==null&&D(e.color,`${t} label color`)}function tn(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&&Xr(n.size,t),n.color!==void 0&&D(n.color,`${t} label color`))}function Be(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=D(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 Jn(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(r=>r.id!==n&&r.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function xt(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 ce(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var le=Math.PI/180,he=Math.PI/180;function Pe(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 Re(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 jc=0,nn=120,Wn=4;function Fc(e){if(!Number.isFinite(e)||e<jc||e>nn)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Dc(e,t){let n=j(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(nn,(e.floors.length-1)*Wn),i=Math.min(nn,a+Wn),s=T(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:i,objects:[],focalPoint:{...e.focalPoint}}),Re(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:i}}function Nc(e,t){let n=j(e),o=n.find(i=>i.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let r=t.name.normalize("NFKC").trim();if(!r||r.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(i=>i.id!==o.id&&i.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${r}`);let a=o.name!==r;return a&&(o.name=r),{changed:a,floorId:o.id,floorName:r}}function Gc(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(r=>r.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});Fc(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 $c(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(r=>r.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[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else Re(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:j(e).length}}function Bc(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:T(e,"zone",t.idFactory,new Set),label:Jn(e,t.label),color:D(t.color,"Zone color"),...t.focalPoint?{focalPoint:xt(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function Kc(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])),r=n.filter(c=>!o.has(c));if(r.length)throw new u("object_not_found",`Unknown zone id(s): ${r.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:r});let a=structuredClone(e),i=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=i.get(c.zoneId);c.patch.label!==void 0&&(d.label=Jn(a,c.patch.label,d.id)),c.patch.color!==void 0&&(d.color=D(c.patch.color,"Zone color")),c.patch.focalPoint!==void 0&&(d.focalPoint=xt(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(i.get(c)))}}function zc(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=j(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 r=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,Re(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:r,zoneCount:e.zones?.length??0}}var St=[{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 on(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])),r=(a,i=1)=>{a&&i>0&&t.set(a,(t.get(a)??0)+i)};r(e.categoryKey,n-o.size);for(let a of o.values())a.skip||r(a.categoryKey??e.categoryKey);return t}var Zn="__sl_ga__";function Ae(e){return e.startsWith(Zn)}var Uc=Zn,oe=1e5;function Hc(e,t){return`${Uc}${encodeURIComponent(e)}__${t+1}`}function Qn(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 r of t){if(!r||typeof r.sourceAreaId!="string"||!r.sourceAreaId.trim()||r.sourceAreaId.length>160||!Number.isInteger(r.startIndex)||r.startIndex<0||!Number.isInteger(r.count)||r.count<1||r.startIndex+r.count>oe||(n+=r.count,n>oe))return!1;let a=o.get(r.sourceAreaId)??[],i=r.startIndex+r.count;if(a.some(s=>r.startIndex<s.end&&i>s.start))return!1;a.push({start:r.startIndex,end:i}),o.set(r.sourceAreaId,a)}return n===e.capacity}function rn(e){let t=Math.min(oe,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Qn(e)?e.inventorySegments.map(n=>({...n})):[]}var an=100,qr=`An area sold to one party holds at most ${an} guests.`;function Ke(e){return e.variableOccupancy?"variable":e.bookAsWhole?"whole":null}function de(e){return Vc(e,2)}function Vc(e,t){return t===2&&Ke(e)&&e.inventorySegments===void 0?e.label.trim()?[e.label]:[]:rn(e).flatMap(n=>Array.from({length:n.count},(o,r)=>Hc(n.sourceAreaId,n.startIndex+r)))}function eo(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=rn(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),i=n[n.length-1];if(i?.sourceAreaId===e.id&&i.startIndex+i.count===a)i.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var Xc="__ungrouped__";function qc(e){return e.type==="row"?ee(e).map(t=>t.label):e.type==="table"?me(e).map(t=>t.label):e.type==="booth"?Rr(e).map(t=>t.label):e.type==="gaArea"?de(e):[]}function Yc(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Jc(e){return e.displayLabel||e.label||"Section"}function Wc(e){let t=new Map;for(let n of ne(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:Jc(n),zone:n.zone})}return t}function Zc(e,t){let n=ne(e),o=n.filter(s=>s.type==="section"),r=new Map;for(let[s,c]of Wc(e))r.set(s,{id:s,label:c.label,zone:c.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:Xc,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},i=new Map;for(let s of n){if(!Yc(s))continue;let c=qc(s);if(c.length===0)continue;let l;if(t)l=t.get(s.id);else{let f=Jt(n,s,o);l=f?f.logicalSectionId??f.id:void 0}let d=l?r.get(l):a;d.seatCount+=c.length,d.objectIds.push(s.id),d.seatLabels.push(...c),i.set(s.id,d.id)}return{sections:[...r.values()],ungrouped:a.objectIds.length?a:null,objectToSection:i}}function It(e){return Zc(e,null)}var Me={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 vt(e,t,n,o,r,a,i=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*r/2,y:n},rotation:0,curve:i,seatCount:o,seatSpacing:r,categoryKey:a}}function Qc(e,t,n,o,r,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:r,categoryKey:a}}function Yr(e,t,n,o,r,a){let i=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-i,y:-s},{x:i,y:-s},{x:i,y:s},{x:-i,y:s}],capacity:r,categoryKey:a}}function el(e,t,n,o,r){let a=n*2,i=[];for(let s=0;s<a;s++){let c=s%2===0,l=c?["wheelchair"]:["companion"];i.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:r,overrides:i}}var Jr=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[Me.balcony],sectionLabel:"Balcony",build:()=>[vt("blk-b0","A",-45,18,24,"balcony",18),vt("blk-b1","B",-15,20,24,"balcony",18),vt("blk-b2","C",15,22,24,"balcony",18),vt("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[Me.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>vt(`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:[Me.standard],build:()=>[Yr("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[Me.premium],build:()=>Array.from({length:6},(e,t)=>Qc(`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:[Me.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:[Me.standard],build:()=>[Yr("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:[Me.standard],build:()=>[el("blk-wc","A",4,40,"standard")]}];function B(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 sn(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 Ie=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"],Wr="#a4508b";var tl=/^#?([\da-f]{3}|[\da-f]{6})$/i;function nl(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Ue(e){let t=tl.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function no(e,t){let n=a=>{let i=Ue(a);if(!i)return null;let s=y=>{let w=y/255;return w<=.04045?w/12.92:((w+.055)/1.055)**2.4},c=s(i[0]),l=s(i[1]),d=s(i[2]),f=(.4124*c+.3576*l+.1805*d)/.95047,g=.2126*c+.7152*l+.0722*d,h=(.0193*c+.1192*l+.9505*d)/1.08883,b=y=>y>.008856?Math.cbrt(y):7.787*y+16/116,p=b(f),S=b(g),I=b(h);return[116*S-16,500*(p-S),200*(S-I)]},o=n(e),r=n(t);return o&&r?Math.hypot(o[0]-r[0],o[1]-r[1],o[2]-r[2]):null}function ze(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Zr(e){let{r:t,g:n,b:o}=nl(e);return .2126*ze(t)+.7152*ze(n)+.0722*ze(o)}function to(e){return .2126*ze(e[0])+.7152*ze(e[1])+.0722*ze(e[2])}function cn(e,t){let n=Zr(e),o=Zr(t);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}function Ct(e,t){let n=Ue(e),o=Ue(t);if(!n||!o)return null;let r=to(n),a=to(o);return(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function Qr(e,t,n){return cn(t,e)>=cn(n,e)?t:n}var ei=.85,ol=12;function ti(e,t){return e*t>=ol}var rl={wheelchair:"M7.8 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM8 7L10.5 7L10.5 15L8 15ZM8 12.5L18 12.5L18 15L8 15ZM16 15L18 15L18 18L16 18ZM5.5 16a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0 -11 0zM8 16a3 3 0 1 1 6 0a3 3 0 1 1 -6 0z",companion:"M5.5 6.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM4.5 18.5L6 11.5L11 11.5L12.5 18.5ZM12.5 7.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM11.5 19L13 12.5L18 12.5L19.5 19Z","semi-ambulatory":"M8.3 3.8a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM9 6.2L12 6.6L11 13.5L8.6 13L9 6.2ZM8.6 13L11 13L9.5 21L7 21ZM10.4 13L12.6 13L13.6 21L11.2 21ZM11.2 7.2L14 8L14.6 9.6L11.9 8.9ZM14.4 6.8L15.9 6.8L16.4 21L14.8 21Z","designated-aisle":"M3 5L6 5L6 14L3 14ZM3 12L13 12L13 15L3 15ZM5 15L7 15L7 20L5 20ZM11 15L13 15L13 20L11 20ZM13 7L20 7L17 4L19 4L23 8.5L19 13L17 13L20 10L13 10Z","step-free":"M4 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM4.4 7L7.5 7L7.5 13L11 15L9.5 17L5 14L4.4 7ZM2 19L8 19L17 10L22 10L22 13L18 13L10 21L2 21Z",hearing:"M15.5 3.5C9 2.2 5.5 6 5.5 11.5C5.5 16 8 19.5 10.5 21C13.2 22.6 16.4 20.8 15.4 18C14.8 16.4 12.9 16.1 13 14C13.1 11.9 15.8 11.4 15.8 8.5C15.8 5.4 13 4 15.5 3.5Z",cart:"M5.5 6L18.5 6a2.5 2.5 0 0 1 2.5 2.5L21 15.5a2.5 2.5 0 0 1 -2.5 2.5L11 18L7 20.5L7.5 18L5.5 18a2.5 2.5 0 0 1 -2.5 -2.5L3 8.5a2.5 2.5 0 0 1 2.5 -2.5zM6.5 11L17.5 11L17.5 12.6L6.5 12.6zM6.5 14L17.5 14L17.5 15.6L6.5 15.6z","sign-language":"M7 11L17 11L17 18a2 2 0 0 1 -2 2L9 20a2 2 0 0 1 -2 -2zM7.6 5L9.4 5L9.4 12L7.6 12zM9.9 3.5L11.7 3.5L11.7 12L9.9 12zM12.3 3.5L14.1 3.5L14.1 12L12.3 12zM14.6 5L16.4 5L16.4 12L14.6 12zM7.2 12.5L5 10.2L6.4 8.9L8.6 11.2Z","low-vision":"M2.5 12C6 6 18 6 21.5 12C18 18 6 18 2.5 12ZM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM17.5 3L19 3L19 6L17.5 6ZM19 4L22 4L22 5.5L19 5.5Z","sensory-friendly":"M4 11C4 5 7 2.5 12 2.5S20 5 20 11L17 11C17 7 15.5 5.5 12 5.5S7 7 7 11ZM3 10L8 10L8 19L5 19a2 2 0 0 1 -2 -2ZM16 10L21 10L21 17a2 2 0 0 1 -2 2L16 19ZM9 12L15 12L15 14L9 14ZM10 16L14 16L14 18L10 18Z","plus-size":"M9.4 4.3a2.6 2.6 0 1 0 5.2 0a2.6 2.6 0 1 0 -5.2 0zM5 20L4 13C4 10.5 7 9.5 12 9.5C17 9.5 20 10.5 20 13L19 20Z","lift-armrest":"M5 6L8 6L8 19L5 19zM5 16L18 16L18 19L5 19zM8 12L17 12L17 14.5L8 14.5zM14 7L16 7L16 12L14 12zM12 7L18 7L15 3Z"},gg=rl.wheelchair;function ni(e,t,n){let o=Ue(e),r=Ue(t);if(!o||!r)return t;let a=Math.max(0,Math.min(1,n));return`#${o.map((s,c)=>Math.round(s*a+r[c]*(1-a))).map(s=>s.toString(16).padStart(2,"0")).join("")}`}var oo={facilities:Wr,"food-drink":Ie[5],navigation:Ie[2],accessibility:Ie[4]};var pg={minDiameterPx:12,glyphScale:.66,ringRatio:1/14,largeFromPx:24};var G=e=>{let t=Math.round(e*100)/100;return Object.is(t,-0)?"0":String(t)},qe=e=>`${G(e[0])} ${G(e[1])}`,Xe=(e,t,n,o)=>[e+n*Math.cos(o*Math.PI/180),t+n*Math.sin(o*Math.PI/180)];function bi(e){let t=`M${qe(e.from)}`;for(let n of e.segs)t+=n.arc?`A${G(n.arc.r)} ${G(n.arc.r)} 0 ${n.arc.large} ${n.arc.sweep} ${qe(n.to)}`:`L${qe(n.to)}`;return`${t}Z`}function K(e){let t=[e.from,...e.segs.map(o=>o.to)],n=[];for(let o=e.segs.length-1;o>=0;o--){let r=e.segs[o].arc;n.push({to:t[o],arc:r&&{...r,sweep:r.sweep?0:1}})}return{from:t[t.length-1],segs:n}}function z(e,t,n){let o={r:n,large:0,sweep:1};return{from:[e-n,t],segs:[{to:[e+n,t],arc:o},{to:[e-n,t],arc:o}]}}function _(e,t,n,o,r){let a=Math.min(r,n/2,o/2),i={r:a,large:0,sweep:1};return a<=0?q([[e,t],[e+n,t],[e+n,t+o],[e,t+o]]):{from:[e+a,t],segs:[{to:[e+n-a,t]},{to:[e+n,t+a],arc:i},{to:[e+n,t+o-a]},{to:[e+n-a,t+o],arc:i},{to:[e+a,t+o]},{to:[e,t+o-a],arc:i},{to:[e,t+a]},{to:[e+a,t],arc:i}]}}function q(e){let t=0;for(let o=0;o<e.length;o++){let[r,a]=e[o],[i,s]=e[(o+1)%e.length];t+=r*s-i*a}let n=t>0?e:[...e].reverse();return{from:n[0],segs:[...n.slice(1).map(o=>({to:o})),{to:n[0]}]}}function F(e,t,n){let o=n/2,r=t[0]-e[0],a=t[1]-e[1],i=Math.hypot(r,a);if(i<1e-6)return z(e[0],e[1],o);let s=[a/i*o,-r/i*o],c={r:o,large:0,sweep:1},l=[e[0]+s[0],e[1]+s[1]];return{from:l,segs:[{to:[t[0]+s[0],t[1]+s[1]]},{to:[t[0]-s[0],t[1]-s[1]],arc:c},{to:[e[0]-s[0],e[1]-s[1]]},{to:l,arc:c}]}}function X(e,t,n=!1){let o=[],r=n?e.length:e.length-1;for(let a=0;a<r;a++)o.push(F(e[a],e[(a+1)%e.length],t));return o}function ue(e,t,n,o,r,a){let i=a/2,s=r-o>180?1:0,c={r:i,large:0,sweep:1},l=Xe(e,t,n+i,o);return{from:l,segs:[{to:Xe(e,t,n+i,r),arc:{r:n+i,large:s,sweep:1}},{to:Xe(e,t,n-i,r),arc:c},{to:Xe(e,t,n-i,o),arc:{r:n-i,large:s,sweep:0}},{to:l,arc:c}]}}var L=(...e)=>e.flat().map(bi).join(" "),ae=(e,t,n)=>`M${G(e-n)} ${G(t)}a${G(n)} ${G(n)} 0 1 0 ${G(2*n)} 0a${G(n)} ${G(n)} 0 1 0 ${G(-2*n)} 0`,ge=(e,t,n,o,r)=>bi(_(e,t,n,o,r)),dn=e=>`M${e.map(qe).join("L")}`,ln=(e,t,n,o,r)=>`M${qe(Xe(e,t,n,o))}A${G(n)} ${G(n)} 0 ${r-o>180?1:0} 1 ${qe(Xe(e,t,n,r))}`;function He(e,t,n,o=1){let r=a=>[a[0]*o+t,a[1]*o+n];return{head:[e.head[0]*o+t,e.head[1]*o+n,e.head[2]*o],limbs:e.limbs.map(a=>a.map(r)),arcs:e.arcs?.map(([a,i,s,c,l])=>[a*o+t,i*o+n,s*o,c,l])}}function Ot(e){return[ae(e.head[0],e.head[1],e.head[2]),...e.limbs.map(dn),...(e.arcs??[]).map(([t,n,o,r,a])=>ln(t,n,o,r,a))].join(" ")}function Ve(e,t=2.6){return[z(e.head[0],e.head[1],e.head[2]+1),...e.limbs.flatMap(n=>X(n,t)),...(e.arcs??[]).map(([n,o,r,a,i])=>ue(n,o,r,a,i,t-.2))]}var _e={head:[10,4,2],limbs:[[[10,8.2],[10,14],[15.5,14],[18,19.5],[20.5,19.5]],[[10,10.6],[14.5,10.6]]],arcs:[[9.5,16,5.5,35,235]]},oi={head:[10.6,3.9,1.9],limbs:[[[9.6,7.8],[7.6,12]],[[5.4,8.2],[9.4,8.4],[12.8,10]],[[4,15.6],[7.6,12],[11,13.6],[10.6,16.4]]]},ri={cx:12,hr:1.9,arm:5,leg:3,r:2},ii={cx:12,hr:1.9,sh:2.2,hem:6,leg:3},ai={cx:6.2,hr:1.8,arm:3.6,leg:2.2,r:1.4},si={cx:17.8,hr:1.8,sh:1.4,hem:4.1,leg:2.2};function ci({cx:e,hr:t,arm:n,leg:o,r}){return[ae(e,2+t,t),`M${G(e-n+r)} 8.5H${G(e+n-r)}a${r} ${r} 0 0 1 ${r} ${r}V15H${G(e+o)}V22H${G(e-o)}V15H${G(e-n)}V${G(8.5+r)}a${r} ${r} 0 0 1 ${r} ${-r}Z`,`M${G(e)} 15V22`].join(" ")}function li({cx:e,hr:t,arm:n,leg:o,r}){return[z(e,2+t,t+1),_(e-n-.5,7.8,2*n+1,7.7,r+.5),_(e-o-.5,13,o,9.5,1),_(e+.5,13,o,9.5,1)]}function di({cx:e,hr:t,sh:n,hem:o,leg:r}){return[ae(e,2+t,t),dn([[e-n,8.5],[e+n,8.5],[e+o,16],[e+r,16],[e+r,22],[e-r,22],[e-r,16],[e-o,16]])+"Z",`M${G(e)} 16V22`].join(" ")}function ui({cx:e,hr:t,sh:n,hem:o,leg:r}){return[z(e,2+t,t+1),q([[e-n-.6,7.8],[e+n+.6,7.8],[e+o+.9,16.8],[e-o-.9,16.8]]),_(e-r-.1,15,r-.4,7.5,.9),_(e+.5,15,r-.4,7.5,.9)]}var il=[[14.6,1.5],[5.2,13.6],[11,13.6],[9.4,22.5],[18.8,10.4],[13,10.4]],al="M8.5 3.5 4 5.5l-1.5 5 3 1 1-2v11h11v-11l1 2 3-1-1.5-5-4.5-2c-.5 1.5-1.8 2.5-3.5 2.5s-3-1-3.5-2.5Z",sl="M12 2.5S5 9.5 5 14.5a7 7 0 0 0 14 0c0-5-7-12-7-12Z",cl="M2.5 21.5h19V3h-6v6.2H9.2v6.2H2.5Z",fi=[[9,3],[15,3],[15,9],[21,9],[21,15],[15,15],[15,21],[9,21],[9,15],[3,15],[3,9],[9,9]],ll={from:[3.8,5.2],segs:[{to:[20.2,5.2]},{to:[22,7],arc:{r:1.8,large:0,sweep:1}},{to:[22,9.7]},{to:[22,14.3],arc:{r:2.3,large:0,sweep:0}},{to:[22,17]},{to:[20.2,18.8],arc:{r:1.8,large:0,sweep:1}},{to:[3.8,18.8]},{to:[2,17],arc:{r:1.8,large:0,sweep:1}},{to:[2,14.3]},{to:[2,9.7],arc:{r:2.3,large:0,sweep:0}},{to:[2,7]},{to:[3.8,5.2],arc:{r:1.8,large:0,sweep:1}}]},dl={from:[12,1.6],segs:[{to:[20.4,4.9]},{to:[20.4,11.2]},{to:[12,22.4],arc:{r:13,large:0,sweep:1}},{to:[3.6,11.2],arc:{r:13,large:0,sweep:1}},{to:[3.6,4.9]},{to:[12,1.6]}]};function hi(e,t,n){return{from:[e-n,t],segs:[{to:[e+n,t],arc:{r:n,large:0,sweep:1}},{to:[e-n,t]}]}}var gi={head:[13.2,4.3,2.2],limbs:[[[12.6,8.6],[11.2,15],[17.8,18.4],[9.4,18.4]],[[12.4,9.8],[16,14.4]]]},ul=[[6,10.5],[15,10.5],[16.5,7],[18.5,5.5],[20,6.5],[21.5,8.5],[19.5,10],[18,12],[18,19],[16.5,19],[15.5,14],[9.5,14],[8.5,19],[7,19],[6.5,13]],fl=[[5.4,9.8],[14.6,9.8],[16.1,6.4],[18.4,4.6],[20.5,5.9],[22.4,8.6],[19.9,10.6],[18.8,12.3],[18.8,19.8],[15.8,19.8],[15,14.8],[10.1,14.8],[9.2,19.8],[6.2,19.8],[5.6,13.2]],ro=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:ci(ri),solid:L(li(ri))},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:di(ii),solid:L(ui(ii))},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:[ge(2.5,2.5,19,19,3.5),Ot(He(_e,4.6,4.3,.66))].join(" "),solid:L(Ve(_e)),solidLarge:L(_(1.5,1.5,21,21,4.5),K(_(3.9,3.9,16.2,16.2,2.6)),Ve(He(_e,4.9,4.7,.62),2.2))},{key:"first-aid",label:"First aid",group:"facilities",path:dn(fi)+"Z",solid:L(q(fi.map(([e,t])=>[e+(e-12)*.08,t+(t-12)*.08])))},{key:"coat-check",label:"Coat check",group:"facilities",path:"M10 6.5a2 2 0 1 1 2 2V10 M12 10 3.4 16.9a1.4 1.4 0 0 0 .9 2.6h15.4a1.4 1.4 0 0 0 .9-2.6Z",solid:L(ue(12,6.2,2.2,180,450,2.3),F([12,8.4],[12,10.5],2.3),X([[12,10.2],[3.2,18.8],[20.8,18.8]],2.8,!0))},{key:"atm",label:"ATM / cash",group:"facilities",path:[ge(2,6,20,12,2),ae(12,12,2.75),"M6 12h.01 M18 12h.01"].join(" "),solid:L(_(1.5,5.5,21,13,2.4),K(z(12,12,3.2)))},{key:"info",label:"Info point",group:"facilities",path:[ae(12,12,9.5),"M10.8 11H12v5.8 M12 7.6h.01"].join(" "),solid:L(z(12,4.9,2.4),_(10.3,9.2,3.4,12.3,1),_(8.2,9.2,4,3,1),_(8.2,18.5,7.6,3,1))},{key:"lost-found",label:"Lost & found",group:"facilities",path:[ae(10.5,10.5,7.5),"M16 16l5.5 5.5","M8.4 8.4a2.1 2.1 0 1 1 3 1.9c-.6.4-.9.8-.9 1.6 M10.5 14.6h.01"].join(" "),solid:L(ue(12,7.6,4.2,180,405,3.4),X([[14.97,10.57],[12,13],[12,15]],3.4),z(12,20,2.1))},{key:"restrooms",label:"Toilets",group:"facilities",path:[ci(ai),di(si)].join(" "),solid:L(li(ai),ui(si))},{key:"charging",label:"Charging point",group:"facilities",path:[ge(6,2,12,20,2.5),"M13.2 6.2 9.6 12h4.8l-3.6 5.8"].join(" "),solid:L(q(il))},{key:"smoking",label:"Smoking area",group:"facilities",path:[ge(2,14.5,14.5,4,1),"M6.5 14.5v4","M15.5 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4 M19 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4"].join(" "),solid:L(_(1.5,14,4.2,5,1.2),_(6.8,14,10.4,5,1.2),X([[15.9,11.4],[17.3,8.9],[15.9,6.4],[17.1,3.9]],2.2),X([[19.6,11.4],[21,8.9],[19.6,6.4],[20.8,3.9]],2.2))},{key:"no-smoking",label:"No smoking",group:"facilities",path:[ae(12,12,9.5),"M5.3 5.3l13.4 13.4","M5.5 10.5h13v3h-13Z"].join(" "),solid:L(z(12,12,10.6),K(z(12,12,8)),F([6,6],[18,18],2.8),_(5,10.4,3,3.2,.6),_(16,10.4,3,3.2,.6))},{key:"food",label:"Food",group:"food-drink",path:"M5 2.5V8a2.5 2.5 0 0 0 5 0V2.5 M7.5 2.5v19 M18.5 13.5h-2c-1.3 0-2-1-2-2.5 0-4 1.5-7 4-8.5v19",solid:L(X([[4.9,2.6],[4.9,8]],2.2),X([[10.1,2.6],[10.1,8]],2.2),X([[7.5,2.6],[7.5,8]],2.2),ue(7.5,8,2.6,0,180,2.2),F([7.5,10],[7.5,21.4],3),q([[19.4,2.2],[19.4,14.2],[16.2,14.2],[14.1,12],[14.1,9.4],[15.2,5.8],[17.3,3.3]]),F([18,13],[18,21.4],3))},{key:"bar",label:"Bar",group:"food-drink",path:"M3.5 3.5h17L12 13Z M6.2 6.5h11.6 M12 13v7.5 M8 20.5h8",solid:L(q([[2.8,3],[21.2,3],[12,13.6]]),F([12,12],[12,20.6],2.8),F([7.4,21],[16.6,21],2.8))},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 9h12v4.5a5.5 5.5 0 0 1-5.5 5.5h-1A5.5 5.5 0 0 1 4 13.5Z M16 10.5h1.2a2.75 2.75 0 0 1 0 5.5H16 M8 3v3 M12 3v3 M3 21.5h14",solid:L({from:[3.4,8.4],segs:[{to:[16.6,8.4]},{to:[16.6,13.4]},{to:[11,19.4],arc:{r:5.8,large:0,sweep:1}},{to:[9,19.4]},{to:[3.4,13.4],arc:{r:5.8,large:0,sweep:1}},{to:[3.4,8.4]}]},ue(17.2,13.25,2.5,270,450,2.4),F([7.8,2.6],[7.8,5.6],2.4),F([12.2,2.6],[12.2,5.6],2.4),F([2.6,21.6],[17.4,21.6],2.6))},{key:"water",label:"Water / drinks",group:"food-drink",path:sl,solid:"M12 1.2S4 8.9 4 14.5a8 8 0 0 0 16 0c0-5.6-8-13.3-8-13.3Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:al,solid:"M8.4 2.8 3.5 5l-1.9 6 4.2 1.4.4-.8v9.4h11.6v-9.4l.4.8 4.2-1.4-1.9-6-4.9-2.2c-.4 1.5-1.8 2.6-3.6 2.6s-3.2-1.1-3.6-2.6Z"},{key:"screen",label:"Screen",group:"facilities",path:[ge(2,3.5,20,13.5,2),"M12 17v3.5 M8 20.5h8","M10 7.8v5.9l5-2.95Z"].join(" "),solid:L(_(1.5,3,21,14.4,2.4),K(q([[9.6,6.7],[16,10.2],[9.6,13.7]])),_(10.6,16.5,2.8,4,0),F([7.4,21],[16.6,21],2.8))},{key:"sound-booth",label:"Sound booth",group:"facilities",path:["M6 3v9 M6 16v5 M12 3v3 M12 10v11 M18 3v10 M18 17v4",ae(6,14,2),ae(12,8,2),ae(18,15,2)].join(" "),solid:L(F([6,2.8],[6,21.2],1.8),F([12,2.8],[12,21.2],1.8),F([18,2.8],[18,21.2],1.8),_(3.2,11.6,5.6,4.8,1.4),_(9.2,5.6,5.6,4.8,1.4),_(15.2,12.6,5.6,4.8,1.4))},{key:"entrance",label:"Entrance",group:"navigation",path:"M11 7V3.5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v17a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V17 M2.5 12h13.5 M12.5 8.5 16 12l-3.5 3.5",solid:L(X([[11,6.5],[11,2.6],[21,2.6],[21,21.4],[11,21.4],[11,17.5]],2.6),F([2.8,12],[13.5,12],3.2),q([[12.6,7.8],[18,12],[12.6,16.2]]))},{key:"exit",label:"Exit",group:"navigation",path:"M13 7V3.5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v17a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V17 M8 12h13.5 M18 8.5l3.5 3.5-3.5 3.5",solid:L(X([[13,6.5],[13,2.6],[3,2.6],[3,21.4],[13,21.4],[13,17.5]],2.6),F([7.2,12],[17,12],3.2),q([[16.2,7.8],[21.6,12],[16.2,16.2]]))},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:[Ot(He(oi,-2,1.4,1.15)),"M15.5 13h6 M19 10.5l2.5 2.5-2.5 2.5"].join(" "),solid:L(Ve(He(oi,-2,1.4,1.15),2.7),F([15.6,13],[19.5,13],2.8),q([[18.4,9.4],[22.4,13],[18.4,16.6]]))},{key:"stairs",label:"Stairs",group:"navigation",path:cl,solid:"M1.5 22.5h21V2h-7.8v6.4H8.4v6.4H1.5Z"},{key:"elevator",label:"Elevator",group:"navigation",path:[ge(3.5,2.5,17,19,2.5),"M8.5 9.5 12 5.5l3.5 4Z M8.5 14.5l3.5 4 3.5-4Z"].join(" "),solid:L(q([[12,1.6],[19.6,10.2],[4.4,10.2]]),q([[4.4,13.8],[19.6,13.8],[12,22.4]]))},{key:"parking",label:"Parking",group:"navigation",path:[ge(3,3,18,18,3),"M9.5 17V7h3.75a3 3 0 0 1 0 6H9.5"].join(" "),solid:"M6.5 21V3H12a5.5 5.5 0 0 1 0 11h-1.9v7Z M10.1 6.6v3.8H12a1.9 1.9 0 0 0 0-3.8Z"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:Ot(_e),solid:L(Ve(_e))},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:["M4 9a6 6 0 1 1 12 0c0 3-1.8 4.3-3 5.2-1.1.8-1.6 1.7-1.6 3.1a3.6 3.6 0 0 1-6.2 2.1","M7.5 9a2.5 2.5 0 0 1 5 0c0 1.2-.7 1.9-1.6 2.5","M18.5 5.5a6.5 6.5 0 0 1 0 8"].join(" "),solid:L(ue(10,9,6,180,380,3),X([[15.64,11.05],[12.8,14.3],[11.5,17.2]],3),ue(8.2,17.2,3.3,0,150,3),ue(10,9,2.2,180,400,2.4),ue(13.38,9.5,6.5,322,398,2.6))},{key:"box-office",label:"Box office / tickets",group:"navigation",path:"M3 7.5A1.5 1.5 0 0 1 4.5 6h15A1.5 1.5 0 0 1 21 7.5V10a2 2 0 0 0 0 4v2.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 16.5V14a2 2 0 0 0 0-4Z M15 6v2 M15 11v2 M15 16v2",solid:L(ll,K(_(14.1,7,1.8,2.2,.9)),K(_(14.1,10.9,1.8,2.2,.9)),K(_(14.1,14.8,1.8,2.2,.9)))},{key:"escalator",label:"Escalator",group:"navigation",path:"M2.5 17H7l9-9h5.5v4h-4l-9 9h-6Z M11 4.5h.01 M11 8.2v3.3",solid:L(q([[2,16.4],[6.8,16.4],[15.8,7.4],[22,7.4],[22,12.6],[17.8,12.6],[8.8,21.6],[2,21.6]]),z(11,4.3,2.3),F([11,8],[11,11],2.6))},{key:"ramp",label:"Ramp",group:"navigation",path:"M2.5 19.5h19v-10Z M4.5 13.2 14 8.2 M10.53 7.76 14 8.2l-1.6 3.11",solid:L(q([[1.6,20.4],[22.4,20.4],[22.4,8.6]]),F([4.2,13.4],[13.2,8.6],2.6),q([[15.4,7.5],[13.16,11.84],[10.56,6.88]]))},{key:"taxi",label:"Taxi / rideshare",group:"navigation",path:["M9.5 2.5h5V5h-5Z M6.5 11 8 7h8l1.5 4",ge(3.5,11,17,6,2),"M6.5 17v2.5 M17.5 17v2.5 M7 14h.01 M17 14h.01"].join(" "),solid:L(_(9,1.8,6,3.4,.8),q([[6,11.4],[7.6,6.4],[16.4,6.4],[18,11.4]]),_(2.8,10.6,18.4,7,2.2),K(z(6.8,14,1.3)),K(z(17.2,14,1.3)),_(4.8,16,3.6,5.2,1.2),_(15.6,16,3.6,5.2,1.2))},{key:"transit",label:"Bus / transit",group:"navigation",path:[ge(4.5,2.5,15,16,3),"M4.5 10.5h15 M9 5.5h6 M7.5 18.5V21 M16.5 18.5V21 M8 14.5h.01 M16 14.5h.01"].join(" "),solid:L(_(4,2,16,17,3.2),K(_(6.2,5.8,11.6,5,1)),K(z(8,14.5,1.3)),K(z(16,14.5,1.3)),_(6,17,3.4,5,1.2),_(14.6,17,3.4,5,1.2))},{key:"bike-parking",label:"Bike parking",group:"navigation",path:[ae(6,14.5,4),ae(18,14.5,4),"M6 14.5 9 7.5h6.5L18 14.5 M9 7.5l2.5 7H6 M11.5 14.5l4-7 M7.5 6h3 M15.5 7.5 15 5.5h2"].join(" "),solid:L(z(6,14.5,4.9),K(z(6,14.5,2.7)),z(18,14.5,4.9),K(z(18,14.5,2.7)),X([[6,14.5],[9,7.5],[15.5,7.5],[18,14.5]],2.2),X([[9,7.5],[11.5,14.5],[15.5,7.5]],2.2),F([6,14.5],[11.5,14.5],2.2),F([7.2,5.8],[10.6,5.8],2.2),X([[15.4,7.3],[15,5.4],[17.2,5.4]],2.2))},{key:"meeting-point",label:"Meeting point",group:"navigation",path:["M9.5 2.5 12 5l2.5-2.5 M9.5 21.5 12 19l2.5 2.5 M2.5 9.5 5 12l-2.5 2.5 M21.5 9.5 19 12l2.5 2.5",ae(10,9.6,1.5),ae(14,9.6,1.5),"M7.5 15.5a2.5 2.5 0 0 1 5 0 M11.5 15.5a2.5 2.5 0 0 1 5 0"].join(" "),solid:L(X([[9.4,2.4],[12,5],[14.6,2.4]],2.6),X([[9.4,21.6],[12,19],[14.6,21.6]],2.6),X([[2.4,9.4],[5,12],[2.4,14.6]],2.6),X([[21.6,9.4],[19,12],[21.6,14.6]],2.6),z(9.7,9.3,2.2),z(14.3,9.3,2.2),hi(9.7,16,3),hi(14.3,16,3))},{key:"security",label:"Security / bag check",group:"facilities",path:"M12 2.5 19.5 5.5v6c0 4.6-3.2 8.4-7.5 10-4.3-1.6-7.5-5.4-7.5-10v-6Z M8.5 12l2.5 2.5 4.5-5",solid:L(dl,K(q([[7.4,12.2],[9,10.6],[10.9,12.5],[15,8.4],[16.6,10],[10.9,15.7]])))},{key:"lockers",label:"Lockers",group:"facilities",path:[ge(3.5,2.5,17,19,1.5),"M12 2.5v19 M6 6h3 M15 6h3 M9.5 11.5v2.5 M14.5 11.5v2.5"].join(" "),solid:L(_(3,2,8.4,20,1.4),K(_(5,5,4.4,1.7,.8)),K(_(8.6,10.8,1.5,3.8,.7)),_(12.6,2,8.4,20,1.4),K(_(14.6,5,4.4,1.7,.8)),K(_(13.9,10.8,1.5,3.8,.7)))},{key:"baby-change",label:"Baby change",group:"facilities",path:"M10 6.5l.8-3.3a1.2 1.2 0 0 1 2.4 0l.8 3.3 M8.5 6.5h7 M9.5 6.5l-.9 2.2a3 3 0 0 0-.1.9V19a2.5 2.5 0 0 0 2.5 2.5h2a2.5 2.5 0 0 0 2.5-2.5V9.6a3 3 0 0 0-.1-.9l-.9-2.2 M8.5 12.5h3 M8.5 16h3",solid:L(q([[9.6,6.2],[10.6,1.8],[13.4,1.8],[14.4,6.2]]),_(7.6,5.4,8.8,2.6,1),_(7.8,7.4,8.4,15,2.6),K(_(7.8,11.8,3.4,1.5,0)),K(_(7.8,15.4,3.4,1.5,0)))},{key:"prayer-room",label:"Prayer room",group:"facilities",path:[Ot(gi),"M3 21.5h18"].join(" "),solid:L(Ve(gi),_(2.4,20.2,19.2,2.6,1.3))},{key:"quiet-room",label:"Quiet room",group:"facilities",path:"M4 9h3.5l5-4v14l-5-4H4Z M15.5 9.5l5 5 M20.5 9.5l-5 5",solid:L(q([[2.6,8.4],[7.2,8.4],[13,3.6],[13,20.4],[7.2,15.6],[2.6,15.6]]),F([15.4,9.2],[20.8,14.8],2.8),F([20.8,9.2],[15.4,14.8],2.8))},{key:"wifi",label:"Wi-Fi",group:"facilities",path:[ln(12,19,11.5,218,322),ln(12,19,7.5,218,322),ln(12,19,3.5,218,322),"M12 19h.01"].join(" "),solid:L(ue(12,19.2,11,218,322,2.8),ue(12,19.2,6.9,218,322,2.8),z(12,19.2,2.2))},{key:"vip-lounge",label:"VIP lounge",group:"facilities",path:["M6.5 11V7a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v4","M3.5 11.5a1.5 1.5 0 0 1 3 0V14h11v-2.5a1.5 1.5 0 0 1 3 0v6h-17Z","M5.5 17.5V20 M18.5 17.5V20"].join(" "),solid:L(_(6,4,12,8.5,2.2),_(2.4,9.6,4.6,9,2.2),_(17,9.6,4.6,9,2.2),_(6,13.2,12,5.4,.6),F([5,18],[5,20.6],2.4),F([19,18],[19,20.6],2.4))},{key:"accessible-entrance",label:"Accessible entrance",group:"accessibility",path:[Ot(He(_e,.3,5,.62)),"M12.5 3.5H20a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-7.5"].join(" "),solid:L(Ve(He(_e,.3,5,.62),2.2),X([[13,2.8],[21.2,2.8],[21.2,21.2],[13,21.2]],2.6))},{key:"assistance-dog",label:"Assistance-dog area",group:"accessibility",path:[dn(ul)+"Z","M6 10.8 3.5 7.5","M10.5 10.5V6h4.5l1 2.5"].join(" "),solid:L(q(fl),F([6.2,11],[3.2,7.2],2.4),X([[10.5,11],[10.5,5.6],[15.2,5.6],[16.2,8.2]],2.2))}],yg=new Map(ro.map(e=>[e.key,e]));var mi=ro;var pi=new Map(mi.map(e=>[e.key,e]));function yi(e){return e?pi.get(e):void 0}function wi(e){return typeof e=="string"&&pi.has(e)}var Sg=mi.map(e=>e.key);function hl(e){if(!Number.isFinite(e))return 0;let t=(e%360+360)%360;return Object.is(t,-0)||Math.abs(t)<1e-9?0:t}function un(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 gl(e){return e==="row"?"signed180":"unsigned360"}function ve(e,t){return gl(e)==="signed180"?un(t):hl(t)}function Ce(e,t,n){let o=r=>({x:r.x+t,y:r.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(r=>r.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=lr(e.outlinePath,t,n)),e.holes&&(e.holes=te(e.holes).map(r=>r.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.holes&&(e.holes=te(e.holes).map(r=>r.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 fn(e,t,n){return n?rr(e,t,n):{x:e.x,y:e.y}}function bl(e,t,n){let o=r=>fn(r,t,n);e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=ct(e.outlinePath,o,1,!1)),e.holes&&(e.holes=te(e.holes).map(r=>r.map(o)))}function ml(e,t,n){let o=e.rotation??0;if(e.points?.length){let r={x:e.points.reduce((s,c)=>s+c.x,0)/e.points.length,y:e.points.reduce((s,c)=>s+c.y,0)/e.points.length},a=fn(r,t,n),i=s=>({x:s.x+a.x-r.x,y:s.y+a.y-r.y});e.points=e.points.map(i),e.holes&&(e.holes=te(e.holes).map(s=>s.map(i)))}else if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){let r={x:e.x+e.width/2,y:e.y+e.height/2},a=fn(r,t,n);e.x+=a.x-r.x,e.y+=a.y-r.y}e.rotation=ve("shape",o+n)}function xi(e,t,n){if(!Number.isFinite(n)||!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new RangeError("group_rotation_must_be_finite");if(n===0)return;let o=r=>fn(r,t,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)}),e.rotation=ve("row",e.rotation+n);break;case"table":case"booth":e.center=o(e.center),e.rotation=ve(e.type,e.rotation+n);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=te(e.holes).map(r=>r.map(o)));break;case"section":bl(e,t,n);break;case"shape":ml(e,t,n);break;case"text":e.position=o(e.position),e.rotation=ve("text",e.rotation+n);break;case"decorImage":{let r={x:e.x+e.width/2,y:e.y+e.height/2},a=o(r);e.x+=a.x-r.x,e.y+=a.y-r.y,e.rotation=ve("decorImage",(e.rotation??0)+n);break}}}var pl=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","wheelchairPlaces"],Si=(e,t,n)=>Number.isInteger(e)&&e>=t&&e<=n;function Ii(e){let t={};for(let n of pl){if(!(n in e))continue;let o=e[n];delete e[n],o!==void 0&&(t[n]=o)}for(let n of["bookAsWhole","variableOccupancy"])if(t[n]!==void 0&&typeof t[n]!="boolean")throw new u("invalid_operation",`${n} must be true or false`);if(t.bookAsWhole===!0&&t.variableOccupancy===!0)throw new u("invalid_operation","A standing area cannot be sold whole and by party size at the same time");if(t.variableOccupancy===!1&&(t.minOccupancy!==void 0||t.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with party-size selling");for(let n of["minOccupancy","maxOccupancy"])if(t[n]!==void 0&&!Si(t[n],1,oe))throw new u("invalid_operation",`${n} must be a whole number from 1 to ${oe}`);if(t.wheelchairPlaces!==void 0&&!Si(t.wheelchairPlaces,0,oe))throw new u("invalid_operation",`wheelchairPlaces must be a whole number from 0 to ${oe}`);return t}function vi(e,t){if(Object.assign(e,t),t.bookAsWhole===!0&&delete e.variableOccupancy,t.variableOccupancy===!0&&delete e.bookAsWhole,e.bookAsWhole||delete e.bookAsWhole,!e.variableOccupancy){if(t.minOccupancy!==void 0||t.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on an area sold by party size",{gaAreaId:e.id});delete e.variableOccupancy,delete e.minOccupancy,delete e.maxOccupancy}e.wheelchairPlaces||delete e.wheelchairPlaces;let n=Ke(e);if(n&&e.inventorySegments!==void 0)throw new u("invalid_operation",`Joined area "${e.label}" is sold per person: its places keep the identities of the areas it was joined from, so it cannot become one box`,{gaAreaId:e.id});if(n&&e.capacity>an)throw new u("invalid_operation",qr,{gaAreaId:e.id,capacity:e.capacity,max:an});if(n&&Ae(e.label))throw new u("invalid_operation",`Area label "${e.label}" uses SeatLayer's reserved GA namespace`,{gaAreaId:e.id});if(n==="variable"&&(!Number.isInteger(e.minOccupancy)||!Number.isInteger(e.maxOccupancy)||e.minOccupancy<1||e.maxOccupancy<e.minOccupancy||e.maxOccupancy>e.capacity))throw new u("invalid_operation",`Area "${e.label}" needs whole-number fewest and most guests from 1 to its ${e.capacity}-person capacity`,{gaAreaId:e.id,capacity:e.capacity});if(e.wheelchairPlaces!==void 0&&e.wheelchairPlaces>e.capacity)throw new u("invalid_operation",`Area "${e.label}" has ${e.capacity} places, so at most ${e.capacity} can be wheelchair places`,{gaAreaId:e.id,capacity:e.capacity})}function Ci(e,t){let n=t.filter(a=>Ke(a));if(!n.length)return;let o=new Map(t.map(a=>[a.id,a])),r=new Map(n.map(a=>[a.label,a.id]));for(let a of j(e))for(let i of a.objects){let s=i.type==="gaArea"?o.get(i.id)??i:i,c=[];s.type==="row"?c=ee(s).map(l=>l.label):s.type==="table"?c=s.bookAsWhole||s.variableOccupancy?[s.label]:me(s).map(l=>l.label):s.type==="booth"?c=[s.label]:s.type==="gaArea"&&(c=de(s));for(let l of c){let d=r.get(l);if(d&&d!==s.id)throw new u("invalid_operation",`Inventory label "${l}" is already in use; an area sold as one box needs a unique label`,{gaAreaId:d,inventoryLabel:l,conflictingObjectId:s.id})}}}var Oi=40,Pi=160;function yl(e,t){let n=e.normalize("NFKC").trim();if(n.length>Oi)throw new u("invalid_operation",`${t} entrance must be at most ${Oi} characters`);return n}function hn(e,t){let n={};if("labelStyle"in e){let o=e.labelStyle;if(delete e.labelStyle,o!==void 0){if(o.color!==void 0)throw new u("invalid_operation",`${t} names use the chart's label colour; only visible and size can change`);if(Se(o,t),o.visible!==void 0&&typeof o.visible!="boolean")throw new u("invalid_operation",`${t} name visibility must be true or false`);n.labelStyle=o}}if("entrance"in e){let o=e.entrance;if(delete e.entrance,o===null)n.entrance=null;else if(o!==void 0){if(typeof o!="string")throw new u("invalid_operation",`${t} entrance must be text`);n.entrance=yl(o,t)||null}}return n}function gn(e,t){if(t.labelStyle){let o=Be(e.labelPresentation,t.labelStyle);o?.visible===!0&&delete o.visible,o&&Object.keys(o).length?e.labelPresentation=o:delete e.labelPresentation}let n=e.entrance;t.entrance===null?delete e.entrance:t.entrance!==void 0&&(e.entrance=t.entrance),e.entrance!==n&&delete e.entranceGateId}function Ri(e){if(!("chairNumbering"in e))return;let t=e.chairNumbering;if(delete e.chairNumbering,t===null)return null;let n=wr(t);if(n)throw new u("invalid_operation",n);return t}function Ai(e,t){if(t===void 0)return;let n=t===null?void 0:xr({...e.chairNumbering,...t});n?e.chairNumbering=n:delete e.chairNumbering}function Mi(e){let t={};if("boothType"in e){let n=e.boothType;if(delete e.boothType,n===null)t.boothType=null;else if(n!==void 0){if(!Ur.includes(n))throw new u("invalid_operation","boothType must be inline, corner, peninsula or island");t.boothType=n}}if("commercial"in e){let n=e.commercial;if(delete e.commercial,n===null)t.note=null;else if(n!==void 0){let o=Object.keys(n).filter(r=>r!=="note");if(o.length)throw new u("invalid_operation",`Booth commercial supports only a note (got ${o.join(", ")})`);if(n.note===null)t.note=null;else if(n.note!==void 0){if(typeof n.note!="string")throw new u("invalid_operation","Booth note must be text");let r=n.note.normalize("NFKC").trim();if(r.length>Pi)throw new u("invalid_operation",`Booth note supports at most ${Pi} characters`);t.note=r||null}}}return t}function _i(e,t){t.boothType===null?delete e.boothType:t.boothType!==void 0&&(e.boothType=t.boothType),t.note===null?delete e.commercial:t.note!==void 0&&(e.commercial={note:t.note})}var wl=[{role:"bar",label:"Bar",icon:"\u{1F378}",kind:"rect",width:160,height:44,fill:"#3a2f4a",blurb:"Drinks counter.",heightM:1.1},{role:"entrance",label:"Entrance",icon:"\u21E5",kind:"rect",width:90,height:30,fill:"#26433a",blurb:"Way in.",heightM:2.7},{role:"exit",label:"Exit",icon:"\u21E4",kind:"rect",width:90,height:30,fill:"#4a2f2f",blurb:"Emergency / way out.",heightM:2.7},{role:"restroom",label:"Restrooms",icon:"\u{1F6BB}",kind:"rect",width:90,height:60,fill:"#2b3550",blurb:"Toilets.",heightM:2.4},{role:"screen",label:"Screen",icon:"\u{1F4FD}\uFE0F",kind:"rect",width:320,height:18,fill:"#203454",blurb:"Projection surface.",heightM:6},{role:"sound",label:"Sound booth",icon:"\u{1F39B}\uFE0F",kind:"rect",width:70,height:50,fill:"#2b2b3a",blurb:"FOH / mixing desk.",heightM:1.45},{role:"concession",label:"Concession",icon:"\u{1F37F}",kind:"rect",width:120,height:44,fill:"#4a3f26",blurb:"Food stand.",heightM:1.1},{role:"coat",label:"Coat check",icon:"\u{1F9E5}",kind:"rect",width:90,height:40,fill:"#2f3a4a",blurb:"Cloakroom.",heightM:1.1},{role:"wall",label:"Wall",icon:"",kind:"rect",width:220,height:14,fill:"#1b2233",blurb:"Structural divider.",heightM:2.8},{role:"rail",label:"Safety rail",icon:"",kind:"rect",width:220,height:7,fill:"#5b6472",blurb:"Guardrail along a tier or balcony edge.",heightM:1.1},{role:"suite",label:"Suite",icon:"\u25C7",kind:"rect",width:180,height:90,fill:"#31394a",blurb:"Open-front hospitality suite.",heightM:3},{role:"obstruction",label:"Obstruction",icon:"\u25CF",kind:"ellipse",width:28,height:28,fill:"#343943",blurb:"Pillar or sightline obstruction.",heightM:4.5}],ki=new Map(wl.map(e=>[e.role,e]));function Pt(e){return ki.get(e)}function Li(e,t,n){let o=ki.get(e);if(!o)throw new Error(`unknown d\xE9cor role: ${e}`);let r=o.icon?`${o.icon} ${o.label}`:o.label;return{type:"shape",id:n,kind:o.kind,x:t.x-o.width/2,y:t.y-o.height/2,width:o.width,height:o.height,fill:o.fill,label:o.role==="wall"?void 0:r,role:e,...o.heightM!==void 0?{heightM:o.heightM}:{}}}var Ei=["in","out","both"];function io(e){return e?.type==="shape"&&e.gate!=null&&typeof e.gate=="object"}function Ti(e){return e?.type==="shape"&&!e.gate&&(e.role==="entrance"||e.role==="exit")&&e.kind!=="line"&&e.kind!=="polyline"}function Ye(e){return e.type==="row"||e.type==="section"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function ji(e){return e==="out"?"exit":"entrance"}function xl(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function ao(e){let t=new Map;for(let n of xl(e))io(n)&&t.set(n.id,n);return t}function so(e){if(e.gate.hideFromBuyers)return;let t=e.label?.normalize("NFKC").trim();return t?t.slice(0,40):void 0}function co(e){let t=new Set([...ao(e).values()].map(n=>n.label?.trim().toLowerCase()));for(let n=0;n<26;n++){let o=`Gate ${String.fromCharCode(65+n)}`;if(!t.has(o.toLowerCase()))return o}for(let n=27;;n++)if(!t.has(`gate ${n}`))return`Gate ${n}`}function Fi(e,t,n){let o=t*.46,r=Math.max(e.length,2)*o*.6,a=n?o*1.25:0;return Math.round(r+a+t)}var fo={color:oo.accessibility,width:4},ho="Step-free route";function bn(e,t,n){if(typeof e!="string")throw new u("invalid_operation",`${n} must be text`);let o=e.normalize("NFKC").trim();if(!o)throw new u("invalid_operation",`${n} cannot be empty`);if(o.length>t)throw new u("invalid_operation",`${n} must be at most ${t} characters`);return o}function Il(e){if(!Ei.includes(e))throw new u("invalid_operation","Gate use must be in, out or both")}function uo(e,t){if(typeof e!="boolean")throw new u("invalid_operation",`${t} must be true or false`)}function Rt(e){return j(e).flatMap(t=>t.objects)}function $i(e,t){let n=ao(e).get(t);if(!n)throw new u("object_not_found",`Unknown gate id: ${t}. Call get_chart to list gate ids.`,{gateId:t});return n}function Bi(e){let t=e.height??40,n=Fi(e.label??"",t,e.gate?.stepFree===!0),o=(e.x??0)+(e.width??n)/2;e.x=o-n/2,e.width=n,e.kind==="rect"&&(e.cornerRadius=t/2)}function Ki(e,t){e.type!=="row"&&(t?e.entrance=t:delete e.entrance)}var Di=e=>e.type==="row"?void 0:e.entrance;function vl(e,t){let n=so(t),o=[];for(let r of Rt(e))!Ye(r)||r.entranceGateId!==t.id||(Ki(r,n),o.push(r.id));return o}function go(e,t,n){n.name!==void 0&&(e.label=bn(n.name,40,"Gate name")),n.use!==void 0&&(Il(n.use),t.use=n.use),n.stepFree!==void 0&&(uo(n.stepFree,"Step-free"),n.stepFree?t.stepFree=!0:delete t.stepFree),n.opens!==void 0&&(n.opens===null||typeof n.opens=="string"&&!n.opens.trim()?delete t.opens:t.opens=bn(n.opens,40,"Opening time")),n.hideFromBuyers!==void 0&&(uo(n.hideFromBuyers,"Hide from buyers"),n.hideFromBuyers?t.hideFromBuyers=!0:delete t.hideFromBuyers),e.gate=t,e.role=ji(t.use)}function zi(e,t,n,o=0){let r={type:"shape",id:e,kind:"rect",x:t.x,y:t.y-40/2,width:0,height:40,fill:oo.navigation,...o?{rotation:o}:{},heightM:Pt("entrance")?.heightM??2.7};return go(r,{use:"in"},n),Bi(r),r}function Cl(e,t){let n=O(e,t.floorId);if(!Number.isFinite(t.center?.x)||!Number.isFinite(t.center?.y))throw new u("invalid_operation","A gate needs a finite centre point");if(t.rotation!==void 0&&(!Number.isFinite(t.rotation)||t.rotation<0||t.rotation>360))throw new u("invalid_operation","Gate rotation must be from 0 to 360");let o=T(e,"gate",t.idFactory,new Set),r=zi(o,t.center,{...t,name:t.name??co(e)},t.rotation??0);return n.objects.push(r),{changed:!0,floorId:n.floorId,gate:structuredClone(r)}}function Ol(e,t){let n=$i(e,t.gateId);if(!Object.keys(t.patch).length)throw new u("invalid_operation","At least one gate change is required");let o=JSON.stringify(n),r=structuredClone(n);go(r,r.gate,t.patch),(t.patch.name!==void 0||t.patch.stepFree!==void 0)&&Bi(r);let a=JSON.stringify(r)!==o;a&&Object.assign(n,r);let i=vl(e,n);return{changed:a,gate:structuredClone(n),servedObjectIds:i}}function Pl(e,t){let n=Rt(e).find(a=>a.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.type!=="shape"||!Ti(n))throw new u("invalid_operation","Only an Entrance or Exit landmark can become a gate");let o=n.label?.replace(/^[^\p{L}\p{N}]+/u,"").trim(),r=!o||/^(entrance|exit)$/i.test(o);return go(n,{use:n.role==="exit"?"out":"in"},{...t,name:t.name??(r?co(e):o.slice(0,40))}),{changed:!0,gate:structuredClone(n)}}function Rl(e,t){if(!t.objectIds.length)throw new u("invalid_operation","At least one object id is required");let n=Rt(e),o=new Map(n.map(f=>[f.id,f])),r=t.objectIds.filter(f=>!o.has(f));if(r.length)throw new u("object_not_found",`Unknown object id(s): ${r.join(", ")}`,{objectIds:r});let a=t.objectIds.filter(f=>!Ye(o.get(f)));if(a.length)throw new u("invalid_operation","Only sections, rows, tables, booths and standing areas have an entrance",{objectIds:a});let i=t.gateId===null?null:$i(e,t.gateId),s=new Set(t.objectIds.flatMap(f=>{let g=o.get(f);return g.type==="section"?[g.logicalSectionId??g.id]:[]})),c=n.filter(f=>Ye(f)&&(t.objectIds.includes(f.id)||f.type==="section"&&s.has(f.logicalSectionId??f.id))),l=i?so(i):void 0,d=!1;for(let f of c){let g=`${f.entranceGateId??""}|${Di(f)??""}`;i?f.entranceGateId=i.id:delete f.entranceGateId,Ki(f,l),`${f.entranceGateId??""}|${Di(f)??""}`!==g&&(d=!0)}return{changed:d,objectIds:c.map(f=>f.id)}}function bo(e,t){let n=new Map(t.filter(io).map(r=>[r.id,r.label?.trim()??""]));if(!n.size)return[];let o=[];for(let r of Rt(e))!Ye(r)||!r.entranceGateId||!n.has(r.entranceGateId)||(r.type!=="row"&&r.entrance?.trim()===n.get(r.entranceGateId)&&delete r.entrance,delete r.entranceGateId,o.push(r.id));return o}function Al(e,t){for(let n of e){if(!Ye(n)||!n.entranceGateId)continue;let o=t.get(n.entranceGateId);o&&(n.entranceGateId=o)}}function Ui(e,t,n=ho,o=!0){return{type:"shape",id:e,kind:t.length===2?"line":"polyline",label:bn(n,40,"Route name"),points:t.map(r=>({x:r.x,y:r.y})),stroke:{...fo},lineCap:"round",lineJoin:"round",endEnding:"arrow",route:o?{stepFree:!0}:{}}}function Ml(e,t){let n=O(e,t.floorId);if(!Array.isArray(t.points)||t.points.length<2||t.points.length>200||t.points.some(r=>!Number.isFinite(r?.x)||!Number.isFinite(r?.y)))throw new u("invalid_operation","A route needs 2 to 200 finite points");let o=Ui(T(e,"route",t.idFactory,new Set),t.points,t.name,t.stepFree??!0);return n.objects.push(o),{changed:!0,floorId:n.floorId,route:structuredClone(o)}}function _l(e,t){let n=Rt(e).find(r=>r.type==="shape"&&r.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.kind!=="line"&&n.kind!=="polyline")throw new u("invalid_operation","Only a line or path can be a route");let o=JSON.stringify(n);if(t.route===null)delete n.route;else{let r={...n.route??{}};t.route.stepFree!==void 0?(uo(t.route.stepFree,"Step-free"),t.route.stepFree?r.stepFree=!0:delete r.stepFree):n.route||(r.stepFree=!0),t.route.name!==void 0?n.label=bn(t.route.name,40,"Route name"):n.label?.trim()||(n.label=ho),n.route||(n.stroke={...fo}),n.route=r}return{changed:JSON.stringify(n)!==o,shape:structuredClone(n)}}function Gl(e,t){let n=O(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let r=o.map(x=>n.objects.find(m=>m.type==="table"&&m.id===x)),a=o.filter((x,m)=>!r[m]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one table change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&N(e,i.categoryKey),i.fill!==void 0&&i.fill!==null&&(i.fill=D(i.fill,"Table surface color"));let s=i.seatCount!==void 0,c=i.seatCountsBySide!==void 0;if(c){if(i.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(i.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let x=["top","bottom","left","right"],m=Object.keys(i.seatCountsBySide);if(m.length!==x.length||m.some(C=>!x.includes(C)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let C of x){let P=i.seatCountsBySide[C];if(!Number.isInteger(P)||P<0||P>40)throw new u("invalid_operation",`seatCountsBySide.${C} must be a whole number from 0 to 40`)}let v=x.reduce((C,P)=>C+i.seatCountsBySide[P],0);if(v<1||v>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&i.seatCount!==v)throw new u("invalid_operation",`seatCount must equal the ${v}-chair seatCountsBySide total`);i.seatCount=v,i.sides=x.filter(C=>i.seatCountsBySide[C]>0)}if(i.seatCount!==void 0&&(!Number.isInteger(i.seatCount)||i.seatCount<1||i.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(i.shape!==void 0&&i.shape!=="round"&&i.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(i.automaticRadius!==void 0&&typeof i.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(i.shape==="rect"&&i.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(i.bookAsWhole===!0&&i.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(i.variableOccupancy===!1&&(i.minOccupancy!==void 0||i.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(x,m,v,C)=>{if(m!==void 0&&(!Number.isFinite(m)||m<v||m>C))throw new u("invalid_operation",`${String(x)} must be from ${v} to ${C}`)};if(l("rotation",i.rotation,0,360),l("radius",i.radius,24,160),l("seatArc",i.seatArc,120,360),l("width",i.width,40,320),l("height",i.height,30,240),i.minOccupancy!==void 0&&(!Number.isInteger(i.minOccupancy)||i.minOccupancy<1||i.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(i.maxOccupancy!==void 0&&(!Number.isInteger(i.maxOccupancy)||i.maxOccupancy<1||i.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(i.sides!==void 0){let x=new Set(["top","bottom","left","right"]);if(!i.sides.length||i.sides.length>4||new Set(i.sides).size!==i.sides.length||i.sides.some(m=>!x.has(m)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=$e(i,"Table"),f=en(i,"Table"),g=hn(i,"Table"),h=Ri(i),b=r.map(x=>{if(x.seatCountsBySide&&!c&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${x.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:x.id});let m=structuredClone(x);if(Object.assign(m,i),gn(m,g),Ai(m,h),i.fill===null&&delete m.fill,m.shape==="round")delete m.seatCountsBySide,m.automaticRadius===!0?m.radius=Nr(m.seatCount,m.seatArc):delete m.automaticRadius;else{if(i.automaticRadius===!0)throw new u("invalid_operation",`Table "${m.label}" is rectangular and cannot use automatic radius`,{tableId:m.id});delete m.automaticRadius}if(m.overrides&&i.seatCount!==void 0&&(m.overrides=m.overrides.filter(v=>v.index<m.seatCount),m.overrides.length||delete m.overrides),i.bookAsWhole===!1&&delete m.bookAsWhole,i.variableOccupancy===!1&&(delete m.variableOccupancy,delete m.minOccupancy,delete m.maxOccupancy),m.bookAsWhole||delete m.bookAsWhole,m.variableOccupancy||delete m.variableOccupancy,m.bookAsWhole&&m.variableOccupancy)throw new u("invalid_operation",`Table "${m.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:m.id});if((m.bookAsWhole||m.variableOccupancy)&&m.overrides?.length)throw new u("invalid_operation",`Table "${m.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:m.id,overriddenChairIndices:m.overrides.map(v=>v.index)});if(m.bookAsWhole)delete m.minOccupancy,delete m.maxOccupancy;else if(m.variableOccupancy){if(!Number.isInteger(m.minOccupancy)||!Number.isInteger(m.maxOccupancy)||m.minOccupancy<1||m.maxOccupancy<m.minOccupancy||m.maxOccupancy>m.seatCount)throw new u("invalid_operation",`Table "${m.label}" needs whole-number minimum and maximum guests from 1 to its ${m.seatCount}-chair capacity`,{tableId:m.id,seatCount:m.seatCount})}else{if(i.minOccupancy!==void 0||i.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:m.id});delete m.minOccupancy,delete m.maxOccupancy}if(f&&delete m.displayType,d&&delete m.displayLabel,m.shape==="rect"){if(m.width??=80,m.height??=50,m.seatCountsBySide){let v=["top","bottom","left","right"],C=v.reduce((P,k)=>P+m.seatCountsBySide[k],0);if(C!==m.seatCount)throw new u("invalid_operation",`Table "${m.label}" side counts total ${C}, but seatCount is ${m.seatCount}`,{tableId:m.id,seatCount:m.seatCount,seatCountsBySide:m.seatCountsBySide});m.sides=v.filter(P=>m.seatCountsBySide[P]>0)}}else m.radius??=40;if((m.bookAsWhole||m.variableOccupancy)&&Ae(m.label))throw new u("invalid_operation",`Grouped table label "${m.label}" uses SeatLayer's reserved GA namespace`,{tableId:m.id});return m}),p=new Map(b.map(x=>[x.id,x])),S=new Set(o),I=new Map;for(let x of j(e))for(let m of x.objects){let v=m.type==="table"?p.get(m.id)??m:m,C=[];v.type==="row"?C=ee(v).map(P=>P.label):v.type==="table"?C=v.bookAsWhole||v.variableOccupancy?[v.label]:me(v).map(P=>P.label):v.type==="booth"?C=[v.label]:v.type==="gaArea"&&(C=de(v));for(let P of C){let k=I.get(P);if(k&&(S.has(k)||S.has(v.id)))throw new u("invalid_operation",`Inventory label "${P}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:P,conflictingObjectIds:[k,v.id]});I.set(P,k??v.id)}}let y=!1,w=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius","chairNumbering","labelPresentation","entrance"];for(let[x,m]of r.entries()){let v=b[x],C=JSON.stringify(m);for(let P of w)P in v||delete m[P];Object.assign(m,v),JSON.stringify(m)!==C&&(y=!0)}return{floorId:n.floorId,changed:y,tableIds:o}}function $l(e,t){let n=O(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let r=o.map(p=>n.objects.find(S=>S.type==="booth"&&S.id===p)),a=o.filter((p,S)=>!r[S]);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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one booth change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&N(e,i.categoryKey);let s=(p,S,I,y)=>{if(S!==void 0&&(!Number.isFinite(S)||S<I||S>y))throw new u("invalid_operation",`${p} must be from ${I} to ${y}`)};s("width",i.width,30,400),s("height",i.height,30,400),s("rotation",i.rotation,0,360);let c=i.points===null;if(i.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let p=ur(i.points);if(!p.ok)throw new u("invalid_operation",p.message??"The booth outline is not a valid simple polygon")}let l=i.points!=null?i.points.map(p=>({x:p.x,y:p.y})):void 0;delete i.points;let d=$e(i,"Booth"),f=en(i,"Booth"),g=hn(i,"Booth"),h=Mi(i),b=!1;for(let p of r){let S=JSON.stringify(p);Object.assign(p,i),gn(p,g),_i(p,h),d&&delete p.displayLabel,f&&delete p.displayType,c?delete p.points:l&&(p.points=l),JSON.stringify(p)!==S&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Bl(e,t){let n=O(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 r=o.map(h=>n.objects.find(b=>b.type==="gaArea"&&b.id===h)),a=o.filter((h,b)=>!r[b]);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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one GA area change is required");if(i.label!==void 0){if(i.label=i.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(!i.label||i.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(i.categoryKey!==void 0&&N(e,i.categoryKey),i.capacity!==void 0&&(!Number.isInteger(i.capacity)||i.capacity<1||i.capacity>oe))throw new u("invalid_operation",`capacity must be an integer from 1 to ${oe}`);if(i.cornerRadius!==void 0&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=$e(i,"GA area"),c=en(i,"GA area"),l=hn(i,"GA area"),d=Ii(i);if(i.capacity!==void 0)for(let h of r){if(h.inventorySegments!==void 0&&i.capacity<h.capacity)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot be reduced below ${h.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:h.id,currentCapacity:h.capacity,requestedCapacity:i.capacity});if(h.inventorySegments!==void 0&&i.capacity>h.capacity&&eo(h,i.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot append that capacity safely`,{gaAreaId:h.id})}let f=r.map(h=>{let b=structuredClone(h),p=i.capacity===void 0?h.inventorySegments:eo(h,i.capacity);return Object.assign(b,i),gn(b,l),vi(b,d),p!==void 0&&(b.inventorySegments=p),s&&delete b.displayLabel,c&&delete b.displayType,b});Ci(e,f);let g=!1;for(let[h,b]of r.entries()){let p=f[h],S=JSON.stringify(b);for(let I of Object.keys(b))I in p||delete b[I];Object.assign(b,p),JSON.stringify(b)!==S&&(g=!0)}return{floorId:n.floorId,changed:g,gaAreaIds:o}}function po(e,t){if(t.length<3)return 0;let n=r=>H(r,t,void 0),o=0;for(let r of e)n(V(r))&&(r.type==="row"?o+=ee(r).length:r.type==="table"?o+=me(r).length:(r.type==="gaArea"||r.type==="booth")&&(o+=Pe(r)));return o}function Kl(e,t){let n=O(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)),r=t.objectIds.filter((s,c)=>!o[c]);if(r.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:r});let a=o,i=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)i.has(n.objects[s].id)&&n.objects.splice(s,1);return bo(e,a),{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,c)=>s+Pe(c),0),remainingObjectCount:n.objects.length}}function zl(e,t){let n=O(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let r=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!r[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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one text change is required");if(i.text!==void 0){if(i.text=i.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(!i.text||i.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(i.fontSize!==void 0&&(!Number.isFinite(i.fontSize)||i.fontSize<8||i.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(i.fontFamily!==void 0&&i.fontFamily!==null&&(i.fontFamily=i.fontFamily.normalize("NFKC").trim(),!i.fontFamily||i.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(i.rotation!==void 0&&(!Number.isFinite(i.rotation)||i.rotation<0||i.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(i.color!==void 0&&i.color!==null&&(i.color=D(i.color,"Text color")),i.bold!==void 0&&typeof i.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(i.italic!==void 0&&typeof i.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(i.width!==void 0&&i.width!==null&&(!Number.isFinite(i.width)||i.width<40||i.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(i.align!==void 0&&!["left","center","right"].includes(i.align))throw new u("invalid_operation","Text align must be left, center, or right");if(i.lineHeight!==void 0&&(!Number.isFinite(i.lineHeight)||i.lineHeight<.8||i.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(i.letterSpacing!==void 0&&(!Number.isFinite(i.letterSpacing)||i.letterSpacing<-2||i.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(i.underline!==void 0&&typeof i.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(i.opacity!==void 0&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(i.background!==void 0&&i.background!==null){i.background.color=D(i.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:f=.9}=i.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(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(l=>Object.prototype.hasOwnProperty.call(i,l))&&r.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(i.labelImportance!==void 0&&i.labelImportance!==null&&i.labelImportance!=="orientation"&&i.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(i.iconKey!==void 0){if(!wi(i.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(r.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 r){let d=JSON.stringify(l);i.iconKey!==void 0&&(l.iconKey=i.iconKey),i.text!==void 0&&(l.text=i.text),i.fontSize!==void 0&&(l.fontSize=i.fontSize),i.fontFamily===null?delete l.fontFamily:i.fontFamily!==void 0&&(l.fontFamily=i.fontFamily),i.rotation!==void 0&&(l.rotation=i.rotation),i.color===null?delete l.color:i.color!==void 0&&(l.color=i.color),i.bold!==void 0&&(i.bold?l.bold=!0:delete l.bold),i.italic!==void 0&&(i.italic?l.italic=!0:delete l.italic),i.width===null?delete l.width:i.width!==void 0&&(l.width=i.width),i.align!==void 0&&(i.align==="left"?delete l.align:l.align=i.align),i.lineHeight!==void 0&&(i.lineHeight===1.2?delete l.lineHeight:l.lineHeight=i.lineHeight),i.letterSpacing!==void 0&&(i.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=i.letterSpacing),i.underline!==void 0&&(i.underline?l.underline=!0:delete l.underline),i.opacity!==void 0&&(i.opacity===1?delete l.opacity:l.opacity=i.opacity),i.background===null?delete l.background:i.background!==void 0&&(l.background=i.background),i.labelImportance===null?delete l.labelImportance:i.labelImportance!==void 0&&(l.labelImportance=i.labelImportance),JSON.stringify(l)!==d&&(mt(l),c=!0)}return{floorId:n.floorId,changed:c,textIds:o}}function Ul(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r.slice().sort((g,h)=>g.origin.y-h.origin.y||g.origin.x-h.origin.x),s=g=>g.segmentedRow?.displayLabel??g.displayLabel??g.label,c=pr(i.map(g=>({label:s(g)})),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,f=!1;return i.forEach((g,h)=>{let b=c[h].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(g)!==b&&(f=!0,g.segmentedRow?g.segmentedRow.displayLabel=b:g.displayLabel=b),d!==void 0){if(d===null){g.displayType!==void 0&&(f=!0,delete g.displayType);return}g.displayType!==d&&(f=!0,g.displayType=d)}}),{floorId:n.floorId,changed:f,rows:i.map(g=>({id:g.id,displayLabel:s(g),...g.displayType?{displayType:g.displayType}:{}}))}}function Hl(e,t){let n=Jr.find(d=>d.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=t.rotation??0;if(!Number.isFinite(o))throw new u("invalid_operation","Block rotation must be a finite number of degrees");let r=O(e,t.floorId),a=new Set,i=n.build().map(d=>structuredClone(d));for(let d of i)d.id=T(e,d.type,t.idFactory,a),Ce(d,t.center.x,t.center.y),o%360&&xi(d,t.center,o);for(let d of n.categories)e.categories.some(f=>f.key===d.key)||e.categories.push({...d});let s=i.filter(d=>d.type==="row");if(s.length){let d=0;for(let f of r.objects){if(f.type!=="row")continue;let g=sn(f.label);g!=null&&(d=Math.max(d,g+1))}for(let f of s)f.label=B(d++)}let c=new Set(r.objects.flatMap(d=>"label"in d&&d.label?[d.label]:[]));for(let d of i){if((d.type==="table"||d.type==="booth")&&c.has(d.label)){let f=/^(.*?)(\d+)$/.exec(d.label),g=f?f[1]:`${d.label} `,h=f?Number.parseInt(f[2],10):1;do h++;while(c.has(`${g}${h}`));d.label=`${g}${h}`}"label"in d&&d.label&&c.add(d.label)}r.objects.push(...i);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let d=Ge(i);if(d){let f={type:"section",id:T(e,"sec",t.idFactory,a),label:n.sectionLabel,outline:d};r.objects.push(f),l=f.id}}return{floorId:r.floorId,blockKey:n.key,createdIds:[...i.map(d=>d.id),...l?[l]:[]],sectionId:l}}function Vl(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=$t(t,97),r=o.slice(1).reduce((a,i,s)=>a+Math.hypot(i.x-o[s].x,i.y-o[s].y),0);if(!Number.isFinite(r)||r<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:r}}function Xi(e,t){let n=O(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 r=Vl(t.path),a=ee(o),i=structuredClone(o);i.path=r.path,i.origin={...r.path.start};let s=ee(i),c=a.map((d,f)=>Math.hypot(d.x-s[f].x,d.y-s[f].y)),l=JSON.stringify(o.path)!==JSON.stringify(r.path)||o.origin.x!==r.path.start.x||o.origin.y!==r.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:r.length,averageSeatMovement:c.length?c.reduce((d,f)=>d+f,0)/c.length:0,maxSeatMovement:c.length?Math.max(...c):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Xl(e,t){let n=Xi(e,t);if(!n.changed)return n;let r=O(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return r.path=structuredClone(t.path),r.origin={...t.path.start},delete r.arcFanGeneration,delete r.rowBlockGeneration,n}function ql(e,t){let n=e.map((o,r)=>[...o,t[r]]);for(let o=0;o<3;o++){let r=o;for(let i=o+1;i<3;i++)Math.abs(n[i][o])>Math.abs(n[r][o])&&(r=i);if(Math.abs(n[r][o])<1e-9)return null;[n[o],n[r]]=[n[r],n[o]];let a=n[o][o];for(let i=o;i<4;i++)n[o][i]/=a;for(let i=0;i<3;i++){if(i===o)continue;let s=n[i][o];for(let c=o;c<4;c++)n[i][c]-=s*n[o][c]}}return[n[0][3],n[1][3],n[2][3]]}function Yl(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let r of e){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))return null;let a=[2*r.x,2*r.y,1],i=r.x**2+r.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*i;for(let c=0;c<3;c++)t[s][c]+=a[s]*a[c]}}let o=ql(t,n);return o?{x:o[0],y:o[1]}:null}function Hi(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function qi(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="section"&&h.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let r=t.strength??100;if(!Number.isFinite(r)||r<0||r>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=j(e).find(h=>h.id===n.floorId),i=t.mode==="outline"?Yl(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!i||!Number.isFinite(i.x)||!Number.isFinite(i.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(h=>h.type==="row"&&H(V(h),o.outline,o.holes)),c=s.filter(h=>!!h.path).map(h=>h.id),l=[],d=[],f=r/100;for(let h of s){if(h.path)continue;if(h.seatCount<2){l.push(h.id);continue}let b=Math.hypot(h.origin.x-i.x,h.origin.y-i.y);if(b<=h.seatSpacing/2+1e-6){l.push(h.id);continue}let p=2*Math.asin(h.seatSpacing/(2*b))/le,S=ee(h),I=Math.atan2(h.origin.x-i.x,h.origin.y-i.y)/le,w=(h.curve!==0?Math.sign(h.curve):S.length>1&&Math.sign(Hi(Math.atan2(S[1].x-i.x,S[1].y-i.y)/le-I))||1)*p*(h.seatCount-1);if(Math.abs(w)>320){l.push(h.id);continue}let x=-I,m=h.curve+(w-h.curve)*f,v=h.rotation+Hi(x-h.rotation)*f,C={...h,curve:m,rotation:v},k=ee(C).map((Y,J)=>Math.hypot(Y.x-S[J].x,Y.y-S[J].y));d.push({rowId:h.id,fromCurve:h.curve,targetCurve:w,resultCurve:m,fromRotation:h.rotation,resultRotation:v,rmsMovement:Math.sqrt(k.reduce((Y,J)=>Y+J**2,0)/k.length),maxMovement:Math.max(...k)})}let g=d.map(h=>h.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...i},strength:r,rows:d,skippedPathRowIds:c,skippedInvalidRowIds:l,averageMovement:g.length?g.reduce((h,b)=>h+b,0)/g.length:0,maxMovement:d.length?Math.max(...d.map(h=>h.maxMovement)):0}}function Jl(e,t){let n=qi(e,t),o=O(e,n.floorId),r=o.objects.find(i=>i.type==="section"&&i.id===n.sectionId),a=!1;for(let i of n.rows){let s=o.objects.find(c=>c.type==="row"&&c.id===i.rowId);(s.curve!==i.resultCurve||s.rotation!==i.resultRotation)&&(s.curve=i.resultCurve,s.rotation=i.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(r.smoothing??0)!==n.strength&&(r.smoothing=n.strength,a=!0),{...n,changed:a}}function Yi(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return r*a<-1e-9&&i*s<-1e-9}function Vi(e,t){return e.some((n,o)=>{let r=e[(o+1)%e.length];return t.some((a,i)=>Yi(n,r,a,t[(i+1)%t.length]))})}function Wl(e){if(e.length<3||e.length>256||Math.abs(it(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)&&Yi(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function mn(e,t,n){let o=O(e,t),r=o.objects.find(i=>(i.type==="section"||i.type==="gaArea"||i.type==="shape"&&i.kind==="polygon")&&i.id===n);if(!r)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});let a=r.type==="section"?r.outline:r.type==="shape"?dt(r):r.points;return{target:o,object:r,outer:a}}function Ji(e,t,n){return t.type==="shape"?{ids:[],units:0}:{ids:e.objects.filter(r=>r.id!==t.id&&r.type!=="section"&&H(V(r),n,void 0)).map(r=>r.id),units:po(e.objects.filter(r=>r.id!==t.id),n)}}function pn(e,t){let{target:n,object:o,outer:r}=mn(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Wl(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!H(l,r,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Vi(a,r))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let i=o.holes??[],s=t.holeIndex??i.length;if(o.type==="shape"&&t.holeIndex==null&&i.length>=$n)throw new u("invalid_operation",`A shape holds at most ${$n} cut-outs`);if(!Number.isInteger(s)||s<0||s>i.length||t.holeIndex!=null&&s>=i.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<i.length;l++){if(l===t.holeIndex)continue;let d=i[l];if(Vi(a,d)||H(a[0],d,void 0)||H(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let c=Ji(n,o,a);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:c.ids,excludedInventoryUnits:c.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Zl(e,t){let n=pn(e,t),{object:o}=mn(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 Wi(e,t){let{target:n,object:o}=mn(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 r=o.holes[t.holeIndex],a=Ji(n,o,r);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:r.length,excludedObjectIds:a.ids,excludedInventoryUnits:a.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ql(e,t){let n=Wi(e,t),{object:o}=mn(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function ed(e){let t=we(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Zi(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(i=>e.find(s=>s.type==="section"&&s.id===i)),r=n.filter((i,s)=>!o[s]);if(r.length)throw new u("object_not_found",`Unknown section id(s): ${r.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:r});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(i=>i.logicalSectionId??i.id))]}}function Qi(e,t){let n=O(e,t.floorId),o=Zi(n.objects,t.sectionIds),r=It(pe(e,n.floorId)),a=new Map(r.sections.map(h=>[h.id,h])),i=new Map(n.objects.map(h=>[h.id,h])),s=o.logicalSectionIds.flatMap(h=>a.get(h)?.objectIds??[]),c=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)).flatMap(h=>h.editor?.defaultCategoryKey?[h.editor.defaultCategoryKey]:[]));for(let h of s){let b=i.get(h);if(b)if(b.type==="row"||b.type==="table")for(let p of on(b).keys())c.add(p);else(b.type==="booth"||b.type==="gaArea")&&c.add(b.categoryKey)}let f=o.logicalSectionIds.every(h=>(a.get(h)?.seatCount??0)>0),g=o.logicalSectionIds.every(h=>a.get(h)?.objectIds.some(b=>{let p=i.get(b);return p?.type==="row"||p?.type==="table"||p?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:f,...f&&c.size===1?{categoryKey:[...c][0]}:!f&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:f?c.size!==1:!s.length&&d.size>1,viewApplicable:g}}function td(e,t){N(e,t.categoryKey);let n=Qi(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=O(e,n.floorId),r=new Set(n.objectIds),a=!1,i=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(!r.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 f={...d};return delete f.categoryKey,i++,a=!0,Object.keys(f).some(g=>g!=="index")?[f]:[]});l.length?c.overrides=l:delete c.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:i}}function yo(e,t){let n=O(e,t.floorId),o=Zi(n.objects,t.sectionIds),{requested:r}=o,a=structuredClone(t.patch),i=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(h=>!i.has(h));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(),r.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(),r.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=ed(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&&tn(a.labelPresentation,"Section"),a.labelStyle!==void 0&&Se(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(h=>h.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=D(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(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)):[],f=new Set,g=!1;for(let h of o.sections){let b=JSON.stringify(h);a.label!==void 0&&(h.label=a.label),a.labelPresentation===null?delete h.labelPresentation:a.labelPresentation!==void 0&&(h.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(h.elevation=a.elevation);let p=S=>{h.physical3dProvenance&&(delete h.physical3dProvenance[S],Object.keys(h.physical3dProvenance).length===0&&delete h.physical3dProvenance)};a.height===null?(delete h.height,p("height")):a.height!==void 0&&(h.height=a.height,h.physical3dProvenance={...h.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete h.rake,p("rake")):a.rake!==void 0&&(h.rake=a.rake,h.physical3dProvenance={...h.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete h.surfaceKind,p("surfaceKind")):a.surfaceKind!==void 0&&(h.surfaceKind=a.surfaceKind,h.physical3dProvenance={...h.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete h.color:a.color!==void 0&&(h.color=a.color),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}for(let h of d){let b=JSON.stringify(h),p=h.viewFromSeatUrl;a.displayLabel===null?delete h.displayLabel:a.displayLabel!==void 0&&(h.displayLabel=a.displayLabel);let S=h.entrance;if(a.entrance===null||a.entrance===""?delete h.entrance:a.entrance!==void 0&&(h.entrance=a.entrance),h.entrance!==S&&delete h.entranceGateId,a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete h.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(h.viewFromSeatUrl=a.viewFromSeatUrl),!h.viewFromSeatUrl||a.viewFromSeatMeta===null?delete h.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?h.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&h.viewFromSeatUrl!==p&&delete h.viewFromSeatMeta,a.labelStyle!==void 0){let I=Be(h.labelPresentation,a.labelStyle);I?h.labelPresentation=I:delete h.labelPresentation}a.zone===null?delete h.zone:a.zone!==void 0&&(h.zone=a.zone),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}return{floorId:n.floorId,changed:g,sectionIds:r,affectedSectionIds:[...f]}}function ea(e,t){let n=O(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 r=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&H(V(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:r.map(a=>a.id),inventoryUnits:r.reduce((a,i)=>a+Pe(i),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function nd(e,t){let n=ea(e,t),r=O(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete r.geometry,{...n,changed:!0}}function ta(e,t){let n=(...s)=>s.every(Number.isFinite),o,r=1,a=!1,i=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");i=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");i=t.factor!==1,r=t.factor;let s=V(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");i=(t.degrees%360+360)%360!==0;let c=t.degrees*Math.PI/180,l=Math.cos(c),d=Math.sin(c),f=V(e);o=g=>{let h=g.x-f.x,b=g.y-f.y;return{x:f.x+h*l-b*d,y:f.y+h*d+b*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 i&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=ct(e.outlinePath,o,r,a)),a&&e.edgeCurvature&&(e.edgeCurvature=dr(e.edgeCurvature)),e.holes&&(e.holes=te(e.holes).map(s=>s.map(o)))),{changed:i,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 od(e,t){let n=O(e,t.floorId),o=n.objects.find(r=>r.type==="section"&&r.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...ta(o,t.transform)}}function rd(e,t){let n=O(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 r=structuredClone(t.path);if(!Bt(r))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=st(r),i=JSON.stringify(o.outlinePath)!==JSON.stringify(r)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return i&&(o.outlinePath=r,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:i,segmentKinds:r.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function id(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function ad(e,t){return na(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function na(e,t){let n=O(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)],r=new Set,a=new Map,i=!1;try{for(let s of o){let c=n.objects.find(y=>y.type==="section"&&y.id===s);if(!c||!id(c))continue;let d=structuredClone(c);a.set(c.id,{section:c,snapshot:d});let f=JSON.stringify(c),g=(c.sourceOutline??c.outline).map(y=>({...y})),h=Math.min(100,Math.max(0,t.cornerSmoothing??c.cornerSmoothing??0)),p=(t.edgeCurvature===void 0?c.edgeCurvature:t.edgeCurvature??void 0)?.map(y=>Math.min(100,Math.max(-100,y))),S=p?.some(y=>Math.abs(y)>.5)===!0,I=h>.5||S?Kt(g,{cornerSmoothing:h,...S?{edgeCurvature:p}:{}}):null;I?(c.sourceOutline=g,c.outlinePath=I,c.outline=st(I),h>.5?c.cornerSmoothing=h:delete c.cornerSmoothing,S?c.edgeCurvature=[...p]:delete c.edgeCurvature):(c.outline=g,delete c.outlinePath,delete c.sourceOutline,delete c.cornerSmoothing,delete c.edgeCurvature);for(let y=0;y<(c.holes?.length??0);y+=1)pn(e,{floorId:n.floorId,objectId:c.id,points:c.holes[y],holeIndex:y});JSON.stringify(c)!==f&&(i=!0,r.add(c.id))}}catch(s){for(let{section:c,snapshot:l}of a.values()){let d=c;for(let f of Object.keys(d))delete d[f];Object.assign(c,structuredClone(l))}throw s}return{floorId:n.floorId,changed:i,sectionIds:o,affectedSectionIds:[...r]}}function sd(e,t,n={}){let o=!1;for(let r of t){let a=yo(e,{floorId:r.floorId,sectionIds:[r.sectionId],patch:{height:r.height,rake:r.rake,surfaceKind:r.surfaceKind}});o||=a.changed}if(n.stage){let r=O(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);r&&r.role!=="stage"&&(r.role="stage",o=!0),r&&n.stage.stageKind&&!r.stageKind&&(r.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:r,floorId:a,role:i}of n.roles??[]){let s=O(e,a).objects.find(c=>c.type==="shape"&&c.id===r);s&&!s.role&&(s.role=i,o=!0)}for(let{floorId:r,point:a}of n.focal??[]){let i=xt(a,"focalPoint"),s=r?e.floors?.find(l=>l.id===r):void 0,c=s?s.focalPoint:e.focalPoint;c?.x===i.x&&c?.y===i.y||(s?s.focalPoint=i:e.focalPoint=i,o=!0)}return e.floors?.length&&Re(e),{changed:o}}var wo=.15,xo=1.6;function Je(e){return typeof e=="string"&&zr.includes(e)}function So(e,t){return e&&t?"both":e?"start":t?"end":"none"}function Io(e){let t=Je(e.aisleSeats)?e.aisleSeats:"none";return{start:t==="start"||t==="both",end:t==="end"||t==="both"}}function vo(e,t){e.aisleSeats=t}function oa(e,t,n){if(!Je(e.aisleSeats)){delete t.aisleSeats,delete n.aisleSeats;return}let o=Io(e);vo(t,So(o.start,!0)),vo(n,So(!0,o.end))}function ra(e,t){let n=e[0],o=e[e.length-1];if(!n||!o||!Je(n.aisleSeats)&&!Je(o.aisleSeats)){delete t.aisleSeats;return}vo(t,So(Io(n).start,Io(o).end))}var ia=["butt","round","square"],aa=["miter","round","bevel"],sa=["none","arrow"];function Co(e){return e==="line"||e==="polyline"}var ca=[{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 L18 12 L18.5 23 L16 23 L15.5 13 L8.5 13 L8 23 L5.5 23 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}}],jb=ca.map(e=>e.key),cd=new Map(ca.map(e=>[e.key,e]));function At(e){return typeof e=="string"&&cd.has(e)}var ld=new Set(["companion","child","senior","student","membership","custom"]);function We(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 r of o){let a=r.key.trim(),i=r.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),!i||i.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=i.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:i});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(r.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(r.referenceDirectSeatImport!==void 0){let l=r.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(r.price!=null&&(!Number.isFinite(r.price)||r.price<0||r.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(r.seatGlyph!=null&&!At(r.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:r.seatGlyph});if((r.seatGlyph==null||r.seatGlyph==="circle")&&delete r.seatGlyph,r.tiers!=null)if(!r.tiers.length)delete r.tiers;else{if(r.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 f of r.tiers){let g=f.id.trim(),h=f.name.normalize("NFKC").trim(),b=h.toLocaleLowerCase("en");if(!g||g.length>160||l.has(g))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:g});if(!h||h.length>80||d.has(b))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:h});if(!Number.isFinite(f.price)||f.price<0||f.price>1e6)throw new u("invalid_operation",`Ticket tier ${g} price must be from 0 to 1000000`,{categoryKey:a,tierId:g});if(f.restriction!=null&&!ld.has(f.restriction))throw new u("invalid_operation",`Ticket tier ${g} has an unknown restriction`,{categoryKey:a,tierId:g});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 ${g} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:g})}if(f.currency!=null&&(f.currency=f.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(f.currency)))throw new u("invalid_operation",`Ticket tier ${g} must use a three-letter ISO currency`,{categoryKey:a,tierId:g});if(f.applicability!=null){let p=f.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),S=f.applicability.accessibility;if(p&&(!p.length||p.length>1e4||p.some(I=>!I||I.length>160)||new Set(p).size!==p.length)||S&&(!S.length||S.some(I=>!wt.some(y=>y.key===I))||new Set(S).size!==S.length))throw new u("invalid_operation",`Ticket tier ${g} has invalid seat applicability`,{categoryKey:a,tierId:g});f.applicability={...p?{seatLabels:p}:{},...S?{accessibility:[...S]}:{}},!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 ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g});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 ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g})}l.add(g),d.add(b)}}}return o}function yn(e,t){let n=new Set,o=structuredClone(e.categories);for(let i of t.updates){if(n.has(i.categoryKey))throw new u("invalid_operation",`Category ${i.categoryKey} may be updated only once`);n.add(i.categoryKey);let s=o.find(f=>f.key===i.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${i.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:i.categoryKey});let c=structuredClone(i.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(f=>{let g={...f,id:f.id.trim(),name:f.name.normalize("NFKC").trim()};return f.buyerMessage?.trim()?g.buyerMessage=f.buyerMessage.normalize("NFKC").trim():delete g.buyerMessage,g})),delete s.referenceDirectSeatImport}let r=We(o),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,categoryKeys:[...n],categories:e.categories}}function dd(e,t){let n=structuredClone(e.categories),o=n.find(i=>i.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 r=We(n),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,category:e.categories.find(i=>i.key===t.categoryKey),categories:e.categories}}function ud(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 r=new Set(o),a=o.filter(c=>!n.includes(c)),i=n.filter(c=>!r.has(c));if(a.length||i.length)throw new u(i.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:i});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=We(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}}function la(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 fd(e,t){let n=la(e),o=la(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var hd=3600;function da(e,t,n=Ie){return n.find(r=>e.every(a=>fd(r,a)>=hd))??n[t%n.length]}function gd(e,t){let n=t?.palette??Ie;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(i=>[i.key,i.color.toLowerCase()])),r=e.categories.map((i,s)=>({categoryKey:i.key,patch:{color:n[s%n.length]}}));return yn(e,{updates:r}),{changed:e.categories.map(i=>({key:i.key,from:o.get(i.key),to:i.color})).filter(i=>i.from!==i.to),categories:e.categories}}function bd(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 r=structuredClone(e.categories),a=r.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 i=We(r),s=JSON.stringify(i)!==JSON.stringify(e.categories);return s&&(e.categories=i),{changed:s,category:e.categories.find(c=>c.key===t.categoryKey),categories:e.categories}}function wn(e,t){let n=new Set(e.categories.map(i=>i.key)),o="";for(let i=0;i<100;i++){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 r={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(i=>({...i,id:i.id.trim(),name:i.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=We([...e.categories,r]);return e.categories=a,{changed:!0,category:a.find(i=>i.key===o),categories:a}}var ua=["#3e8e7e","#6e7ff0","#b0700f","#b05fc4"],md=[...ua,"#4d7c0f","#c026d3","#a86b00","#d6336c","#e5484d","#dc2626"],pd={row:"#6e7ff0",table:"#3e8e7e",booth:"#b05fc4",gaArea:"#b0700f"};function yd(e,t){let n=pd[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var wd="#f5f6f8",xd="#f7f8fb",Sd=26;function Id(e,t,n){let o=(1-Math.abs(2*n-1))*t,r=(e%360+360)%360/60,a=o*(1-Math.abs(r%2-1)),[i,s,c]=r<1?[o,a,0]:r<2?[a,o,0]:r<3?[0,o,a]:r<4?[0,a,o]:r<5?[a,0,o]:[o,0,a],l=n-o/2,d=f=>Math.round((f+l)*255).toString(16).padStart(2,"0");return`#${d(i)}${d(s)}${d(c)}`}function vd(e,t,n,o,r){let a=d=>e.every(f=>{let g=no(d,f);return g==null||g>=Sd}),i=[wd,r??xd],s=(d,f)=>Ct(ni(d,f,ei),f)??0,c=d=>o==="gaArea"?[...i,"#12151d"].every(f=>s(d,f)>=3):i.every(f=>(Ct(d,f)??0)>=3),l=t.find(d=>a(d)&&c(d));if(l)return l;for(let d=0;d<360;d+=12)for(let f of[.52,.44,.6]){let g=Id(d,.62,f);if(a(g)&&c(g))return g}return n}function fa(e,t){let n=St.find(a=>a.objectType===t).creationWord,o=e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim();return St.some(a=>a.creationWord.toLowerCase()===o.toLowerCase())?n:`${o} \u2013 ${n}`}function Cd(e){let t=new Map;for(let n of j(e))for(let o of n.objects){let r=St.find(i=>i.objectType===o.type);if(!r)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let i of on(o).keys())a.add(i);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let i of a){let s=t.get(i)??new Set;s.add(r.objectType),t.set(i,s)}}return t}function Od(e,t){let n=new Set(e.categories.map(r=>r.label.toLowerCase())),o=t;for(let r=2;n.has(o.toLowerCase());r+=1)o=`${t} ${r}`;return o}function ha(e,t,n){let o=Cd(e),r=d=>{let f=o.get(d);return!f||f.size===0||f.size===1&&f.has(n)},a=e.categories.find(d=>d.key===t);if(a&&r(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};let i=e.categories.find(d=>{let f=o.get(d.key);return f?.size===1&&f.has(n)});if(!a&&i)return{kind:"existing",categoryKey:i.key,label:i.label};let s=St.find(d=>d.objectType===n),c=a?fa(a.label,n):s.creationWord,l=e.categories.find(d=>d.label.toLowerCase()===c.toLowerCase()&&r(d.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:i?{kind:"existing",categoryKey:i.key,label:i.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:Od(e,c)}}function Pd(e,t,n,o){let r=ha(e,t,n);if(r.kind==="existing")return r.categoryKey;let a=r.baseCategoryKey?e.categories.find(i=>i.key===r.baseCategoryKey):void 0;return Rd(e,n,a,r.label,o)}function Rd(e,t,n,o,r){let a=r.palette??md,i=e.categories.map(d=>d.color),s=r.suggestColor?.(i.map(d=>d.toLowerCase()))??da(i,e.categories.length),c=vd(i,yd(t,a),s,t,e.theme?.background),l=wn(e,{label:o,color:c,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:r.idFactory});return e.categories=l.categories,l.category.key}function Ad(e,t){let n=new Set;for(let o of j(e))for(let r of o.objects)"categoryKey"in r&&r.categoryKey===t&&n.add(r.id),r.type==="section"&&r.editor?.defaultCategoryKey===t&&n.add(r.id),(r.type==="row"||r.type==="table")&&r.overrides?.some(a=>a.categoryKey===t)&&n.add(r.id);return[...n]}function Oo(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=Ad(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 r=We(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=r,{changed:!0,categoryKey:t.categoryKey,categories:r}}function Md(e,t){if(!t.drafts.length)throw new u("invalid_operation","Add at least one category");let n=[];for(let o of t.drafts){let r=ga(e.categories,o.label),a=wn(e,{label:r,color:o.color,...o.price!==void 0?{price:o.price}:{},...o.tiers?.length?{tiers:o.tiers}:{},idFactory:t.idFactory});n.push(a.category.key),(o.notForSale||o.seatGlyph)&&yn(e,{updates:[{categoryKey:a.category.key,patch:{...o.notForSale?{notForSale:!0}:{},...o.seatGlyph?{seatGlyph:o.seatGlyph}:{}}}]})}return{categoryKeys:n,categories:e.categories}}function ga(e,t){let n=t.normalize("NFKC").trim().slice(0,76)||"Category",o=new Set(e.map(r=>r.label.toLocaleLowerCase("en")));if(!o.has(n.toLocaleLowerCase("en")))return n;for(let r=2;r<1e4;r+=1){let a=`${n} ${r}`;if(!o.has(a.toLocaleLowerCase("en")))return a}return`${n} ${Date.now()}`}function _d(e,t){let{categoryKey:n,toCategoryKey:o}=t;if(!e.categories.some(i=>i.key===n))throw new u("category_not_found",`Unknown chart category: ${n}`,{categoryKey:n});if(o!==void 0){if(o===n)throw new u("invalid_operation","Move the seats to a different category");if(!e.categories.some(i=>i.key===o))throw new u("category_not_found",`Unknown chart category: ${o}`,{categoryKey:o})}let r=new Set;if(o!==void 0)for(let i of j(e))for(let s of i.objects){if((s.type==="row"||s.type==="table"||s.type==="booth"||s.type==="gaArea")&&s.categoryKey===n&&(s.categoryKey=o,r.add(s.id)),(s.type==="row"||s.type==="table")&&s.overrides?.length){for(let l of s.overrides)l.categoryKey===n&&(l.categoryKey=o,r.add(s.id));let c=s.overrides.flatMap(l=>{if(l.categoryKey!==s.categoryKey)return[l];let d={...l};return delete d.categoryKey,Object.keys(d).some(f=>f!=="index")?[d]:[]});c.length?s.overrides=c:delete s.overrides}s.type==="section"&&s.editor?.defaultCategoryKey===n&&(s.editor.defaultCategoryKey=o,r.add(s.id))}let a=Oo(e,{categoryKey:n});return{movedObjectIds:[...r],categories:a.categories}}var Po=["daylight","floodlit","evening","arena-show","theatre","concert-hall","plain"];var kd=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],Ld=["seat","deck","shell","fascia"];function Ed(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),r={...e.theme??{}};for(let a of kd){let i=n[a];i===null?delete r[a]:i!==void 0&&(r[a]=D(i,`Theme ${a}`))}if(n.sectionDetail===null)delete r.sectionDetail;else if(n.sectionDetail!==void 0){if(n.sectionDetail!=="rows"&&n.sectionDetail!=="seats")throw new u("invalid_operation","Theme sectionDetail must be rows or seats");r.sectionDetail=n.sectionDetail}if(n.fontFamily===null)delete r.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");r.fontFamily=a}if(n.seatScale===null)delete r.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<wo||n.seatScale>xo)throw new u("invalid_operation",`Theme seatScale must be from ${wo} to ${xo}`);r.seatScale=n.seatScale}if(n.logoUrl===null)delete r.logoUrl;else if(n.logoUrl!==void 0){let a=we(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");r.logoUrl=a}if(n.brandName===null)delete r.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");r.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete r.hideBadge:n.hideBadge===!0&&(r.hideBadge=!0),n.venue3d===null)delete r.venue3d;else if(n.venue3d!==void 0){let a={...r.venue3d??{}},i=n.venue3d.look;if(i===null)delete a.look;else if(i!==void 0){if(!Po.includes(i))throw new u("invalid_operation",`3D venue look must be one of: ${Po.join(", ")}`);a.look=i}for(let c of Ld){let l=n.venue3d[c];l===null?delete a[c]:l!==void 0&&(a[c]=D(l,`3D venue ${c}`))}let s=n.venue3d.roughness;if(s===null)delete a.roughness;else if(s!==void 0){if(!Number.isFinite(s)||s<0||s>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=s}r.venue3d=Object.keys(a).length?a:void 0,r.venue3d||delete r.venue3d}return e.theme=Object.keys(r).length?r:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Td(e,t){let n=t.url===null?null:we(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 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 r=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(r?e.viewFromSeatMeta:void 0):void 0,i=!r||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:i,scope:"venue",url:e.viewFromSeatUrl??null}}function ke(e,t){let n=pe(e,t.floorId),o=fe(n),r=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return r==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:r==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:r==="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 xn(e,t){N(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 r=t.fit??"seat-pitch";if(r==="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");if(t.seatsPerRowByRow!==void 0&&(r!=="fixed-count"||t.seatsPerRowByRow.length!==t.rowCount||t.seatsPerRowByRow.some(d=>!Number.isInteger(d)||d<2||d>300)))throw new u("invalid_operation","Fixed Arc/Fan seats per row need one count from 2 to 300 for every row");let a=t.taperDegrees??0,i=t.skewDegrees??0;if(!n(a,i)||Math.abs(a)>120||Math.abs(i)>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=O(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:r,facing:t.facing??"inward",taperDegrees:a,skewDegrees:i,aisleGaps:s,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function ba(e,t,n){let o=n*le;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function jd(e,t,n,o){let r=Math.abs(o-n)*le,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let f=e.aisleGaps[l];if(!f)return[];let g=f/t/r/2;return[[Math.max(0,d-g),Math.min(1,d+g)]]}).sort((l,d)=>l[0]-d[0]),i=[];for(let l of a){let d=i[i.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):i.push([...l])}let s=[],c=0;for(let l of i)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*r*(d-l)>=e.seatPitch*.75)}function Sn(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,r=e.reduce((c,l)=>c+l,0),a=e.map(c=>o*c/r),i=a.map(c=>2+Math.floor(c)),s=t-i.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&&i[c]++}),i}function In(e,t,n){let o=[];for(let r=0;r<e.rowCount;r++){let a=e.rowCount===1?0:r/(e.rowCount-1),i=e.innerRadius+r*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 ${r+1} below a 5\xB0 sweep`);let d=jd(e,i,c,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${r+1}`);e.facing==="outward"&&(d=d.slice().reverse());let f=d.map(([b,p])=>i*Math.abs(l-c)*le*(p-b)),g=e.fit==="fixed-count"?Sn(f,e.seatsPerRowByRow?.[r]??e.seatsPerRow):f.map(b=>Math.max(2,Math.round(b/e.seatPitch)+1)),h=e.seatLabelStart;d.forEach(([b,p],S)=>{let I=c+(l-c)*b,y=c+(l-c)*p;e.facing==="outward"&&([I,y]=[y,I]);let w=g[S];if(w>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let x=Math.abs(y-I)*le/(w-1),m=2*i*Math.sin(x/2),v={type:"row",id:n(r,S),label:B(e.rowLabelStart+r),origin:ba(e.center,i,I),rotation:-I,curve:y-I,seatCount:w,seatSpacing:m,categoryKey:e.categoryKey,seatLabelStart:h,...d.length>1?{aisleSeats:S===0?"end":S===d.length-1?"start":"both"}:{},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}:{},...e.seatsPerRowByRow?{seatsPerRowByRow:[...e.seatsPerRowByRow]}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:r,segmentIndex:S}};o.push(v),h+=w})}return o}var Fd=150,Ro=22,Dd=3;function ma(e,t){if(Math.abs(e.endAngle-e.startAngle)<=Fd)return Ge(t);let n=(e.startAngle+e.endAngle)/2,o=1/0,r=0,a=1/0,i=-1/0;for(let b of t)for(let p of ee(b)){let S=p.x-e.center.x,I=p.y-e.center.y,y=Math.hypot(S,I),w=(Math.atan2(S,I)/le-n+540)%360-180;o=Math.min(o,y),r=Math.max(r,y),a=Math.min(a,w),i=Math.max(i,w)}if(!Number.isFinite(o))return null;let s=Math.max(0,o-Ro),c=r+Ro,l=Ro/Math.max(o,1)/le,d=Math.max(a-l,-179.5),f=Math.min(i+l,179.5),g=Math.max(2,Math.ceil((f-d)/Dd)),h=(b,p)=>Array.from({length:g+1},(S,I)=>{let y=p?g-I:I;return ba(e.center,b,n+d+(f-d)*y/g)});return[...h(c,!1),...s>0?h(s,!0):[{...e.center}]]}function Ao(e,t){let n=xn(e,t),o=O(e,t.floorId),r=In(n,"preview-arc-fan",(c,l)=>`preview-fan-${c}-${l}`),a=r.map(c=>c.seatSpacing),i=Math.max(...a.map(c=>Math.abs(c-n.seatPitch))),s=[];return i>n.seatPitch*.12&&s.push(`Seat spacing differs from the setting by up to ${Math.round(i*Xt*100)} cm, so each row keeps its seat count`),r.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:r,logicalRowCount:n.rowCount,rowSegmentCount:r.length,totalSeats:r.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:i,aisleCount:Object.values(n.aisleGaps).filter(c=>c>0).length,warnings:s}}function vn(e,t){let n=xn(e,t),o=O(e,t.floorId),r=new Set,a=T(e,"fan",t.idFactory,r),i=In(n,a,()=>T(e,"r",t.idFactory,r)),s=Ao(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 f=ma(n,i);f&&(c=T(e,"sec",t.idFactory,r),d={type:"section",id:c,label:l,outline:f,arcFanGroupId:a})}return o.objects.push(...i,...d?[d]:[]),{floorId:o.floorId,rowIds:i.map(f=>f.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 pa(e,t){let n=O(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 r=o[0].arcFanGeneration,a=f=>{let g=f.arcFanGeneration;return JSON.stringify({center:g.center,innerRadius:g.innerRadius,rowCount:g.rowCount,rowGap:g.rowGap,startAngle:g.startAngle,endAngle:g.endAngle,seatPitch:g.seatPitch,fit:g.fit,seatsPerRow:g.seatsPerRow,seatsPerRowByRow:g.seatsPerRowByRow,facing:g.facing,taperDegrees:g.taperDegrees,skewDegrees:g.skewDegrees,aisleGaps:g.aisleGaps,rowLabelStart:g.rowLabelStart,seatLabelStart:g.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 i=n.objects.find(f=>f.type==="section"&&f.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...r.center},innerRadius:r.innerRadius,rowCount:r.rowCount,rowGap:r.rowGap,startAngle:r.startAngle,endAngle:r.endAngle,seatPitch:r.seatPitch,fit:r.fit,seatsPerRow:r.seatsPerRow,...r.seatsPerRowByRow?{seatsPerRowByRow:[...r.seatsPerRowByRow]}:{},facing:r.facing,taperDegrees:r.taperDegrees,skewDegrees:r.skewDegrees,aisleGaps:{...r.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:r.rowLabelStart,seatLabelStart:r.seatLabelStart,sectionLabel:i?.label},c=xn(e,s),l=new Set(In(c,t.groupId,(f,g)=>`${f}:${g}`).map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].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 Nd(e,t){pa(e,{floorId:t.floorId,groupId:t.groupId});let n=xn(e,t),o=O(e,t.floorId),r=o.objects.filter(p=>p.type==="row"&&p.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(p=>p.type==="section"&&p.arcFanGroupId===t.groupId),i=new Map(r.map(p=>[`${p.arcFanGeneration.rowIndex}:${p.arcFanGeneration.segmentIndex}`,p.id])),s=new Set,c=In(n,t.groupId,(p,S)=>i.get(`${p}:${S}`)??T(e,"r",t.idFactory,s)),l=Ao(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 p=ma(n,c);p&&(f={type:"section",id:a?.id??T(e,"sec",t.idFactory,s),label:d,outline:p,arcFanGroupId:t.groupId})}let g=new Set([...r.map(p=>p.id),...a?[a.id]:[]]),h=Math.min(...o.objects.map((p,S)=>g.has(p.id)?S:1/0)),b=o.objects.filter(p=>!g.has(p.id));return b.splice(Number.isFinite(h)?h:b.length,0,...c,...f?[f]:[]),o.objects.splice(0,o.objects.length,...b),{floorId:o.floorId,rowIds:c.map(p=>p.id),sectionId:f?.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 ya(e,t){let n=Gd(e?.trim()??"");if(n){let r=n(1);for(let a=2;t.has(r)&&a<1e3;a+=1)r=n(a);if(!t.has(r))return r}let o=0;for(;t.has(B(o));)o+=1;return B(o)}function Gd(e){if(!e)return null;let t=/^([A-Za-z])\1+$/.exec(e);if(t){let i=e===e.toLowerCase(),s=t[1].toUpperCase().charCodeAt(0)-65;return c=>{let l=s+c,f=String.fromCharCode(65+l%26).repeat(e.length+Math.floor(l/26));return i?f.toLowerCase():f}}let n=/^(.*?)(\d+)$/.exec(e);if(n){let[,i,s]=n,c=s.startsWith("0")?s.length:0;return l=>`${i}${String(Number(s)+l).padStart(c,"0")}`}let o=e.toUpperCase(),r=sn(o);if(r==null)return null;let a=e===e.toLowerCase();return i=>{let s=B(r+i);return a?s.toLowerCase():s}}function Mo(e){return e.segmentedRow?.displayLabel??e.displayLabel??e.label}function $d(e,t=[]){let n=new Set([...ne(e),...t].filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=0;return()=>{for(;n.has(B(o));)o+=1;let r=B(o);return n.add(r),o+=1,r}}function Bd(e){let t=new Set(e.flatMap(o=>o.type==="row"?[Mo(o)]:o.type==="table"||o.type==="booth"?[o.label]:[])),n=0;return()=>{for(;t.has(B(n));)n+=1;let o=B(n);return t.add(o),o}}function Kd(e,t){let n=e.filter(c=>c.type==="section"),o=n.find(c=>H(t,c.outline,c.holes));if(!o)return Bd(e);let r=e.filter(c=>c.type==="row"&&Jt(e,c,n)===o),a=new Set(r.map(Mo)),i=r[r.length-1],s=i?Mo(i):void 0;return()=>{let c=ya(s,a);return a.add(c),s=c,c}}function wa(e,t){let n=t.pending??[],o=$d(e,n),r=Kd([...O(e,t.floorId).objects,...n],t.origin);return Array.from({length:Math.max(0,t.count)},()=>{let a=o(),i=r?.();return i&&i!==a?{label:a,displayLabel:i}:{label:a}})}var xa=1,_o=.01;function Sa(e,t){let n=Q(e),o=n[n.length-1],r=Q(t)[0];if(!o||!r)return null;let a=Math.hypot(r.x-o.x,r.y-o.y),i=a>_o?{x:(r.x-o.x)/a,y:(r.y-o.y)/a}:{x:Math.cos(t.rotation*Math.PI/180),y:Math.sin(t.rotation*Math.PI/180)};return{distance:a,direction:i,pitch:(e.seatSpacing+t.seatSpacing)/2}}function Ia(e,t){return t==="break"?e*(1+xa):e}function zd(e,t){let n=e[t-1],o=e[t];if(!n||!o||o.segmentedRow?.boundaryBefore!=="break")return!1;let r=Sa(n,o);return!!r&&Ia(r.pitch,"break")-r.distance>=_o}function Mt(e,t,n){let o=e[t-1],r=e[t];if(!o||!r)return!1;let a=Sa(o,r);if(!a)return!1;let i=Ia(a.pitch,n),s=n==="break"?Math.max(0,i-a.distance):Math.min(0,i-a.distance);if(Math.abs(s)<_o)return!1;for(let c of e.slice(t))Ce(c,a.direction.x*s,a.direction.y*s);return!0}function va(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 ko(e,t){if(N(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 r=O(e,t.floorId),a=new Set,i=wa(e,{floorId:t.floorId,origin:t.origin,count:t.rowCount}),s=un(t.rotation??0),c=t.curve??0,l=t.style,d=l?T(e,"rowblock",t.idFactory,a):void 0,f=l?va({style:l,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:c}):void 0,g={x:Math.cos(s*he),y:Math.sin(s*he)},h={x:-g.y,y:g.x},b=Array.from({length:t.rowCount},(I,y)=>{let w=l==="intertwined"&&y%2===1?o/2:0,x={type:"row",id:T(e,"r",t.idFactory,a),...i[y],origin:{x:t.origin.x+h.x*y*n+g.x*w,y:t.origin.y+h.y*y*n+g.y*w},rotation:s,curve:c,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&f&&(x.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:y,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:c,signature:f}),x});r.objects.push(...b);let p=null,S=t.sectionLabel?.trim();if(S){let I=Ge(b);if(I){let y={type:"section",id:T(e,"sec",t.idFactory,a),label:S,outline:I};r.objects.push(y),p=y.id}}return{floorId:r.floorId,rowIds:b.map(I=>I.id),sectionId:p,createdIds:[...b.map(I=>I.id),...p?[p]:[]]}}function Ca(e,t){let n=new Set(ne(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let r=`${t}${o}`;return n.add(r),o+=1,r}}function Ud(e,t){let n=new Set(ne(e).filter(r=>r.type==="gaArea").map(r=>r.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Hd=456;function Cn(e){let t=Math.sqrt(Math.max(1,e)*Hd);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Lo(e,t){if(N(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=O(e,t.floorId),o=new Set,{width:r,height:a}=Cn(t.capacity),i=Ud(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:T(e,"ga",t.idFactory,o),label:i,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y+a/2},{x:t.center.x-r/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:i,createdIds:[s.id]}}function Eo(e,t){if(N(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 r=O(e,t.floorId),a=new Set,i=Ca(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:T(e,"t",t.idFactory,a),label:i(),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 r.objects.push(...s),{floorId:r.floorId,tableIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function To(e,t){if(N(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 r=O(e,t.floorId),a=new Set,i=Ca(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:T(e,"booth",t.idFactory,a),label:i(),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 r.objects.push(...s),{floorId:r.floorId,boothIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function _t(e,t){let n=O(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(g=>g!=="continuous"&&g!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);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 i=r,s=i.filter(g=>g.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(g=>g.id)});let c=(t.displayLabel??i[0].displayLabel??i[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(g=>g.type==="row"?[g.segmentedRow?.groupId,g.rowBlockGeneration?.groupId].filter(h=>!!h):[])),d="";for(let g=0;g<100;g+=1){let h=t.idFactory("rowgroup");if(h&&!l.has(h)){d=h;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let f=i[0];return i.forEach((g,h)=>{g.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:h,componentCount:i.length,boundaryBefore:h===0?"start":t.boundaries[h-1],displayLabel:c,...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 Vd(e,t){let n=O(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),r=t.groupId??o?.segmentedRow?.groupId;if(!r)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===r);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let i=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:r,rowIds:i,changed:!0}}function Xd(e,t){let n=O(e,t.floorId),o=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId).sort((s,c)=>s.segmentedRow.componentIndex-c.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(s=>s!=="continuous"&&s!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=t.displayLabel?.normalize("NFKC").trim();if(r!==void 0&&(!r||r.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(s=>s.segmentedRow)),i=!1;return t.boundaries?.forEach((s,c)=>{s==="break"&&(i=Mt(o,c+1,"break")||i)}),o.forEach((s,c)=>{let l=s.segmentedRow,d=l.viewFromSeatUrl;r!==void 0&&(l.displayLabel=r),t.boundaries&&c>0&&(l.boundaryBefore=t.boundaries[c-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!==d&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(s=>s.id),changed:i||JSON.stringify(o.map(s=>s.segmentedRow))!==a,...i?{seatsMoved:!0}:{}}}function qd(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=O(e,t.floorId),o=n.objects.filter(A=>A.type==="row"&&A.rowBlockGeneration?.groupId===t.groupId).sort((A,re)=>A.rowBlockGeneration.rowIndex-re.rowBlockGeneration.rowIndex),r=o[0]?.rowBlockGeneration;if(!r||o.length!==r.rowCount||o.some((A,re)=>{let M=A.rowBlockGeneration;return M.kind!=="row-block-v1"||M.rowIndex!==re||M.signature!==r.signature||JSON.stringify(M)!==JSON.stringify({...r,rowIndex:re})}))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),i=t.style??r.style,s=t.rowCount??r.rowCount,c=t.seatsPerRow??r.seatsPerRow,l=t.rowGap??r.rowGap,d=t.seatSpacing??r.seatSpacing,f=t.curve??r.curve,g=Number.isFinite(t.rotation??r.rotation)?un(t.rotation??r.rotation):t.rotation??r.rotation,h=t.origin?{...t.origin}:{...r.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(A=>Number.isFinite(A)&&A>0)||!Number.isFinite(f)||!Number.isFinite(g)||!Number.isFinite(h.x)||!Number.isFinite(h.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let b=va({style:i,origin:h,rotation:g,rowCount:s,seatsPerRow:c,rowGap:l,seatSpacing:d,curve:f}),p={x:Math.cos(g*he),y:Math.sin(g*he)},S={x:-p.y,y:p.x},I=new Map(o.map(A=>[A.rowBlockGeneration.rowIndex,A])),y=new Set,w=new Set(n.objects.filter(A=>A.type==="row").filter(A=>!o.includes(A)).map(A=>A.label)),x=n.objects.filter(A=>A.type==="row").length,m=()=>{for(;w.has(B(x));)x+=1;let A=B(x);return w.add(A),x+=1,A},v=[],C=[];for(let A=0;A<s;A+=1){let re=i==="intertwined"&&A%2===1?d/2:0,M=I.get(A);M||(M={type:"row",id:T(e,"r",t.idFactory,y),label:m(),origin:{...h},rotation:g,curve:f,seatCount:c,seatSpacing:d,categoryKey:o[0].categoryKey},C.push(M.id)),M.origin={x:h.x+S.x*A*l+p.x*re,y:h.y+S.y*A*l+p.y*re},M.rotation=g,M.curve=f,M.seatCount=c,M.seatSpacing=d,delete M.path,delete M.arcFanGeneration,M.overrides&&(M.overrides=M.overrides.filter(ie=>ie.index<c),M.overrides.length||delete M.overrides),M.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:i,rowIndex:A,rowCount:s,seatsPerRow:c,origin:{...h},rotation:g,rowGap:l,seatSpacing:d,curve:f,signature:b},v.push(M)}let P=o.slice(s).map(A=>A.id),k=Math.min(...o.map(A=>n.objects.indexOf(A))),Y=new Set(o.map(A=>A.id)),J=n.objects.filter(A=>!Y.has(A.id));return J.splice(k,0,...v),n.objects.splice(0,n.objects.length,...J),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(A=>A.id),createdRowIds:C,removedRowIds:P,changed:a!==JSON.stringify(v)||C.length>0||P.length>0}}function Oa(e){let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t/Math.max(1,e.length-1)}function Yd(e){let t=e.length,n=e.reduce((I,y)=>I+y.x,0)/t,o=e.reduce((I,y)=>I+y.y,0)/t,r=0,a=0,i=0,s=0,c=0,l=0,d=0;for(let I of e){let y=I.x-n,w=I.y-o;r+=y*y,a+=w*w,i+=y*w,s+=y*y*y,c+=w*w*w,l+=y*w*w,d+=w*y*y}let f=r*a-i*i;if(Math.abs(f)<1e-9)return null;let g=(s+l)/2,h=(c+d)/2,b=(g*a-h*i)/f,p=(h*r-g*i)/f,S=Math.sqrt(b*b+p*p+(r+a)/t);return Number.isFinite(S)?{center:{x:b+n,y:p+o},radius:S}:null}function kt(e){let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=e.length;return{origin:{...t},rotation:o>0?Math.atan2(n.y-t.y,n.x-t.x)*180/Math.PI:0,curve:0,seatSpacing:r>1&&o>0?o/(r-1):Oa(e),seatCount:r,ordered:e}}function Jd(e){if(e.length<3)return kt(e);let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=Oa(e);if(o<=0||r<=0)return kt(e);let a=0;for(let g of e){let h=Math.abs((n.x-t.x)*(t.y-g.y)-(t.x-g.x)*(n.y-t.y))/o;a=Math.max(a,h)}if(a<r*.2)return kt(e);let i=Yd(e);if(!i||i.radius<=r/2)return kt(e);let s=g=>{let h=g[0],b=g[1],p=h.x-i.center.x,I=-(h.y-i.center.y),y=p;I*(b.x-h.x)+y*(b.y-h.y)<0&&(I=-I,y=-y);let w=Math.hypot(I,y)||1;I/=w,y/=w;let x=(i.center.x-h.x)*y+(i.center.y-h.y)*-I;return{tx:I,ty:y,centreSide:x}},c=e,l=s(c);l.centreSide<0&&(c=[...e].reverse(),l=s(c));let f=2*Math.asin(Math.min(1,r/(2*i.radius)))*(c.length-1)*180/Math.PI;return!Number.isFinite(f)||f>=359?kt(e):{origin:{...c[0]},rotation:Math.atan2(l.ty,l.tx)*180/Math.PI,curve:f,seatSpacing:r,seatCount:c.length,ordered:c}}function On(e,t){let n=Jd(e);if(e.length<6)return[n];let o=t(n),r=-1,a=0;if(n.ordered.forEach((s,c)=>{let l=o[c]?Math.hypot(s.x-o[c].x,s.y-o[c].y):1/0;l>a&&(a=l,r=c)}),a<=n.seatSpacing/3)return[n];let i=Math.min(n.ordered.length-3,Math.max(3,r));return[...On(n.ordered.slice(0,i),t),...On(n.ordered.slice(i),t)]}function jo(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Fo(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Do(e){return Fo(jo(e),40)}function Pa(e,t=39){return Fo(jo(e),Math.max(1,t))}function Ze(e,t=80){return Fo(jo(e),Math.max(1,t))}function Ra(e){return Ze(e).toLocaleLowerCase("en")}function No(e){return Ra(e)}function Aa(e){return new Map((e??[]).map(t=>[t.index,t]))}function Wd(e){let t=Aa(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(be(e,o,r))}return n}function Zd(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=Aa(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(r?.label??`${e.label}-${o+1}`)}return n}function Qd(e){return e.type==="row"?[e.label,...Wd(e)]:e.type==="table"?[e.label,...Zd(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...de(e)]:[]}function Ma(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let r of Qd(o)){let a=No(r);a&&n.add(a)}return n}function eu(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[No(e)];for(let r=0;r<t;r+=1)o.push(No(be(n,r)));return o.filter(Boolean)}function _a(e,t,n){let o=eu(t,n);if(!o.length||o.some(r=>e.has(r)||Ae(r)))return!1;for(let r of o)e.add(r);return!0}var tu=1e-6,nu=160,ou=.001,ru=1e-5;function Qe(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>nu)return;for(let a of t){let i=a.codePointAt(0)??0;if(i<32||i===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),r=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(r)||!Number.isSafeInteger(Number(r))))return t}function ka(e){return typeof e=="string"&&Pa(e)||void 0}function La(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(Go(e.origin)&&Go(t.start)&&Go(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)},r=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=ou+Math.max(1,r)*ru;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||r<=tu)return!0;let i=r/(e.seatCount-1);if(Math.abs(e.seatSpacing-i)>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,r))*180/Math.PI);return c<=l}function Go(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var iu=300;function au(e){let t=new Set(ne(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(Boolean)),n=0,o=()=>{for(;t.has(B(n));)n+=1;let r=B(n);return n+=1,t.add(r),r};return r=>{let a=Do(r),i=0;return()=>{for(;a&&i<4096;i+=1){let s=`${a}-${B(i)}`;if(!t.has(s))return t.add(s),i+=1,s}return o()}}}function su(e){let t=Ma(ne(e));return(n,o)=>{let r=Ze(n);for(let a=1;a<4096;a+=1){let i=a===1?"":` ${a}`,s=i?`${Ze(r,80-i.length)}${i}`:r;if(s&&_a(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function cu(e){return{ordinaryFor:au(e),direct:su(e)}}function $o(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Ea(e,t,n){return e.type==="table"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function lu(e,t,n){let o=new Map;for(let i of t.sections)if(!(n&&i.sectionId!==n)&&i.sourceGroupId)for(let[s,c]of i.rows.entries()){let l=Qe(`${i.sourceGroupId}:${s}`),d=l&&Qe(c.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:c)}let r=new Map;for(let i of e){let s=Qe(i.referenceScan?.directSourceRowId);if(!s){if(!i.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:i.id})}let c=r.get(s)??[];c.push(i),r.set(s,c)}let a=new Map;for(let[i,s]of r){let c=s.filter(g=>g.overrides?.length);if(!c.length)continue;let l=o.get(i),d=c[0],f=d.overrides;if(s.length!==1||c.length!==1||!f||!l||!La(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:i,rowIds:s.map(g=>g.id)});a.set(i,structuredClone(f))}return a}function Ta(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!$o(o,t,n)&&!Ea(o,t,n))}function du(e,t,n,o,r,a,i){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=Ta(t,n,i).filter(f=>H(V(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 c=[],l=0;for(let[d,f]of e.rows.entries()){let g=Math.min(iu,Math.max(1,Math.round(f.seatCount)));if(!Number.isFinite(g)||g<1)continue;let h=f.end.x-f.start.x,b=f.end.y-f.start.y,p=Math.hypot(h,b),S=g>1&&p>0?p/(g-1):o>0?o:24;if(!Number.isFinite(S)||S<=0)continue;let I=p>0?Math.atan2(b,h)*180/Math.PI:0,y={x:f.start.x,y:f.start.y},w=0,x=S,m,v=f.seats?.length===g&&f.seats.every(M=>Number.isFinite(M.x)&&Number.isFinite(M.y))?f.seats:null;if(v&&f.table&&g>=3){let M=f.table.center,ie=v.reduce(($,W)=>$+Math.hypot(W.x-M.x,W.y-M.y),0)/g,se=v.map($=>Math.atan2($.y-M.y,$.x-M.x)).sort(($,W)=>$-W),Oe=0,Nt=0;se.forEach(($,W)=>{let je=W+1<se.length?se[W+1]:se[0]+Math.PI*2;je-$>Oe&&(Oe=je-$,Nt=(W+1)%se.length)});let R=Oe>1.6*(Math.PI*2/g),E=R?(Math.PI*2-Oe)*180/Math.PI:void 0;m={center:{...M},radius:Math.max(1,ie-xe),...E!==void 0?{seatArc:E}:{}},I=R?(se[Nt]-Oe/2)*180/Math.PI:se[0]*180/Math.PI,y={...M}}let C=[];if(v&&!m&&g>=3){C=On(v,ie=>Q({origin:ie.origin,rotation:ie.rotation,curve:ie.curve,seatCount:ie.seatCount,seatSpacing:ie.seatSpacing}));let M=C[0];y=M.origin,I=M.rotation,w=M.curve,x=M.seatSpacing}if(!Number.isFinite(x)||x<=0)continue;let P=e.sourceGroupId?Qe(`${e.sourceGroupId}:${d}`):void 0,k=P&&Qe(f.directSourceRowId)===P?P:void 0,Y=k?ka(f.directReviewedSuffix):void 0,J=e.sourceGroupId&&f.rowLabel?Ze(f.rowLabel):"",A=e.sourceGroupId&&f.rowDisplayLabel?Ze(f.rowDisplayLabel):"",re=!!e.sourceGroupId&&f.rowDisplayLabel==="";c.push({label:J?a(J,g):r(),displayLabel:A||(re?"":String(d+1)),origin:y,rotation:I,curve:w,seatCount:C[0]?.seatCount??g,seatSpacing:x,...m?{table:m}:{},...v&&!m?{measured:!0}:{},...k?{directSourceRowId:k}:{},...Y?{directReviewedSuffix:Y}:{}});for(let M of C.slice(1))c.push({label:r(),displayLabel:String(d+1),origin:M.origin,rotation:M.rotation,curve:M.curve,seatCount:M.seatCount,seatSpacing:M.seatSpacing,measured:!0});l+=g}return{skip:null,rows:c,seats:l}}function uu(e,t,n){N(e,n.categoryKey);let o=O(e,n.floorId),r=t.assetId,a=n.sectionId?o.objects.find(y=>y.type==="section"&&y.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let i=new Map;for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=n.categoryKeyForSection?.(y)??n.categoryKey;N(e,w),i.set(y,w)}if(a&&!t.sections.some(y=>y.sectionId===a.id&&y.seatCount>0))return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(y=>y.sectionId===a.id&&y.seatCount>0):void 0;if(a&&s){let y=Ta(o.objects,r,a.id).filter(w=>H(V(w),a.outline,a.holes));if(y.length)return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:y.map(w=>w.id)}]}}let c=o.objects.filter(y=>$o(y,r,a?.id)),l=lu(c,t,a?.id),d=[],f=o.objects.filter(y=>$o(y,r,a?.id)||Ea(y,r,a?.id)?(d.push(y.id),!1):!0);o.objects.splice(0,o.objects.length,...f);let g=[],h=[],b=[],p=new Set,S=0,I=cu(e);for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=du(y,o.objects,r,t.seatPitch,I.ordinaryFor(y.name),I.direct,a?.id);if(w.skip){h.push(w.skip);continue}let x=[],m=[],v=0;for(let C of w.rows){let P={assetId:r,...y.sectionId?{sectionId:y.sectionId}:{}},k=i.get(y)??n.categoryKey;if(C.table){v+=1,x.push({type:"table",id:T(e,"t",n.idFactory,p),referenceScan:P,label:C.label,displayLabel:String(v),center:C.table.center,shape:"round",radius:C.table.radius,...C.table.seatArc!==void 0?{seatArc:C.table.seatArc}:{},rotation:C.rotation,seatCount:C.seatCount,categoryKey:k});continue}let Y={type:"row",id:T(e,"r",n.idFactory,p),referenceScan:{...P,...C.directSourceRowId?{directSourceRowId:C.directSourceRowId}:{},...C.directReviewedSuffix?{directReviewedSuffix:C.directReviewedSuffix}:{}},label:C.label,...C.displayLabel!==void 0?{displayLabel:C.displayLabel}:{},origin:C.origin,rotation:C.rotation,curve:C.curve,seatCount:C.seatCount,seatSpacing:C.seatSpacing,categoryKey:k,...C.directSourceRowId&&l.has(C.directSourceRowId)?{overrides:structuredClone(l.get(C.directSourceRowId))}:{}};x.push(Y),C.measured&&m.push(Y)}if(o.objects.push(...x),m.length&&!y.sourceGroupId){let C=j(e).find(P=>P.id===o.floorId);fu(e,m,C?.focalPoint??e.focalPoint,o.floorId,n.idFactory)}for(let C of x)b.push(C.id);g.push({sectionId:y.sectionId,name:y.name,seats:w.seats,rows:x.length}),S+=w.seats}return{floorId:o.floorId,assetId:r,createdRowIds:b,removedRowIds:d,totalSeats:S,perSection:g,skipped:h}}function fu(e,t,n,o,r){let a=t.map(h=>Q(h)),i=a.flat(),s=n??{x:i.reduce((h,b)=>h+b.x,0)/i.length,y:Math.min(...i.map(h=>h.y))-1},c=t.map((h,b)=>{let p=a[b],S=p.map((y,w)=>{let x=p[Math.max(0,w-1)],m=p[Math.min(p.length-1,w+1)],v=Math.hypot(m.x-x.x,m.y-x.y);return v<=0?Math.hypot(y.x-s.x,y.y-s.y):Math.abs((y.x-s.x)*(-(m.y-x.y)/v)+(y.y-s.y)*((m.x-x.x)/v))}).sort((y,w)=>y-w),I=p.reduce((y,w)=>y+w.x,0)/p.length;return{row:h,depth:S[Math.floor(S.length/2)],along:I}}).sort((h,b)=>h.depth-b.depth||h.along-b.along),l=c.slice(1).map((h,b)=>h.depth-c[b].depth).filter(h=>h>1e-6).sort((h,b)=>h-b),d=l.length?l[Math.floor(l.length*.75)]:1/0,f=[],g=-1/0;for(let h of c)(!f.length||h.depth-g>d*.45)&&(f.push([]),g=h.depth),f[f.length-1].push(h.row);f.forEach((h,b)=>{let p=B(b);h.sort((S,I)=>{let y=Q(S),w=Q(I);return y.reduce((x,m)=>x+m.x,0)/y.length-w.reduce((x,m)=>x+m.x,0)/w.length});for(let S of h)S.displayLabel=p;h.length>=2&&h.length<=64&&_t(e,{floorId:o,rowIds:h.map(S=>S.id),boundaries:h.slice(1).map(()=>"break"),displayLabel:p,idFactory:r})})}function Fa(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.objectIds)];if(!r.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=r.map(p=>o.objects.find(S=>(S.type==="table"||S.type==="booth")&&S.id===p)),i=r.filter((p,S)=>!a[S]);if(i.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:i});let s=a[0].type;if(a.some(p=>p.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[p,S,I]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(S)||S<1||S>I)throw new u("invalid_operation",`${p} must be a whole number from 1 to ${I}`);for(let[p,S]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(S)||S<30||S>2e3)throw new u("invalid_operation",`${p} 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=r.length*(c-1);if(l>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((p,S)=>p+(S.type==="table"?S.seatCount:1),0),g=(e.floors?.length?e.floors.flatMap(p=>p.objects):e.objects).reduce((p,S)=>p+(S.type==="row"||S.type==="table"?S.seatCount:S.type==="gaArea"?Math.max(0,Math.floor(S.capacity)):S.type==="booth"?1:0),0),h=d*(c-1),b=n.maxInventory??1e5;if(g+h>b)throw new u("invalid_operation",`Grid inventory would exceed the ${b} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:r,sourceCount:r.length,cells:c,createdCount:l,addedInventory:h,resultingInventory:g+h,provenanceRemovedCount:a.filter(p=>!!p.referenceInventorySource).length*(c-1)}}}function hu(e,t,n={}){return Fa(e,t,n).preview}function gu(e,t,n={}){let{target:o,sources:r,preview:a}=Fa(e,t,n),i=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]:[])),c=[],l=(f,g)=>{let h=Math.max(2,g),b=S=>{let I=`-${S}`;return`${f.slice(0,Math.max(1,80-I.length))}${I}`},p=b(h);for(;s.has(p);)p=b(++h);return s.add(p),p},d=1;for(let f=0;f<t.rows;f++)for(let g=0;g<t.columns;g++)if(!(f===0&&g===0)){d+=1;for(let h of r){let b=structuredClone(h);b.id=T(e,b.type,t.idFactory,i),b.label=l(h.label,d),b.center={x:h.center.x+g*t.stepX,y:h.center.y+f*t.stepY},delete b.referenceInventorySource,c.push(b)}}return o.objects.push(...c),{...a,createdIds:c.map(f=>f.id)}}function bu(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=D(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var mu=new Set(wt.map(e=>e.key));function Lt(e){return`${e.rowId}:${e.index}`}function pu(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 yu(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,At(e.glyph)||delete e.glyph;let n=bt(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),r={};typeof e.commercial.restrictedView=="boolean"&&(r.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(r.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(r.premium=e.commercial.premium),o&&(r.note=o),Object.keys(r).length?e.commercial=r: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"&&Qt(t,e)}function wu(e){return Object.keys(e).every(t=>t==="index")}function Da(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=O(e,t),r=[],a=new Set,i=new Map;for(let s of n){let c=Lt(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});r.push({rowId:s.rowId,index:s.index}),i.set(l.id,l)}return{floorId:o.floorId,refs:r,owners:i}}function Bo(e,t){let n=Da(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&&N(e,t.patch.categoryKey),t.patch.glyph!=null&&!At(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(i=>!mu.has(i));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 i=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??i?.wheelchairSpaceType,c=t.patch.skip===null?!1:t.patch.skip??i?.skip??!1;if(s&&c)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Lt(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=we(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 i=t.patch[a];if(i!=null&&!Number.isFinite(i))throw new u("invalid_operation",`${a} must be finite`,{[a]:i})}t.patch.labelStyle!=null&&Se(t.patch.labelStyle,"Seat");let r=!1;return n.refs.forEach((a,i)=>{let s=n.owners.get(a.rowId),c=JSON.stringify(s.overrides??[]),l=s.overrides??(s.overrides=[]),d=l.find(g=>g.index===a.index);d||(d={index:a.index},l.push(d));let f=d.viewFromSeatUrl;for(let g of o){let h=t.patch[g];if(g==="wheelchairSpaceType"&&h==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(b=>b!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(h==null)delete d[g];else if(g==="accessibility")d.accessibility=[...new Set(h)],delete d.accessible;else if(g==="commercial")d.commercial={...d.commercial,...h};else if(g==="labelStyle"){let b=bu(d.labelStyle,h);b?d.labelStyle=b:delete d.labelStyle}else Object.assign(d,{[g]:h})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==f&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${i+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${i+1}`),yu(d,s),wu(d)&&(s.overrides=l.filter(g=>g!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==c&&(r=!0)}),{floorId:n.floorId,changed:r,seatIds:n.refs.map(Lt)}}function xu(e,t){let n=Da(e,t.floorId,t.seats),o=!1;for(let[r,a]of n.owners){if(!a.overrides?.length)continue;let i=new Set(n.refs.filter(c=>c.rowId===r).map(c=>c.index)),s=a.overrides.filter(c=>!i.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(Lt)}}function Su(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(w=>n.objects.find(x=>x.type==="row"&&x.id===w)),a=o.filter((w,x)=>!r[x]);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&&N(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 w=t.patch.seatNumbering,x=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(w.scheme!==void 0&&!x.includes(w.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${w.scheme}. Expected one of ${x.join(", ")}.`);if(w.prefix!==void 0&&(typeof w.prefix!="string"||w.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(w.endAt!==void 0&&w.endAt!==null&&(!Number.isInteger(w.endAt)||w.endAt<0||w.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:i,labelPosition:s,labelRotation:c,labelStyleShape:l,displayLabel:d,displayType:f,aisleSeats:g,...h}=t.patch,b=d===void 0?{}:{displayLabel:d},p=$e(b,"Row"),S=f===void 0?void 0:Yn(f,"Row");if(i!==void 0&&Se(i,"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");if(h.labelPresentation!==void 0&&tn(h.labelPresentation,"Row"),g!=null&&!Je(g))throw new u("invalid_operation","Row aisleSeats must be one of start, end, both, none (or null to unmark)");let I=w=>JSON.stringify({origin:w.origin,rotation:w.rotation,curve:w.curve,seatCount:w.seatCount,seatSpacing:w.seatSpacing,path:w.path??null}),y=!1;for(let w of r){let x=JSON.stringify(w),m=I(w),v=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?V(w):null;if(Object.assign(w,structuredClone(h)),w.overrides&&t.patch.seatCount!==void 0&&(w.overrides=w.overrides.filter(C=>C.index<w.seatCount),w.overrides.length||(w.overrides=void 0)),v){let C=V(w);w.origin={x:w.origin.x+v.x-C.x,y:w.origin.y+v.y-C.y}}if(JSON.stringify(w)!==x&&(y=!0),I(w)!==m&&(delete w.arcFanGeneration,delete w.rowBlockGeneration),i!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=Be(w.labelPresentation,i);P?w.labelPresentation=P:delete w.labelPresentation,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(s!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(c!==void 0||l!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};c===null?delete P.rotation:c!==void 0&&(P.rotation=c),l!==void 0&&(P.style=l),w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(S!==void 0){let C=w.displayType;S?w.displayType=S:delete w.displayType,w.displayType!==C&&(y=!0)}if(g!==void 0){let C=w.aisleSeats;g===null?delete w.aisleSeats:w.aisleSeats=g,w.aisleSeats!==C&&(y=!0)}if(d!==void 0){let C=w.displayLabel;p?delete w.displayLabel:w.displayLabel=b.displayLabel,w.displayLabel!==C&&(y=!0)}}return{floorId:n.floorId,changed:y,rowIds:o}}var Iu=3;function Pn(e){return(e%360+360)%360}function vu(e){let t=e.rotation*he;return{x:Math.cos(t),y:Math.sin(t)}}function Cu(e,t){let n=Math.abs(Pn(e-t));return n>180&&(n=360-n),n}function et(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Na(e){let t=0,n=0;for(let r of e){let a=2*r.rotation*he;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 Ou(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=r=>({x:r.x+t,y:r.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 Ga(e,t){let n=Na(e),o={x:-n.y,y:n.x},r=V(e[0]),a=e.map(c=>({row:c,coord:et(V(c),r,o)})).sort((c,l)=>c.coord-l.coord),i=a[0].coord,s=!1;return a.forEach((c,l)=>{let d=i+l*t-c.coord;Math.abs(d)>1e-6&&(Ou(c.row,o.x*d,o.y*d),delete c.row.arcFanGeneration,delete c.row.rowBlockGeneration,s=!0)}),s}function Pu(e,t){let n={x:-t.y,y:t.x},o=V(e[0]),r=e.map(i=>et(V(i),o,n)).sort((i,s)=>i-s);if(r.length<2)return 28;let a=(r[r.length-1]-r[0])/(r.length-1);return a>.5?a:28}function Ru(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Q(e),n=t[0],o=t[t.length-1],r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,i/(e.seatCount-1))),i>1e-6&&(e.rotation=Pn(Math.atan2(a,r)/he)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function Au(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let r=`${t}${o}`.slice(0,80);if(!n.has(r))return r}return`${t}-${Date.now().toString(36)}`}function Mu(e,t){let n=O(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 r=o.map(m=>n.objects.find(v=>v.type==="row"&&v.id===m)),a=o.filter((m,v)=>!r[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 i=r,s=i.filter(m=>m.path||m.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(m=>m.id)});let c=i[0],l=i.find(m=>Cu(m.rotation,c.rotation)>Iu);if(l)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[c.id,l.id]});let d=vu(c),f={x:-d.y,y:d.x},g=Math.max(8,c.seatSpacing*.6),h=i.find(m=>Math.abs(et(m.origin,c.origin,f))>g);if(h){let m=Math.round(Math.abs(et(h.origin,c.origin,f)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${m} units from the first.`,{rowIds:[c.id,h.id]})}let b=i.slice().sort((m,v)=>et(m.origin,c.origin,d)-et(v.origin,c.origin,d)),p=b.reduce((m,v)=>m+v.seatCount,0);if(p>300)throw new u("invalid_operation",`A merged row would have ${p} seats, over the 300-seat row limit. Merge fewer rows.`);let S=b[0];ra(b,S);let I=[],y=0;for(let m of b){if(m.overrides)for(let v of m.overrides)I.push({...structuredClone(v),index:v.index+y});y+=m.seatCount}S.seatCount=p,S.curve=0,delete S.path,I.length?S.overrides=I:delete S.overrides,delete S.arcFanGeneration,delete S.rowBlockGeneration;let w=b.slice(1).map(m=>m.id),x=new Set(w);for(let m=n.objects.length-1;m>=0;m--)x.has(n.objects[m].id)&&n.objects.splice(m,1);return{floorId:n.floorId,changed:!0,rowId:S.id,removedRowIds:w,seatCount:p}}function Ko(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="row"&&h.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 r=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>r-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${r-1} (the seat where the second row begins)`);let i=Q(o),s=r>1?o.curve/(r-1):0,c=r-a,l={type:"row",id:T(e,"r",t.idFactory,new Set),label:Au(n.objects,o.label),origin:{...i[a]},rotation:Pn(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 h=structuredClone(o.labelPresentation);delete h.position,l.labelPresentation=h}let d=[],f=[];if(o.overrides)for(let h of o.overrides)h.index<a?d.push(structuredClone(h)):f.push({...structuredClone(h),index:h.index-a});oa(o,o,l),o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,f.length&&(l.overrides=f);let g=n.objects.indexOf(o);return n.objects.splice(g+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:c,newLabel:l.label}}function _u(e,t){let n=O(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 r=o.map(s=>n.objects.find(c=>c.type==="row"&&c.id===s)),a=o.filter((s,c)=>!r[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 i=Ga(r,t.gap);return{floorId:n.floorId,changed:i,rowIds:o,gap:t.gap}}function ku(e,t){let n=O(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 r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r,s=()=>JSON.stringify(i.map(g=>[g.origin,g.rotation,g.curve,g.path??null,g.seatSpacing])),c=s();for(let g of i)Ru(g);let l=Na(i),d=Pn(Math.atan2(l.y,l.x)/he);for(let g of i)g.rotation=d;let f=Pu(i,l);return Ga(i,f),{floorId:n.floorId,changed:s()!==c,rowIds:o,gap:f}}function Lu(e,t){let n=O(e,t.floorId).objects.find(c=>c.type==="row"&&c.id===t.rowId);if(n?.segmentedRow)throw new u("invalid_operation","This row already has parts: choose Aisle on the join between them.",{rowIds:[t.rowId]});let o=n?.displayLabel??n?.label,r=Ko(e,t),a=_t(e,{floorId:r.floorId,rowIds:[r.rowId,r.newRowId],boundaries:["break"],...o?{displayLabel:o}:{},idFactory:t.idFactory}),{objects:i}=O(e,r.floorId),s=[r.rowId,r.newRowId].map(c=>i.find(l=>l.type==="row"&&l.id===c));return Mt(s,1,"break"),{floorId:r.floorId,rowId:r.rowId,newRowId:r.newRowId,groupId:a.groupId}}var An=vs(require("polygon-clipping"),1),$a=100,Ba=512,zo=8192,Ya=64,Ka=1e7,U=1e-7;function Ja(e,t){return Math.abs(e.x-t.x)<=U&&Math.abs(e.y-t.y)<=U}function Wa(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ja(t[0],t[t.length-1]);)t.pop();return t}function Et(e,t,n){let o=ce(t,n,e);return Math.abs(o)>U?!1:e.x>=Math.min(t.x,n.x)-U&&e.x<=Math.max(t.x,n.x)+U&&e.y>=Math.min(t.y,n.y)-U&&e.y<=Math.max(t.y,n.y)+U}function Za(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return(r>U&&a<-U||r<-U&&a>U)&&(i>U&&s<-U||i<-U&&s>U)?!0:Math.abs(r)<=U&&Et(n,e,t)||Math.abs(a)<=U&&Et(o,e,t)||Math.abs(i)<=U&&Et(e,n,o)||Math.abs(s)<=U&&Et(t,n,o)}function Eu(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 r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&Za(e[t],e[n],e[o],e[r]))return!0}}return!1}function za(e,t){return e.some((n,o)=>t.some((r,a)=>Za(n,e[(o+1)%e.length],r,t[(a+1)%t.length])))}function Uo(e,t){return!t.some((n,o)=>Et(e,n,t[(o+1)%t.length]))&&H(e,t,void 0)}function Mn(e,t,n){let o=Wa(e);if(o.length<3||o.length>Ba||o.some((r,a)=>!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>Ka||Math.abs(r.y)>Ka||Ja(r,o[(a+1)%o.length]))||Math.abs(it(o))<=U||Eu(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Ba} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Tu(e){let t=Mn(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Ya)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(r=>Mn(r,"cutout",e.id));for(let r=0;r<o.length;r+=1){let a=o[r];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=>Uo(s,t))||za(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:r});for(let s=r+1;s<o.length;s+=1)if(za(a,o[s])||Uo(a[0],o[s])||Uo(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:r})}return{outer:t,holes:o}}function Rn(e){return e.map(t=>[t.x,t.y])}function Ua(e){return Wa(e.map(([t,n])=>({x:t,y:n})))}function Ha(e){return Math.abs(e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n[0]*r[1]-r[0]*n[1]},0))/2}function ju(e){return e.reduce((t,n)=>t+(Ha(n[0]??[])-n.slice(1).reduce((o,r)=>o+Ha(r),0)),0)}function Ho(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Ho).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Ho(t[n])}`).join(",")}}`}function Va(e,t,n){let o=e[t];if(o===void 0)return null;let r=o.normalize("NFKC").trim();if(!r||r!==o||r.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 r}function Xa(e){return Ho({categoryKey:e.categoryKey,displayLabel:Va(e,"displayLabel",80),displayType:Va(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function qa(e,t){let n=Math.min(...e.points.map(r=>r.y)),o=Math.min(...e.points.map(r=>r.x));return[n,o,t]}function Fu(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function Qa(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.gaAreaIds)];if(r.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(r.length>$a)throw new u("invalid_operation",`Join Areas supports at most ${$a} areas at once`);let a=r.map(R=>o.objects.find(E=>E.type==="gaArea"&&E.id===R)),i=r.filter((R,E)=>!a[E]);if(i.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:i});let s=a,c=s.find(R=>Ke(R));if(c)throw new u("invalid_operation",`"${c.displayLabel??c.label}" is sold as one box. Only areas sold per person can be joined; switch it back to Standing first.`,{gaAreaId:c.id});N(e,s[0].categoryKey);let l=Xa(s[0]),d=s.find(R=>Xa(R)!==l);if(d)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,d.id]});let f=It(e).objectToSection,g=f.get(s[0].id)??"__ungrouped__",h=s.find(R=>(f.get(R.id)??"__ungrouped__")!==g);if(h)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,h.id],sectionIds:[g,f.get(h.id)??"__ungrouped__"]});let b=s.reduce((R,E)=>{if(!Number.isInteger(E.capacity)||E.capacity<1||E.capacity>oe)throw new u("invalid_operation",`GA area ${E.id} has invalid capacity`,{gaAreaId:E.id});return R+E.capacity},0);if(b>oe)throw new u("invalid_operation",`Joined GA capacity would be ${b}, over the ${oe}-unit area limit`,{capacity:b});let p=ne(e).reduce((R,E)=>R+Pe(E),0),S=n.maxInventory??1e5;if(p>S)throw new u("invalid_operation",`Chart inventory exceeds the ${S}-unit publication limit`,{inventory:p});let I=s.map(Tu),y=I.reduce((R,E)=>R+E.outer.length+E.holes.reduce(($,W)=>$+W.length,0),0);if(y>zo)throw new u("invalid_operation",`Join Areas supports at most ${zo} source vertices`,{vertexCount:y});let w;try{let R=I.map(W=>[Rn(W.outer)]);if(w=An.default.union(R[0],...R.slice(1)),w.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:w.length});let E=I.flatMap(W=>W.holes.map(je=>[Rn(je)]));E.length&&(w=An.default.difference(w,...E));let $=I.findIndex(W=>{let je=[Rn(W.outer),...W.holes.map(Rn)];return ju(An.default.intersection(je,w))<=U});if($>=0)throw new u("invalid_operation",`GA area ${s[$].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[$].id})}catch(R){throw R instanceof u?R:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:R instanceof Error?R.message:"polygon_union_failed"})}if(w.length!==1||!w[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:w.length});let x=Ua(w[0][0]),m=w[0].slice(1).map(Ua),v=x.length+m.reduce((R,E)=>R+E.length,0);if(m.length>Ya||v>zo)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:m.length,vertexCount:v});Mn(x,"outline",s[0].id),m.forEach(R=>Mn(R,"cutout",s[0].id));let C=new Map(o.objects.map((R,E)=>[R.id,E])),P=s.slice().sort((R,E)=>Fu(qa(R,C.get(R.id)??Number.MAX_SAFE_INTEGER),qa(E,C.get(E.id)??Number.MAX_SAFE_INTEGER))),k=P[0],Y=structuredClone(e),J=O(Y,o.floorId),A=J.objects.find(R=>R.type==="gaArea"&&R.id===k.id);A.points=structuredClone(x),m.length?A.holes=structuredClone(m):delete A.holes;let re=new Set(P.slice(1).map(R=>R.id));for(let R=J.objects.length-1;R>=0;R-=1)re.has(J.objects[R].id)&&J.objects.splice(R,1);let M=It(Y).objectToSection.get(k.id)??"__ungrouped__";if(M!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:k.id,beforeSectionId:g,afterSectionId:M});let ie=[],se=new Set;for(let R of P){if(!Qn(R))throw new u("invalid_operation",`GA area ${R.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:R.id});let E=de(R);if(E.length!==R.capacity||E.some($=>se.has($)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:R.id});E.forEach($=>se.add($)),ie.push(...rn(R))}if(ie.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let Oe=new Set(s.map(R=>R.id));for(let R of ne(e).filter(E=>E.type==="gaArea"&&!Oe.has(E.id))){let E=de(R).find($=>se.has($));if(E)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:E,gaAreaId:R.id})}let Nt=P.slice(1).map(R=>R.id);return{floorId:o.floorId,areaId:k.id,survivorLabel:k.label,removedAreaIds:Nt,sourceAreaCount:P.length,capacity:b,inventorySegmentCount:ie.length,outerVertexCount:x.length,holeCount:m.length,sectionId:g,points:x,...m.length?{holes:m}:{},segments:ie}}function Du(e,t,n={}){let{segments:o,...r}=Qa(e,t,n);return r}function Nu(e,t,n={}){let o=Qa(e,t,n),r=O(e,o.floorId),a=r.objects.find(d=>d.type==="gaArea"&&d.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes;let i=r.objects.filter(d=>d.type==="gaArea"&&(d.id===o.areaId||o.removedAreaIds.includes(d.id))).reduce((d,f)=>d+(f.wheelchairPlaces??0),0);a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments),i>0&&(a.wheelchairPlaces=Math.min(i,o.capacity));let s=new Set(o.removedAreaIds);for(let d=r.objects.length-1;d>=0;d-=1)s.has(r.objects[d].id)&&r.objects.splice(d,1);let{segments:c,...l}=o;return{...l,changed:!0}}function Gu(e,t){let n=O(e,t.floorId),o=n.objects.find(c=>c.type==="shape"&&c.id===t.shapeId);if(!o)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(o.role==="stage")throw new u("invalid_operation","A stage keeps its generated outline; turn it back into a shape first");if(o.kind==="polygon")return{floorId:n.floorId,changed:!1,shapeId:o.id};if(o.kind!=="rect"||o.x==null||o.y==null||o.width==null||o.height==null||![o.x,o.y,o.width,o.height].every(Number.isFinite)||o.width<=0||o.height<=0)throw new u("invalid_operation","Only a rectangle can become a custom outline");let{x:r,y:a,width:i,height:s}=o;return o.points=[{x:r,y:a},{x:r+i,y:a},{x:r+i,y:a+s},{x:r,y:a+s}],o.kind="polygon",delete o.x,delete o.y,delete o.width,delete o.height,delete o.cornerRadius,mt(o),{floorId:n.floorId,changed:!0,shapeId:o.id}}function $u(e,t){let n=O(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let r=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!r[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 i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one shape change is required");if(i.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(i.label!==null){if(i.label=i.label.normalize("NFKC").trim(),!i.label)i.label=null;else if(i.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(i.labelStyle!==void 0){let l=r.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(i.labelStyle.size!==void 0&&i.labelStyle.size!==null&&(!Number.isFinite(i.labelStyle.size)||i.labelStyle.size<Ne||i.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${Ne} to ${72}`);if(i.labelStyle.color!==void 0&&i.labelStyle.color!==null&&(i.labelStyle.color=D(i.labelStyle.color,"Shape label color")),i.labelStyle.fontFamily!==void 0&&i.labelStyle.fontFamily!==null&&(i.labelStyle.fontFamily=i.labelStyle.fontFamily.normalize("NFKC").trim(),!i.labelStyle.fontFamily||i.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");if(i.labelStyle.direction!==void 0&&i.labelStyle.direction!==null&&!Kr.includes(i.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");for(let d of["bold","italic","underline"]){let f=i.labelStyle[d];if(f!=null&&typeof f!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(i.fill!==void 0&&i.fill!==null&&(i.fill=D(i.fill,"Shape fill")),i.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(i.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(i.stroke!==void 0&&i.stroke!==null){if(!Number.isFinite(i.stroke.width)||i.stroke.width<.5||i.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");i.stroke={color:D(i.stroke.color,"Shape stroke"),width:i.stroke.width}}if(i.cornerRadius!==void 0&&i.cornerRadius!==null&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(i.opacity!==void 0&&i.opacity!==null&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(i.heightM!==void 0&&i.heightM!==null&&(!Number.isFinite(i.heightM)||i.heightM<.05||i.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(i.rotation!==void 0&&i.rotation!==null){if(!Number.isFinite(i.rotation))throw new u("invalid_operation","Shape rotation must be a finite number of degrees");i.rotation=ve("shape",i.rotation)}if(i.edgeCurvature!==void 0){if(o.length!==1)throw new u("invalid_operation","edgeCurvature can be changed only for one shape at a time");let l=r[0];if((i.kind??l.kind)!=="polygon"||(l.points?.length??0)<3)throw new u("invalid_operation","Curved sides apply only to custom outline (polygon) shapes",{shapeIds:[l.id]});if(i.edgeCurvature!==null){if(!Array.isArray(i.edgeCurvature)||i.edgeCurvature.some(f=>!Number.isFinite(f)||f<-100||f>100))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");if(i.edgeCurvature.length&&i.edgeCurvature.length!==l.points.length)throw new u("invalid_operation",`edgeCurvature needs one value per side: this shape has ${l.points.length} sides`,{shapeIds:[l.id]});i.edgeCurvature.some(f=>Math.abs(f)>.5)||(i.edgeCurvature=null)}let d={kind:"polygon",points:l.points,edgeCurvature:i.edgeCurvature??void 0,holes:l.holes};fr(d).forEach((f,g)=>{if(!hr(d,f))throw new u("invalid_operation",`That curve would cross cut-out ${g+1}. Move the cut-out or use less curve.`,{shapeIds:[l.id]})})}if(i.eventConfigurationIds!==void 0&&i.eventConfigurationIds!==null){let l=i.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");i.eventConfigurationIds=l}if(i.lineCap!==void 0&&i.lineCap!==null&&!ia.includes(i.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(i.lineJoin!==void 0&&i.lineJoin!==null&&!aa.includes(i.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",i.startEnding],["endEnding",i.endEnding]])if(d!=null&&!sa.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(i.lineCap!=null||i.lineJoin!=null||i.startEnding!=null||i.endEnding!=null){let l=r.filter(d=>!Co(i.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 r){let d=JSON.stringify(l);if(i.label===null?delete l.label:i.label!==void 0&&(l.label=i.label),i.labelStyle!==void 0){let f={...l.labelStyle};i.labelStyle.size===null?delete f.size:i.labelStyle.size!==void 0&&(f.size=i.labelStyle.size),i.labelStyle.color===null?delete f.color:i.labelStyle.color!==void 0&&(f.color=i.labelStyle.color),i.labelStyle.fontFamily===null?delete f.fontFamily:i.labelStyle.fontFamily!==void 0&&(f.fontFamily=i.labelStyle.fontFamily),i.labelStyle.bold===null?delete f.bold:i.labelStyle.bold!==void 0&&(f.bold=i.labelStyle.bold),i.labelStyle.italic===null||i.labelStyle.italic===!1?delete f.italic:i.labelStyle.italic===!0&&(f.italic=!0),i.labelStyle.underline===null||i.labelStyle.underline===!1?delete f.underline:i.labelStyle.underline===!0&&(f.underline=!0),i.labelStyle.direction===null||i.labelStyle.direction==="horizontal"?delete f.direction:i.labelStyle.direction!==void 0&&(f.direction=i.labelStyle.direction),Object.keys(f).length?l.labelStyle=f:delete l.labelStyle}if(i.fill===null?delete l.fill:i.fill!==void 0&&(l.fill=i.fill),i.kind!==void 0&&(l.kind=i.kind,Co(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),i.stroke===null?delete l.stroke:i.stroke!==void 0&&(l.stroke={...i.stroke}),i.opacity===null?delete l.opacity:i.opacity!==void 0&&(l.opacity=i.opacity),i.heightM===null?delete l.heightM:i.heightM!==void 0&&(l.heightM=i.heightM),i.rotation===null||i.rotation===0?delete l.rotation:i.rotation!==void 0&&(l.rotation=i.rotation),i.edgeCurvature===null?delete l.edgeCurvature:i.edgeCurvature!==void 0&&(l.edgeCurvature=[...i.edgeCurvature]),i.kind!==void 0&&i.kind!=="polygon"&&(delete l.edgeCurvature,delete l.holes),i.eventConfigurationIds===null?delete l.eventConfigurationIds:i.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...i.eventConfigurationIds]),i.lineCap===null?delete l.lineCap:i.lineCap!==void 0&&(l.lineCap=i.lineCap),i.lineJoin===null?delete l.lineJoin:i.lineJoin!==void 0&&(l.lineJoin=i.lineJoin),i.startEnding===null?delete l.startEnding:i.startEnding!==void 0&&(l.startEnding=i.startEnding),i.endEnding===null?delete l.endEnding:i.endEnding!==void 0&&(l.endEnding=i.endEnding),i.cornerRadius===null)delete l.cornerRadius;else if(i.cornerRadius!==void 0){let f=Math.min(l.width??1/0,l.height??1/0),g=Number.isFinite(f)?f/2:i.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(i.cornerRadius,g)):i.cornerRadius}JSON.stringify(l)!==d&&(mt(l),c=!0)}return{floorId:n.floorId,changed:c,shapeIds:o}}function ts(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),r=Math.min(...n),a=Math.max(...n),i=Math.min(...o),s=Math.max(...o),c=Math.max(1,a-r),l=Math.max(1,s-i);return{cx:r+c/2,cy:i+l/2,width:c,height:l}}function Bu(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(i=>i.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let r=t.updates.map(i=>{if(![i.width,i.height].every(Number.isFinite)||i.width<8||i.height<8||i.width>1e4||i.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:i.shapeId});let s=n.objects.find(l=>l.type==="shape"&&l.id===i.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${i.shapeId}`,{shapeId:i.shapeId});let c=s.role==="stage"?ts(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(S=>!Number.isFinite(S.x)||!Number.isFinite(S.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=l.map(S=>S.x),f=l.map(S=>S.y),g=Math.min(...d),h=Math.max(...d),b=Math.min(...f),p=Math.max(...f);return{cx:(g+h)/2,cy:(b+p)/2,width:Math.max(1,h-g),height:Math.max(1,p-b)}})();return{shape:s,update:i,box:c}}),a=!1;for(let{shape:i,update:s,box:c}of r)if(!(Math.abs(c.width-s.width)<1e-9&&Math.abs(c.height-s.height)<1e-9)){if(i.kind==="rect"||i.kind==="ellipse")i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height;else{let l=s.width/c.width,d=s.height/c.height,f=g=>({x:c.cx+(g.x-c.cx)*l,y:c.cy+(g.y-c.cy)*d});i.points=(i.points??[]).map(f),i.holes&&(i.holes=i.holes.map(g=>g.map(f))),(i.x!=null||i.y!=null||i.width!=null||i.height!=null||i.role==="stage")&&(i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:r.map(({shape:i,update:s})=>({id:i.id,width:s.width,height:s.height}))}}function Ku(e,t){let n=O(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 r=new Set(Sr.map(s=>s.key)),a=t.updates.map(s=>{if(!r.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:ts(c)}}),i=!1;for(let s of a)s.box&&(s.shape.points=zn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",delete s.shape.edgeCurvature,delete s.shape.holes,s.shape.stageKind=s.stageKind,i=!0);return{floorId:n.floorId,changed:i,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Uu(e){return[...Yo(e)].map(([t,n])=>({key:t,...n}))}function Hu(e){if(!Array.isArray(e))return Yo(e);let t=new Map;for(let{key:n,target:o,evidence:r}of e)t.set(n,{target:o,evidence:r});return t}function Yo(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of j(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let r=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(r,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${r}: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(`${r}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function _n(e){return Array.isArray(e)?e.map(_n):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,_n(n)]))}function Vu(e,t){return JSON.stringify(_n(e))===JSON.stringify(_n(t))}function Vo(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Xu(e){return e?e.status==="retracted"?"retract":Vo(e)?"approve":"set":"clear"}function ns(e,t){let n=Hu(e),o=Yo(t),r=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let i of r){let s=n.get(i),c=o.get(i);if(s&&c&&Vu(s.evidence,c.evidence))continue;let l=c?.target??s?.target;l&&a.push({...l,operation:Xu(c?.evidence),...s?{before:s.evidence}:{},...c?{after:c.evidence}:{}})}return a}function qu(e,t){return ns(e,t).some(n=>Vo(n.before)||Vo(n.after))}var Yu=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Ju=new Set(["generated","geometry-verified","configuration-verified"]),Wu=new Set(["none","comparable-build-reference","actual-build-checked"]),Zu=new Set(["clear","partial","obstructed"]);function Xo(e){return e.toISOString().slice(0,10)}function qo(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function nt(e,t,n){if(!qo(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function tt(e,t,n){if(e!==void 0)return nt(e,t,n)}function kn(e,t,n){let o=n?[O(e,n)]:j(e).map(r=>({floorId:r.id,objects:r.objects}));for(let r of o){let a=r.objects.find(i=>i.id===t);if(a)return{floorId:r.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function os(e,t){let n=j(e),o=t?n.find(r=>r.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Tt(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return os(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=kn(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(r=>r.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=kn(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 Ln(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let r=os(e,t.floorId);return n?r.confidenceEvidence=n:delete r.confidenceEvidence,{floorId:r.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let r=kn(e,t.objectId,t.floorId);return Bo(e,{floorId:r.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:r.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=kn(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 Qu(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!qo(e.label,80)||!qo(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(!Zu.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>nt(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 rs(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(!Yu.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Ju.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Wu.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=tt(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 r=e.limitations?.map(f=>nt(f,160,"limitation"));if(r&&r.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=tt(e.assessedAt,40,"assessedAt")??Xo(t),i=Date.parse(a);if(!Number.isFinite(i))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=tt(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Xo(new Date(i+365*24*60*60*1e3))),c=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(c)||c<i||c>i+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=tt(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=tt(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:nt(e.evidenceId,120,"evidenceId"),modelVersion:nt(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}:{},...d?{sourceLabel:e.sourceLabel}:{},...r?.length?{limitations:r}:{},...e.modeledTarget?{modeledTarget:Qu(e.modeledTarget)}:{}}}function ot(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 ef(e,t){let n=rs(t.evidence,t.now),o=JSON.stringify(Tt(e,t)??null),r=Ln(e,t,n),a=JSON.stringify(Tt(e,t)??null);return ot(t,{changed:o!==a,...r,evidenceId:n.evidenceId,status:"draft"})}function tf(e,t){let n=Tt(e,t);if(!n)return ot(t,{changed:!1});let o=Ln(e,t,void 0);return ot(t,{changed:!0,...o,evidenceId:n.evidenceId})}function nf(e,t){let n=Tt(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=nt(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),r=tt(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!r)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 i={...n,status:"approved",approvedByRole:o,assessedAt:Xo(t.now??new Date),...r?{eventConfigurationId:r}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete i.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(i.basisSha256=s);let c=JSON.stringify(n),l=Ln(e,t,i);return ot(t,{changed:c!==JSON.stringify(i),...l,evidenceId:i.evidenceId,status:"approved"})}function of(e,t){let n=Tt(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 ot(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let r=Ln(e,t,o);return ot(t,{changed:!0,...r,evidenceId:n.evidenceId,status:"retracted"})}var rf={width:960,height:600};function af(e,t,n=e){let o={...e,objects:t,floors:void 0,referenceImage:void 0,backgroundImage:Dr(n)},r=fe(o,{freeText:"exclude"}),{width:a,height:i}=rf;return Math.min(a/Math.max(r.width,1e-6),i/Math.max(r.height,1e-6))}function sf(e,t){return!e.text.trim()||e.semanticKind==="icon"||e.labelImportance==="detail"||Ar(e)?!1:!ti(e.fontSize,t)}function is(e){let t=[],n=!!e.floors?.length;for(let o of j(e)){let r=o.objects.filter(i=>i.type==="text");if(!r.length)continue;let a=af(e,o.objects,n?o:e);for(let i of r)sf(i,a)&&t.push({floorId:o.id,text:i,renderedPx:i.fontSize*a})}return t}var En=40,as=96,cf=48,Le=24;function jt(e,t){let n=fe({...e,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"});return{x:n.x+En,y:n.y+En,width:Math.max(0,n.width-2*En),height:Math.max(0,n.height-2*En)}}function lf(e){if(!e.length)return null;let t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),o=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:o-t,height:r-n}}function df(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}var Jo=e=>e.type==="shape"&&e.role==="stage";function uf(e,t){let n=t.x-(e.x+e.width/2),o=t.y-(e.y+e.height/2);return Math.abs(n)>Math.abs(o)?{dx:n>=0?1:-1,dy:0}:{dx:0,dy:o>=0?1:-1}}function ff(e,t){return t.dy===1?e.y+e.height:t.dy===-1?-e.y:t.dx===1?e.x+e.width:-e.x}function Wo(e,t){return t.dy===1?e.y:t.dy===-1?-(e.y+e.height):t.dx===1?e.x:-(e.x+e.width)}function Tn(e,t){let n=pe(e,t.floorId),o=lf(n.objects.filter(Jo).map(y=>jt(n,y)));if(!o)return null;let r=uf(o,n.focalPoint),a=r.dy!==0?t.height:t.width,i=ff(o,r),s=n.objects.filter(y=>!Jo(y)&&df(y)).map(y=>jt(n,y)).filter(y=>Wo(y,r)>=i-1),c=s.length?Math.min(...s.map(y=>Wo(y,r))):1/0,l=as+a+cf,d=c-i,f=()=>{let y=i+as+a/2;return r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2}};if(!s.length)return{center:f(),movedBack:0};if(d>=a+2*Le){let y=i+d/2;return{center:r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2},movedBack:0}}if(t.makeRoom){let y=l-d,w=O(e,t.floorId);for(let x of w.objects)Jo(x)||Wo(jt(n,x),r)<i-1||Ce(x,r.dx*y,r.dy*y);return{center:f(),movedBack:y}}let g="No room between the stage and the seats, so it went beside the stage. Tell the user; moving seats to make room is done in the Designer.",h=t.width,b=t.height,p=o.x+o.width/2,S=o.y+o.height/2;if(r.dy!==0){let y=r.dy===1?Math.min(S,c-Le-b/2):Math.max(S,-c+Le+b/2);return{center:{x:o.x-Le-h/2,y},note:g,movedBack:0}}return{center:{x:r.dx===1?Math.min(p,c-Le-h/2):Math.max(p,-c+Le+h/2),y:o.y-Le-b/2},note:g,movedBack:0}}var ss=40,Ft=24;function hf(e,t,n){let{objects:o}=O(e,t),r=o.find(a=>a.id===n);if(!r)throw new u("object_not_found",`No object ${n} on this floor. Call get_chart for ids.`,{objectId:n});return r}function rt(e,t){if(!t.nearObjectId&&t.placement==="front"){let n=Tn(e,{floorId:t.floorId,width:t.width,height:t.height,makeRoom:t.makeRoom});if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:cs(e,t)}}function gf(e,t){return rt(e,t).center}function cs(e,t){if(t.nearObjectId){let n=hf(e,t.floorId,t.nearObjectId),o=jt(pe(e,t.floorId),n),r=t.side??"rear";return r==="front"?{x:o.x+o.width/2,y:o.y-Ft-t.height/2}:r==="left"?{x:o.x-Ft-t.width/2,y:o.y+o.height/2}:r==="right"?{x:o.x+o.width+Ft+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+Ft+t.height/2}}if(t.placement==="center"){let n=fe(pe(e,t.floorId),{freeText:"exclude"});return{x:n.x+n.width/2,y:n.y+n.height/2}}return ke(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}function jn(e,t,n){if(e===void 0)return n;if(!Number.isFinite(e)||e<=0||e>400)throw new u("invalid_operation",`${t} must be between 0 and 400 metres`);return e*ss}function Zo(e,t){if(e===void 0)return;let n=e.trim();if(!n||n.length>80)throw new u("invalid_operation",`${t} must be 1 to 80 characters`);return n}function bf(e){return e.some(t=>t.type==="shape"&&t.role==="stage")}function mf(e,t){let n=O(e,t.floorId),o=Ir(t.kind),r=jn(t.widthM,"widthM",o.width),a=jn(t.depthM,"depthM",o.height),i=cs(e,{...t,placement:t.placement??"front",width:r,height:a}),s=Zo(t.label,"label")??Cr(t.kind),c=T(e,"stage",t.idFactory,new Set),l={...vr({kind:t.kind,cx:i.x,cy:i.y,width:r,height:a,label:s},c),x:i.x-r/2,y:i.y-a/2,width:r,height:a},d=bf(n.objects);if(n.objects.push(l),!d){let f={x:i.x,y:i.y+a/2+Ft},g=j(e).find(h=>h.id===n.floorId);e.floors?.length&&g&&(g.focalPoint=f),(!e.floors?.length||e.floors[0]?.id===n.floorId)&&(e.focalPoint=f)}return{floorId:n.floorId,stageId:c,label:s,focalPointMoved:!d,createdIds:[c]}}function pf(e,t){let n=Pt(t.role);if(!n)throw new u("invalid_operation",`Unknown landmark: ${t.role}`);let o=O(e,t.floorId),{center:r,note:a}=rt(e,{...t,width:n.width,height:n.height}),i=T(e,"decor",t.idFactory,new Set),s=Li(t.role,r,i),c=Zo(t.label,"label");return c&&s.label!==void 0&&(s.label=n.icon?`${n.icon} ${c}`:c),o.objects.push(s),{floorId:o.floorId,landmarkId:i,label:s.label??null,createdIds:[i],...a?{note:a}:{}}}var yf={small:16,medium:24,large:36};function Fn(e){if(e==="always")return"orientation";if(e==="close-up")return"detail"}var wf="#f7f8fb";function xf(e){let t=e.theme?.background??wf,n=e.theme?.textColor;return n&&cn(n,t)>=4.5?n:Qr(t,"#0b1220","#e8ecf4")}function Sf(e,t){let n=t.text.trim();if(!n||n.length>120)throw new u("invalid_operation","text must be 1 to 120 characters");let o=O(e,t.floorId),r=yf[t.size??"medium"],a=Math.max(r,n.length*r*.56),i=r*1.2,{center:s,note:c}=rt(e,{...t,width:a,height:i}),l=T(e,"txt",t.idFactory,new Set),d={type:"text",id:l,text:n,position:{x:s.x-a/2,y:s.y-i/2},fontSize:r,rotation:0,color:t.color?D(t.color,"color"):xf(e),...t.bold?{bold:!0}:{},...Fn(t.showAt)?{labelImportance:Fn(t.showAt)}:{}};o.objects.push(d);let f=t.showAt===void 0&&is(e).some(h=>h.text.id===l)?'Buyers see this text only after zooming in. For a gate, entrance or anything they must see at once, set showAt "always" or size "large".':void 0,g=[c,f].filter(Boolean).join(" ");return{floorId:o.floorId,textId:l,createdIds:[l],...g?{note:g}:{}}}function If(e,t){let n=yi(t.iconKey);if(!n)throw new u("invalid_operation",`Unknown icon: ${t.iconKey}`);let o=O(e,t.floorId),r=28,{center:a,note:i}=rt(e,{...t,width:r,height:r}),s=T(e,"icon",t.idFactory,new Set),c={type:"text",id:s,semanticKind:"icon",iconKey:n.key,text:n.label,position:a,fontSize:r,rotation:0,...Fn(t.showAt)?{labelImportance:Fn(t.showAt)}:{}};return o.objects.push(c),{floorId:o.floorId,iconId:s,createdIds:[s],...i?{note:i}:{}}}var ls="#4b5568";function vf(e,t){let n=Zo(t.label,"label"),o=O(e,t.floorId),r=jn(t.widthM,"widthM",0),a=jn(t.depthM,"depthM",0),{center:i,note:s}=rt(e,{...t,width:r,height:a}),c=T(e,"shape",t.idFactory,new Set),l={type:"shape",id:c,kind:t.shape??"rect",x:i.x-r/2,y:i.y-a/2,width:r,height:a,fill:t.fill?D(t.fill,"fill"):ls,...n?{label:n}:{},...t.shape!=="ellipse"?{cornerRadius:8}:{}};return o.objects.push(l),{floorId:o.floorId,areaId:c,createdIds:[c],...s?{note:s}:{}}}function Cf(){return["bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"].map(e=>({role:e,label:Pt(e)?.label??e}))}var Of=100,Pf=300,Hp=Of*Pf;function ds(e,t,n){if(n==="horizontal"||!t||![e.x,e.y,t.x,t.y].every(Number.isFinite))return 0;let o=e.x-t.x,r=e.y-t.y,a=Math.hypot(o,r);if(a<=1e-6)return 0;let i={x:r/a,y:-o/a},s=Math.atan2(i.y,i.x)*180/Math.PI;return Object.is(s,-0)?0:s}function Dt(e,t){if(t.placement==="front"){let n=Tn(e,t);if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:ke(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}}var hs={straight:0,gentle:15,medium:30,strong:45},Rf=24,Af=28,Mf=48;function _f(e,t){let n=t.blocks??1;if(!Number.isInteger(n)||n<1||n>8)throw new u("invalid_operation","blocks must be a whole number from 1 to 8");if(t.sectionLabels&&t.sectionLabels.length!==n)throw new u("invalid_operation",`Give one section name per block (${n})`);if(t.blockSeats&&t.blockSeats.length!==n)throw new u("invalid_operation",`Give one seat count per block (${n})`);let o=I=>t.blockSeats?.[I]??t.seatsPerRow,r=I=>Math.max(24,(I-1)*Rf),a=r(t.seatsPerRow),i=Math.max(28,(t.rowCount-1)*Af),s=t.aisleWidth??Mf,c=t.placement??"auto",l=hs[t.curveStyle??"straight"],d={floorId:"",rowIds:[],sectionIds:[],createdIds:[]},f=(I,y,w)=>{let x=ko(e,{floorId:t.floorId,origin:I,rowCount:t.rowCount,seatsPerRow:o(w),categoryKey:t.categoryKey,curve:l,...t.blockStyle?{style:t.blockStyle}:{},rotation:y,sectionLabel:t.sectionLabels?.[w],idFactory:t.idFactory});d.floorId=x.floorId,d.rowIds.push(...x.rowIds),x.sectionId&&d.sectionIds.push(x.sectionId),d.createdIds.push(...x.createdIds)};if(n===1&&c==="front"){let I=Dt(e,{floorId:t.floorId,width:a,height:i,placement:c,makeRoom:t.makeRoom});return I.note&&(d.note=I.note),f({x:I.center.x-a/2,y:I.center.y-i/2},0,0),d}if(n===1){let I=ke(e,{floorId:t.floorId,width:a,height:i,placement:c}),y=ds(I,e.focalPoint,t.orientation??"horizontal"),w=y*Math.PI/180,x=Math.abs(a*Math.cos(w))+Math.abs(i*Math.sin(w)),m=Math.abs(a*Math.sin(w))+Math.abs(i*Math.cos(w)),v=y===0?I:ke(e,{floorId:t.floorId,width:x,height:m,placement:c});return f({x:v.x-a/2,y:v.y-i/2},y,0),d}let g=Array.from({length:n},(I,y)=>r(o(y))),h=g.reduce((I,y)=>I+y,0)+(n-1)*s,b=Dt(e,{floorId:t.floorId,width:h,height:i,placement:c,makeRoom:t.makeRoom});b.note&&(d.note=b.note);let p=b.center,S=p.x-h/2;for(let I=0;I<n;I+=1)f({x:S,y:p.y-i/2},0,I),S+=g[I]+s;return d}function kf(e,t){return t===1?[e]:t===2?[`${e} Left`,`${e} Right`]:t===3?[`${e} Left`,`${e} Centre`,`${e} Right`]:Array.from({length:t},(n,o)=>`${e} ${o+1}`)}var Lf=155,Ef=150,us=110;function Tf(e,t){let n=(t.tableColumns-1)*Lf+us,o=(t.tableRows-1)*Ef+us,{center:r,note:a}=Dt(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=Eo(e,{floorId:t.floorId,center:r,tableRows:t.tableRows,tableColumns:t.tableColumns,seatsPerTable:t.seatsPerTable??8,shape:t.shape??"round",categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}function jf(e,t){let n=Cn(t.capacity),{center:o,note:r}=Dt(e,{floorId:t.floorId,...n,placement:t.placement,makeRoom:t.makeRoom}),a=Lo(e,{floorId:t.floorId,center:o,capacity:t.capacity,categoryKey:t.categoryKey,...t.label===void 0?{}:{label:t.label},...t.displayLabel===void 0?{}:{displayLabel:t.displayLabel},idFactory:t.idFactory});return r?{...a,note:r}:a}var Ff=88,Df=82,Nf=62,Gf=52;function $f(e,t){let n=(t.boothColumns-1)*Ff+Nf,o=(t.boothRows-1)*Df+Gf,{center:r,note:a}=Dt(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=To(e,{floorId:t.floorId,center:r,boothRows:t.boothRows,boothColumns:t.boothColumns,categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}var Bf=40,Ee=30,Te=42,ye=48,Kf={none:[1],center:[1,1],two:[1,2,1]},zf=6;function gs(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}function Qo(e,t){return fe({...e,floors:void 0,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"})}function Uf(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x,y:e.y+e.height},{x:e.x+e.width,y:e.y+e.height}]}function bs(e,t,n,o="front"){let r=j(e),a=t?r.find(I=>I.id===t):r[0];if(!a)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});let i=a.focalPoint??e.focalPoint,s=a.objects.filter(gs),c=0;if(s.length){let I=0,y=0;for(let w of s){let x=Qo(e,w);I+=x.x+x.width/2-i.x,y+=x.y+x.height/2-i.y}Math.hypot(I,y)>1&&(c=Math.atan2(I,y)*180/Math.PI)}let l=o==="behind";l&&(c=(c+360)%360-180);let d=n/2,f={x:Math.sin(c*Math.PI/180),y:Math.cos(c*Math.PI/180)},g=0,h=[],b=s.some(I=>I.type==="row"),p=l?a.objects.filter(I=>I.type==="shape"&&I.role==="stage"):[];for(let I of[...s,...p]){if(I.type==="section"&&b)continue;let y=I.type==="row"?Q(I):Uf(Qo(e,I)),w=I.type==="row"?I.seatSpacing/2:0;for(let x of y){let m=x.x-i.x,v=x.y-i.y,C=Math.atan2(m,v)*180/Math.PI;if(Math.abs((C-c+540)%360-180)>d+10)continue;let k=Math.hypot(m,v)+w;g=Math.max(g,k),h.push({radius:k,depth:m*f.x+v*f.y+w})}}let S=I=>{let y=Math.cos(I/2*Math.PI/180);return y<.2||!h.length?0:(Math.max(...h.map(w=>w.depth))+Te)/y};return{center:i,bearing:c,occupiedRadius:g,floorId:a.id,clearRadius:S}}var ms=100,er=180;function fs(e,t){return e===void 0||t<=0?ms:Math.min(er,Math.max(20,Math.round(e/t*(180/Math.PI))))}function Hf(e,t){let n=t==="two"?2:t==="center"?1:0;return e*Ee+n*ye}function Vf(e,t,n,o){let r=[],a=o+Te-t.occupiedRadius;if(t.occupiedRadius<=0||a<=0)return r;let i=n/2+10;for(let s of O(e,t.floorId).objects){if(gs(s)||s.type==="shape"&&s.role==="stage")continue;let c=Qo(e,s),l=c.x+c.width/2-t.center.x,d=c.y+c.height/2-t.center.y,f=Math.hypot(l,d);if(f<=t.occupiedRadius)continue;let g=Math.atan2(l,d)*180/Math.PI;Math.abs((g-t.bearing+540)%360-180)>i||(Ce(s,l/f*a,d/f*a),r.push(s.id))}return r}function Xf(e,t){let n=t.sectionLabels&&t.sectionLabels.length>1?t.sectionLabels:void 0;if(t.seatsPerRowByRow&&t.seatsPerRowByRow.length!==t.rowCount)throw new u("invalid_operation","Give one seat count per curved row");let o=x=>t.seatsPerRowByRow?.[x]??t.seatsPerRow,r=x=>n?n.length*x*Ee+(n.length-1)*ye:Hf(x,t.aisles),a=x=>{if(n)return n.length*(x-1)*Ee+(n.length-1)*ye;let m=Kf[t.aisles??"none"],v=m.reduce((P,k)=>P+k,0),C=Sn(m,x);return Math.max(...C.map((P,k)=>(P-1)*Ee*v/m[k]))+(m.length-1)*ye},i=t.spreadDegrees===void 0?a:r,s=o(0),c=bs(e,t.floorId,t.spreadDegrees??ms,t.stageSide),l=Math.max((t.firstRowDistanceM??4)*Bf,c.occupiedRadius>0?c.occupiedRadius+Te+ye:0),d=t.spreadDegrees??fs(s===void 0?void 0:i(s),l),f=t.spreadDegrees??(s!==void 0&&d>=er?er:void 0),g=f!==void 0&&s!==void 0?Math.max(...Array.from({length:t.seatsPerRowByRow?t.rowCount:1},(x,m)=>i(o(m))/(f*Math.PI/180)-m*Te)):0,h=Math.max(l,g,c.clearRadius(d)),b=t.spreadDegrees??fs(s===void 0?void 0:i(s),h),p=h+(t.rowCount-1)*Te,S=Vf(e,c,b,p),I=t.spreadDegrees===void 0&&t.rowCount>1?o(t.rowCount-1):void 0,y=(x,m)=>{let v=m/p*(180/Math.PI);return Math.max(-120,Math.min(120,(x-Math.max(v,zf))/2))};if(n){let x=I===void 0?void 0:(I-1)*Ee;return{...qf(e,t,n,c,h,b,s,m=>x===void 0?0:y(m,x)),spreadDegrees:b,movedBackIds:S}}return{...vn(e,{floorId:c.floorId,center:c.center,innerRadius:h,rowCount:t.rowCount,rowGap:Te,startAngle:c.bearing-b/2,endAngle:c.bearing+b/2,seatPitch:Ee,fit:s===void 0?"seat-pitch":"fixed-count",...s===void 0?{}:{seatsPerRow:s},...t.seatsPerRowByRow?{seatsPerRowByRow:t.seatsPerRowByRow}:{},...I===void 0?{}:{taperDegrees:y(b,a(I))},facing:"inward",...t.aisles==="center"?{aisleGaps:{center:ye}}:t.aisles==="two"?{aisleGaps:{left:ye,right:ye}}:{},categoryKey:t.categoryKey,...t.sectionLabel===void 0?{}:{sectionLabel:t.sectionLabel},idFactory:t.idFactory}),spreadDegrees:b,movedBackIds:S}}function qf(e,t,n,o,r,a,i,s){let c=ye/r*(180/Math.PI),l=a>=359,d=(a-(l?n.length:n.length-1)*c)/n.length;if(d<5)throw new u("invalid_operation",`${n.length} sections do not fit in ${Math.round(a)}\xB0; widen the fan or use fewer sections`);let f=o.bearing-a/2+(l?c/2:0),g=n.map((h,b)=>vn(e,{floorId:o.floorId,center:o.center,innerRadius:r,rowCount:t.rowCount,rowGap:Te,startAngle:f+b*(d+c),endAngle:f+b*(d+c)+d,seatPitch:Ee,fit:i===void 0?"seat-pitch":"fixed-count",...i===void 0?{}:{seatsPerRow:i},...t.seatsPerRowByRow?{seatsPerRowByRow:t.seatsPerRowByRow}:{},...s(d)===0?{}:{taperDegrees:s(d)},facing:"inward",categoryKey:t.categoryKey,sectionLabel:h,idFactory:t.idFactory}));return{floorId:o.floorId,rowIds:g.flatMap(h=>h.rowIds),sectionId:g[0].sectionId,sectionIds:g.map(h=>h.sectionId).filter(h=>h!==null),groupId:g[0].groupId,logicalRowCount:t.rowCount,rowSegmentCount:g.reduce((h,b)=>h+b.rowSegmentCount,0),totalSeats:g.reduce((h,b)=>h+b.totalSeats,0),innerRadius:r,outerRadius:g[0].outerRadius,minSeatSpacing:Math.min(...g.map(h=>h.minSeatSpacing)),maxSeatSpacing:Math.max(...g.map(h=>h.maxSeatSpacing)),maxPitchDeviation:Math.max(...g.map(h=>h.maxPitchDeviation)),aisleCount:n.length-(l?0:1),warnings:[...new Set(g.flatMap(h=>h.warnings))]}}0&&(module.exports={AISLE_EMPTY_SEATS,COLORBLIND_SAFE_PALETTE,ChartOperationError,DECOR_UNITS_PER_METRE,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_ROUTE_NAME,DEFAULT_SECTION_CORNER_SMOOTHING,FIRST_CATEGORY_COLOURS,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,NAMED_AREA_FILL,ROUTE_STROKE,ROW_CURVE_DEGREES,addArcFanRows,addArea,addBookableGridArray,addBoothArray,addChartCategories,addChartCategory,addChartFloor,addChartZone,addCurvedRows,addGAArea,addGate,addIcon,addLandmark,addPlacedBoothArray,addPlacedGAArea,addPlacedRowBlocks,addPlacedTableArray,addRoute,addRowAisle,addRowBlock,addStage,addTableArray,addText,allocateFixedArcFanSeats,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,blockSectionLabels,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,convertShapeToOutline,countCoveredInventory,curvedRowsPlacement,decorPlacement,decorPlacementCenter,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,fitSegmentedRowJoin,gaAreaFootprint,gateShape,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,landmarkRoles,makeGate,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,releaseGateReferences,remapGateReferences,removeCategoryMovingInventory,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,routeShape,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,segmentedRowAisleTooNarrow,setConfidenceEvidence,setObjectEntrance,setRoute,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,uniqueCategoryLabel,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateGate,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});