@seatlayer/core 0.88.1 → 0.89.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.
- package/dist/{ar-4SZT3THP.js → ar-UOZGQV3R.js} +1 -1
- package/dist/{be-6TW5GRGS.js → be-D7IPUFM3.js} +1 -1
- package/dist/{bg-P7K6SESD.js → bg-TFVGHBDR.js} +1 -1
- package/dist/{ca-E6R73FI4.js → ca-46QN2JKO.js} +1 -1
- package/dist/{categoryInventory-C5TShXDW.d.cts → categoryInventory-6qAQffC9.d.cts} +1 -1
- package/dist/{categoryInventory-CvhYDK4q.d.ts → categoryInventory-DxHnIyza.d.ts} +1 -1
- package/dist/{chunk-3X2CEDBN.js → chunk-A4GTB3SG.js} +1 -1
- package/dist/chunk-BCMCXHLH.js +1 -0
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +4 -4
- package/dist/core/chart-ops/index.d.ts +4 -4
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/inventory/index.cjs +1 -1
- package/dist/core/inventory/index.d.cts +4 -4
- package/dist/core/inventory/index.d.ts +4 -4
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.d.cts +5 -5
- package/dist/core/layout/index.d.ts +5 -5
- package/dist/core/quality/index.d.cts +3 -3
- package/dist/core/quality/index.d.ts +3 -3
- package/dist/core/render-assets/index.d.cts +2 -2
- package/dist/core/render-assets/index.d.ts +2 -2
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/sections/index.cjs +1 -1
- package/dist/core/sections/index.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/core/sections/index.js +1 -1
- package/dist/{cs-3JAN3UIR.js → cs-5WGMCADH.js} +1 -1
- package/dist/{cy-4G5GKLQ2.js → cy-X3WFFVMY.js} +1 -1
- package/dist/{da-7HO2Z7S3.js → da-JN45KDLF.js} +1 -1
- package/dist/{de-NUKO6ZXA.js → de-TJJM43O6.js} +1 -1
- package/dist/{el-H55AXK2J.js → el-L252TGZ6.js} +1 -1
- package/dist/{es-QSTKSWCW.js → es-GYCFPBTS.js} +1 -1
- package/dist/{et-5PPWOPTR.js → et-4D2RURJU.js} +1 -1
- package/dist/{eventConfigurations-D0G8mxbb.d.cts → eventConfigurations-CMnIbVqZ.d.cts} +1 -1
- package/dist/{eventConfigurations-Dvb8u8bV.d.ts → eventConfigurations-uEwzNRzt.d.ts} +1 -1
- package/dist/{fa-OLG2YL4K.js → fa-QY7GPMTS.js} +1 -1
- package/dist/{fi-PAV5SN5D.js → fi-LPEAS6M5.js} +1 -1
- package/dist/{fr-UZCQILN3.js → fr-JSUSU6JQ.js} +1 -1
- package/dist/{he-RJCSPJ6G.js → he-O54GBSBK.js} +1 -1
- package/dist/{hr-PAOMST2Q.js → hr-ZQFLCHLA.js} +1 -1
- package/dist/{hu-4Z36Q2UK.js → hu-2VXKRZXL.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/dist/{it-QQZIYWUZ.js → it-B4XJ426F.js} +1 -1
- package/dist/{ja-IZR5KSXG.js → ja-CF4TF647.js} +1 -1
- package/dist/{ku-VCCWSULB.js → ku-YIFVOMW6.js} +1 -1
- package/dist/{labeling-YVvDyso3.d.cts → labeling--sSzNon3.d.cts} +1 -1
- package/dist/{labeling-BEamEVl5.d.ts → labeling-CCORxGjk.d.ts} +1 -1
- package/dist/localeLoaders-FO2X6GWB.js +1 -0
- package/dist/{lt-U5AHDGDJ.js → lt-LQDZ2HXY.js} +1 -1
- package/dist/{lv-WY22HKO4.js → lv-BH7ELUCP.js} +1 -1
- package/dist/{nl-MNIC4WUI.js → nl-2XT4V6VG.js} +1 -1
- package/dist/{no-YFUAME7I.js → no-IYOFZH7V.js} +1 -1
- package/dist/{pl-2ETFV772.js → pl-K6ZUTDN5.js} +1 -1
- package/dist/{pt-5CQK36EB.js → pt-5K2BCSEO.js} +1 -1
- package/dist/{renderedQuality-DkDTyl9y.d.cts → renderedQuality-CeSE6pEM.d.cts} +1 -1
- package/dist/{renderedQuality-BqrSXn-t.d.ts → renderedQuality-CrlBXHzi.d.ts} +1 -1
- package/dist/{renderer-C7veuoCF.d.cts → renderer-B1mEhbA7.d.cts} +1 -1
- package/dist/{renderer-CUKvpguA.d.ts → renderer-BwZhXv8G.d.ts} +1 -1
- package/dist/{ro-AANRNCTZ.js → ro-XRMIT3FZ.js} +1 -1
- package/dist/{ru-CTBOMCZ2.js → ru-CUTGR4RJ.js} +1 -1
- package/dist/{seatTypeIcons-DxxPw5Mn.d.ts → seatTypeIcons-8folIM2Q.d.ts} +1 -1
- package/dist/{seatTypeIcons-DHf2-kPo.d.cts → seatTypeIcons-GlskmXH9.d.cts} +1 -1
- package/dist/{sections-COvZ-5ua.d.cts → sections-BFR0_Zeq.d.cts} +1 -1
- package/dist/{sections-B8JXltQM.d.ts → sections-BlBo6siI.d.ts} +1 -1
- package/dist/{segmentedRowModel-Dm3nuc6_.d.ts → segmentedRowModel-CfVeZaOw.d.ts} +1 -1
- package/dist/{segmentedRowModel-DkGr4Jb7.d.cts → segmentedRowModel-DR7Xz6mb.d.cts} +1 -1
- package/dist/{sk-MJ4GVTMT.js → sk-E2CJJV43.js} +1 -1
- package/dist/{sl-X7LAO2EK.js → sl-2VQTITJY.js} +1 -1
- package/dist/{sr-J6QX5N7R.js → sr-NT7MISAD.js} +1 -1
- package/dist/{sv-G5NMSDZW.js → sv-RUJANVJE.js} +1 -1
- package/dist/{tableSizing-CEqWVQ4f.d.ts → tableSizing-DyS3UAha.d.ts} +3 -3
- package/dist/{tableSizing-DVTmR9Wg.d.cts → tableSizing-wnW3HNga.d.cts} +3 -3
- package/dist/{ticketRestrictions-JhGzamZ8.d.ts → ticketRestrictions-BTTN-LzH.d.cts} +11 -4
- package/dist/{ticketRestrictions-DbpUYleE.d.cts → ticketRestrictions-DuYWl2uy.d.ts} +11 -4
- package/dist/{tr-QQPKF6XB.js → tr-N6TZENQ2.js} +1 -1
- package/dist/{types-pwg1Vsz-.d.cts → types-D91PAu7c.d.cts} +1 -1
- package/dist/{types-pwg1Vsz-.d.ts → types-D91PAu7c.d.ts} +1 -1
- package/dist/{uk-XY7N2ZWK.js → uk-6ANXZHF4.js} +1 -1
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.d.cts +3 -3
- package/dist/view3d/index.d.ts +3 -3
- package/dist/{zh-Hans-OEZKZLYA.js → zh-Hans-FY3T2SFA.js} +1 -1
- package/dist/{zh-Hant-EJGZWB2N.js → zh-Hant-X5U3FV62.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHPF5SD6.js +0 -1
- package/dist/localeLoaders-YBKNUI3J.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Xo=Object.create;var Fe=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var Wo=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var er=(e,t)=>{for(var n in t)Fe(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qo(t))!Zo.call(e,i)&&i!==n&&Fe(e,i,{get:()=>t[i],enumerable:!(o=Yo(t,i))||o.enumerable});return e};var tr=(e,t,n)=>(n=e!=null?Xo(Wo(e)):{},en(t||!e||!e.__esModule?Fe(n,"default",{value:e,enumerable:!0}):n,e)),nr=e=>en(Fe({},"__esModule",{value:!0}),e);var Ds={};er(Ds,{COLORBLIND_SAFE_PALETTE:()=>$t,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>At,DEFAULT_SECTION_CORNER_SMOOTHING:()=>St,MAX_BUYER_IMAGE_URL_LENGTH:()=>Ir,MAX_FLOOR_BASE_HEIGHT_M:()=>Xe,addArcFanRows:()=>va,addBookableGridArray:()=>Qa,addBoothArray:()=>Ma,addChartCategory:()=>co,addChartFloor:()=>Wr,addChartZone:()=>ni,addGAArea:()=>_a,addRowBlock:()=>Oa,addTableArray:()=>Aa,applyPolygonHole:()=>Ni,applyReferenceScanRows:()=>Xa,applySectionCornerSmoothing:()=>Vi,applySectionOutlineShaping:()=>Zn,applySectionRowFit:()=>Ti,approveConfidenceEvidence:()=>Fs,arcFanInputForGroup:()=>fo,assignSectionInventoryCategory:()=>$i,automaticPlacementCenter:()=>ma,clearConfidenceEvidence:()=>Ts,compactChartDoc:()=>Gr,compactRowOverrides:()=>_n,compactTableOverrides:()=>An,confidenceEvidenceChangeRequiresPublish:()=>_s,confidenceEvidenceChanges:()=>Vo,confirmReferenceCategoryOutputColor:()=>ta,convertGeneratedSectionToPolygon:()=>zi,countCoveredInventory:()=>tt,detectSeatLabelRun:()=>Rn,dropRedundantSeatOverrideFields:()=>Ue,familyCategoryLabel:()=>lo,gaAreaFootprint:()=>ho,groupRowsAsSegmented:()=>ja,insertSeatingBlock:()=>Mi,isSafeBuyerImageUrl:()=>pn,joinGAAreas:()=>xs,mergeRows:()=>fs,mirrorFirstFloor:()=>_e,normalizeBuyerImageUrl:()=>Z,normalizeDraftEvidence:()=>Jo,parseSeatRefId:()=>es,pickColorblindSafeCategoryColor:()=>so,planCreationCategory:()=>uo,previewArcFanRows:()=>Gt,previewBookableGridArray:()=>Ya,previewGeneratedSectionPolygonConversion:()=>Qn,previewJoinGAAreas:()=>Ss,previewPolygonHole:()=>ot,previewRemovePolygonHole:()=>Jn,previewRowCubicPath:()=>Hn,previewSectionRowFit:()=>Vn,reassignColorblindSafeCategoryColors:()=>ea,relabelChartRows:()=>Ai,removeChartCategory:()=>ga,removeChartFloor:()=>ti,removeChartObjects:()=>Pi,removeChartZone:()=>ri,removePolygonHole:()=>Di,renameChartFloor:()=>Zr,renameDirectSeatImportCategory:()=>Yi,reorderChartCategories:()=>Qi,replaceArcFanRows:()=>Ia,replaceRowBlock:()=>Ea,resetSeatOverrides:()=>os,resizeShapes:()=>Is,resolveCreationCategory:()=>da,retractConfidenceEvidence:()=>Ns,roundBuyerCoordinates:()=>Br,seatRefId:()=>ke,seatSemanticsSignature:()=>Ct,sectionInventorySelectionSummary:()=>Yn,setConfidenceEvidence:()=>Es,setRowBlockSpacing:()=>bs,splitRow:()=>gs,straightenAndSpaceRows:()=>hs,transformSectionBoundary:()=>Bi,transformSectionBoundaryObject:()=>Wn,ungroupSegmentedRow:()=>La,updateBooths:()=>Oi,updateCategoryDefinitions:()=>ao,updateChartFloorBaseHeight:()=>ei,updateChartTheme:()=>pa,updateChartZones:()=>oi,updateGAAreas:()=>Ri,updateRowCubicPath:()=>Li,updateRows:()=>rs,updateSeatOverrides:()=>qt,updateSectionExactPath:()=>Ui,updateSectionMetadata:()=>Gi,updateSegmentedRow:()=>ka,updateShapes:()=>vs,updateStageKinds:()=>Cs,updateTables:()=>Ci,updateTextObjects:()=>_i,updateViewFromSeatFallback:()=>ya});module.exports=nr(Ds);var tn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function or(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/tn(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let c of a.split(/\s+/)){let s=c.length;r&&r+1+s<=o?r+=1+s:(i+=Math.max(1,Math.ceil(s/o)),r=s%o)}}return Math.max(1,i)}function nn(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(c=>c.length))*tn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=or(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var Gs=Math.PI/180;function D(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function pt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function on(e,t){let n=1-t,o=n*n*n,i=3*n*n*t,a=3*n*t*t,r=t*t*t;return{x:o*e.start.x+i*e.control1.x+a*e.control2.x+r*e.end.x,y:o*e.start.y+i*e.control1.y+a*e.control2.y+r*e.end.y}}function Ne(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[on(e,.5)];let o=Array.from({length:n+1},(s,l)=>on(e,l/n)),i=new Float64Array(o.length);for(let s=1;s<o.length;s+=1){let l=o[s].x-o[s-1].x,d=o[s].y-o[s-1].y;i[s]=i[s-1]+Math.hypot(l,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],c=1;for(let s=0;s<t;s+=1){let l=a*s/(t-1);for(;c<i.length-1&&i[c]<l;)c+=1;let d=i[c-1],g=i[c],b=g===d?0:(l-d)/(g-d);r.push({x:o[c-1].x+(o[c].x-o[c-1].x)*b,y:o[c-1].y+(o[c].y-o[c-1].y)*b})}return r}function Se(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 xe(e,t,n){return Math.max(t,Math.min(n,e))}function rr(e){return xe(e,0,1)}function rn(e){let t=rr(e);return t*t*(3-2*t)}var ie=Math.PI*2;function ae(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function ir(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ie;for(;o>=ie;)o-=ie}else{for(;o>0;)o-=ie;for(;o<=-ie;)o+=ie}return o}function De(e){if(e.version!==1||e.closed!==!0||!ae(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!ae(n.end))return!1;if(n.kind==="line"){if(D(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!ae(n.control1)||!ae(n.control2)||D(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!ae(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(D(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(D(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||D(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return D(t,e.start)<=1e-4}function ar(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function mt(e,t=2){if(!De(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),c=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),s=ir(r,c,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(s)*a.radius/n));for(let d=1;d<=l;d+=1){let g=r+s*d/l;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=D(i,a.control1)+D(a.control1,a.control2)+D(a.control2,a.end),c=Math.max(2,Math.ceil(r/n));for(let s=1;s<=c;s+=1)o.push(ar(i,a,s/c))}i=a.end}return D(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function cn(e,t,n){return wt(e,i=>({x:i.x+t,y:i.y+n}))}function wt(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(i=>i.kind==="line"?{...i,end:t(i.end)}:i.kind==="arc"?{...i,center:t(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:t(i.end)}:{...i,control1:t(i.control1),control2:t(i.control2),end:t(i.end)})}}var St=45,yt=150,sr=60;function cr(e){let t=St/100;if(e<=t)return yt;let n=Math.min(1,(e-t)/(1-t));return yt-n*(yt-sr)}var an=.5523;function sn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function lr(e){let t=[],n=[];for(e.forEach((o,i)=>{ae(o)&&(t.length&&sn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&sn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var dr=.5,ur=4/3;function fr(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,c=o/a,s=n*ur;return{kind:"bezier",control1:{x:e.x+o/3+r*s,y:e.y+i/3+c*s},control2:{x:e.x+o*2/3+r*s,y:e.y+i*2/3+c*s},end:{...t}}}function ln(e,t){let{points:n,sourceIndex:o}=lr(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,c=new Array(i).fill(0);if(r?.length)for(let w=0;w<i;w+=1){let S=r[o[w]];c[w]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let s=c.some(w=>Math.abs(w)>1e-6);if(a<=0&&!s)return null;let l=t.wideAngleThresholdDeg??cr(a),d=[];for(let w=0;w<i;w+=1)d[w]=D(n[w],n[(w+1)%i]);let g=new Array(i).fill(0);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],v=n[w],P=n[(w+1)%i],K={x:S.x-v.x,y:S.y-v.y},N={x:P.x-v.x,y:P.y-v.y},H=Math.hypot(K.x,K.y),$=Math.hypot(N.x,N.y);if(H<=1e-9||$<=1e-9)continue;let R=Math.min(1,Math.max(-1,(K.x*N.x+K.y*N.y)/(H*$))),G=Math.acos(R)*180/Math.PI;if(G<l)continue;let M=rn((G-l)/(180-l));g[w]=a*M*.5*Math.min(H,$)}for(let w=0;w<i;w+=1){let S=(w+1)%i,v=g[w]+g[S];if(v>d[w]&&v>1e-9){let P=d[w]/v;g[w]*=P,g[S]*=P}}let b=new Array(i),f=new Array(i);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],v=n[w],P=n[(w+1)%i];if(g[w]<=1e-6){b[w]={...v},f[w]={...v};continue}let K=D(v,S)||1,N=D(v,P)||1;b[w]={x:v.x+(S.x-v.x)/K*g[w],y:v.y+(S.y-v.y)/K*g[w]},f[w]={x:v.x+(P.x-v.x)/N*g[w],y:v.y+(P.y-v.y)/N*g[w]}}if(g.every(w=>w<=1e-6)&&!s)return null;let p=[],m={...f[0]},x=m,I=(w,S)=>{if(D(x,w)<=1e-9)return;let v=c[S];Math.abs(v)>1e-6?p.push(fr(x,w,v*dr*d[S])):p.push({kind:"line",end:{...w}}),x=w};for(let w=1;w<=i;w+=1){let S=w%i,v=n[S];I(b[S],(w-1)%i),g[S]>1e-6&&D(b[S],f[S])>1e-9&&(p.push({kind:"bezier",control1:pt(b[S],v,an),control2:pt(f[S],v,an),end:{...f[S]}}),x=f[S])}if(!p.length)return null;let h=p[p.length-1];D(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:p.push({kind:"line",end:{...m}}));let y={version:1,closed:!0,start:m,segments:p};return De(y)?y:null}var dn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",gr="ABCDEFGHJKLMNPQRSTUVWXYZ",br="abcdefghijklmnopqrstuvwxyz";function un(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function hr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?gr:dn;return un(o,i)}function xt(e,t=!1){let n=t?br:dn;return un(Math.max(0,Math.floor(e)-1),n)}var pr=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function fn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of pr)for(;t>=o;)n+=i,t-=o;return n}function gn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:hr(a,t)}})}function yr(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function se(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",c=e.seatNumbering?.endAt,s=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(s/2),p=a==="updown"?t<f?n+2*t:n-1+2*(s-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${p}`}let l=a==="odd"||a==="even"?2:i,d=c!=null&&Number.isFinite(c)?c-(s-1)*l:n,g=o==="center"?yr(s)[t]:o==="rtl"?s-1-t:t,b;switch(a){case"odd":{let f=d%2===1?d:d+1;b=String(f+g*2);break}case"even":{let f=d%2===0?d:d+1;b=String(f+g*2);break}case"roman":b=fn(d+g*i);break;case"letters-upper":b=xt(d+g*i,!1);break;case"letters-lower":b=xt(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function mr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function X(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${se(e,t)}`}function ve(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return se(e,t);if(!n)return`${e.displayLabel||e.label}-${se(e,t)}`;let i=mr(n),a=n.displayOffset+t;return`${n.displayLabel}-${se(i,a)}`}var bn=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."}];var wr=Math.PI*2;function Sr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function hn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,c=Math.cos(r),s=Math.sin(r),l=i/2,d=a/2,g=[],b=(f,p)=>{g.push({x:f,y:p})};switch(t){case"rect":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rounded":{let f=Math.min(i,a)*.18,p=5,m=(x,I,h)=>{for(let y=0;y<=p;y++){let w=h+y/p*(Math.PI/2);b(x+f*Math.cos(w),I+f*Math.sin(w))}};m(l-f,-d+f,-Math.PI/2),m(l-f,d-f,0),m(-l+f,d-f,Math.PI/2),m(-l+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-l,-d),b(l,-d);let p=24;for(let m=0;m<=p;m++){let x=m/p,I=l-x*i,h=d+f*(1-Math.pow(2*I/i,2));b(I,h)}break}case"thrust":{let f=i*.18,p=a*1.1;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+p),b(-f,d+p),b(-f,d),b(-l,d);break}case"runway":{let f=i*.1,p=a*3;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+p),b(-f,d+p),b(-f,d),b(-l,d);break}case"round":case"oval-cricket":{for(let p=0;p<40;p++){let m=p/40*wr;b(l*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rink-hockey":{for(let f of xr(l,d,l*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of vr(l,d))b(f.x,f.y);break}}return g.map(f=>Sr(f.x,f.y,c,s,n,o))}function xr(e,t,n,o){let i=[],r=(c,s,l)=>{for(let d=0;d<=8;d++){let g=l+d/8*(Math.PI/2);i.push({x:c+n*Math.cos(g),y:s+o*Math.sin(g)})}};return r(e-n,-t+o,-Math.PI/2),r(e-n,t-o,0),r(-e+n,t-o,Math.PI/2),r(-e+n,-t+o,Math.PI),i}function vr(e,t){let n=Math.max(0,e-t),o=[],i=20;for(let a=0;a<=i;a++){let r=-Math.PI/2+a/i*Math.PI;o.push({x:n+t*Math.cos(r),y:t*Math.sin(r)})}for(let a=0;a<=i;a++){let r=Math.PI/2+a/i*Math.PI;o.push({x:-n+t*Math.cos(r),y:t*Math.sin(r)})}return o}var Ir=2e6,Cr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Or=/[\s"'<>`\\]/;function pn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Cr.test(e);if(Or.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Z(e){let t=e.trim();return pn(t)?t:null}function Ie(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var $e=Math.PI/180,Rr=9,ce=16;function It(e,t,n,o){let i=n*$e,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function Ce(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return Ne(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let l=0;l<t;l++)r.push(It(l*n,0,i,a));return r}let c=o/(t-1)*$e,s=n/(2*Math.sin(Math.abs(c)/2));for(let l=0;l<t;l++){let d=l*c,g=s*Math.sin(d),b=-s+s*Math.cos(d);r.push(It(g,b,i,a))}return r}function Pr(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function _r(e,t){let n=Pr(e);return Ce(e).map((o,i)=>{let a=n.get(i),r=Ie(a),c=X(e,i,a),s={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:c,displayLabel:ve(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(s).some(l=>l!==void 0&&l!==!1&&l!=="")?s:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function z(e){let t=[];for(let n of _r(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 Ar(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(e.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function Mr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let p=o.get(d),m=Ie(p),x=p?.label??`${e.label}-${d+1}`,I=e.displayLabel??e.label;return{index:d,label:x,displayLabel:p?.displayLabel??`${I}-${d+1}`,x:g+(p?.dx??0),y:b+(p?.dy??0),categoryKey:p?.categoryKey??e.categoryKey,skipped:!!p?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:p?.wheelchairSpaceType,commercial:p?.commercial,glyph:p?.glyph,viewUrl:p?.viewFromSeatUrl,viewMeta:p?.viewFromSeatUrl?p.viewFromSeatMeta:void 0,labelStyle:p?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+ce,g=e.rotation*$e,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let x=0;x<n;x++){let I=g+x/n*2*Math.PI;t.push(i(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let f=b*$e,p=(2*Math.PI-f)/2,m=g+p;for(let x=0;x<n;x++){let I=m+x/(n-1)*f;t.push(i(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,r=e.height??50,c=Ar(e),s=["top","bottom","left","right"],l=0;for(let d of s){let g=c[d];for(let b=0;b<g;b++){let f,p;d==="top"?(f=-a/2+(b+.5)*a/g,p=-r/2-ce):d==="bottom"?(f=-a/2+(b+.5)*a/g,p=r/2+ce):d==="left"?(f=-a/2-ce,p=-r/2+(b+.5)*r/g):(f=a/2+ce,p=-r/2+(b+.5)*r/g);let m=It(f,p,e.rotation,e.center);t.push(i(l++,m.x,m.y,d))}}return t}function ee(e){return Mr(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 wn(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function yn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,c=t[i].x,s=t[i].y;r>e.y!=s>e.y&&e.x<(c-a)*(e.y-r)/(s-r)+a&&(n=!n)}return n}function jr(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.y-n.y)*(i.y-n.y),c=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=c+1e-7})}function F(e,t,n){return yn(e,t)&&!(n??[]).some(o=>yn(e,o)||jr(e,o))}function vt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function L(e){switch(e.type){case"row":{let t=z(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let i of t)n+=i.x,o+=i.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return vt(e.points);case"section":return vt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?vt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function mn(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Lr(e,t){if(e.type!=="gaArea"||!mn(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((i,a)=>mn(i,o[a]))}function Sn(e,t){let n=e.filter(r=>r.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,i=L(t);return(o?n.find(r=>(r.logicalSectionId??r.id)===o&&(Lr(t,r)||F(i,r.outline,r.holes))):void 0)??n.find(r=>F(i,r.outline,r.holes))}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 B(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var Ke=40;function xn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,c=(s,l)=>{s<o&&(o=s),l<i&&(i=l),s>a&&(a=s),l>r&&(r=l)};for(let s of B(e))if(s.type==="row"){let l=new Map((s.overrides??[]).map(d=>[d.index,d]));Ce(s).forEach((d,g)=>{let b=l.get(g);b?.skip||c(d.x+(b?.dx??0),d.y+(b?.dy??0))})}else if(s.type==="gaArea")for(let l of s.points)c(l.x,l.y);else if(s.type==="section")for(let l of s.outline)c(l.x,l.y);else if(s.type==="decorImage")c(s.x,s.y),c(s.x+s.width,s.y+s.height);else if(s.type==="shape")if(s.points&&s.points.length)for(let l of s.points)c(l.x,l.y);else s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null&&(c(s.x,s.y),c(s.x+s.width,s.y+s.height));else if(s.type==="table"){let l=ce+Rr,d=s.shape==="round"?(s.radius??40)+l:Math.max((s.width??80)/2,(s.height??50)/2)+l;c(s.center.x-d,s.center.y-d),c(s.center.x+d,s.center.y+d)}else if(s.type==="booth"){let l=Math.max(s.width,s.height)/2;c(s.center.x-l,s.center.y-l),c(s.center.x+l,s.center.y+l)}else if(s.type==="text"){if(n)continue;let l=nn(s);c(s.position.x,s.position.y),c(s.position.x+l.width,s.position.y+l.height)}for(let s of[e.referenceImage,e.backgroundImage]){if(!s)continue;let{center:l,width:d}=s,g=d*3/4;c(l.x-d/2,l.y-g/2),c(l.x+d/2,l.y+g/2)}if(!isFinite(o)){let s=e.focalPoint??{x:0,y:0};return{x:s.x-200,y:s.y-200,width:400,height:400}}return{x:o-Ke,y:i-Ke,width:a-o+Ke*2,height:r-i+Ke*2}}function Ge(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}var kr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function On(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Re(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Ct(e){let t=Re(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of kr){let c=i?.[r];c!==void 0&&(a[r]=c)}n.push([X(e,o,i),ve(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function Er(e){return JSON.parse(JSON.stringify(e))}function ze(e,t){let n=Er(e);return t(n)&&Ct(n)===Ct(e)?n:e}function Tr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Re(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let i=t.get(o)?.labelStyle;if(!i)return!1;if(!n)n=i;else if(!On(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Fr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Rn(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let r=Fr(a.slice(n.length+1));if(r===void 0)return;o.push(r)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let i=o[1]-o[0];if(!(i!==1&&i!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==i)return;return i===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Nr(e){if(e.seatCount<1)return!1;let t=Re(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(X(e,i,t.get(i)));let o=Rn(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let i of e.overrides??[])delete i.label;return!0}function Dr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Re(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==se(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Ue(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&On(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===X(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===ve(e,t.index)&&delete t.displayLabel}function Pn(e){return Object.keys(e).every(t=>t==="index")}function Kr(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Ue(e,n);let t=e.overrides.filter(n=>!Pn(n));return t.length?e.overrides=t:delete e.overrides,!0}function $r(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Re(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function _n(e){if(e.type!=="row")return e;let t=ze(e,Tr);return t=ze(t,Nr),t=ze(t,Dr),t=ze(t,Kr),$r(e,t)?t:e}function An(e){if(!e.overrides?.length)return e;let t=e.displayLabel??e.label,n=[];for(let i of e.overrides){let a={...i};a.label===`${e.label}-${a.index+1}`&&delete a.label,a.displayLabel===`${t}-${a.index+1}`&&delete a.displayLabel,a.categoryKey===e.categoryKey&&delete a.categoryKey,a.dx===0&&delete a.dx,a.dy===0&&delete a.dy,Pn(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function vn(e){return e.type==="row"?_n(e):e.type==="table"?An(e):e}function Gr(e){let t=e.objects.map(vn),n=e.floors?.map(o=>({...o,objects:o.objects.map(vn)}));return{...e,objects:t,...n?{floors:n}:{}}}var In=2,zr=3,Cn=6;function Oe(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function Be(e){return{...e,x:Oe(e.x,In),y:Oe(e.y,In)}}function Br(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Be(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Be)),Array.isArray(t.points)&&(t.points=t.points.map(Be)),typeof t.rotation=="number"&&(t.rotation=Oe(t.rotation,Cn)),typeof t.seatSpacing=="number"&&(t.seatSpacing=Oe(t.seatSpacing,Cn));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Be(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let c=Oe(r,zr);c===0?delete i[a]:i[a]=c}return i})),t}var Ur=36,Hr=160;function Mn(e,t=360){let n=xe(Math.round(Number.isFinite(e)?e:1),1,40),o=xe(Number.isFinite(t)?t:360,120,360);return Math.round(xe(n*4*(360/o),Ur,Hr))}var Pe=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],uc=new Map(Pe.map(e=>[e.key,e]));var Vr=[{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"}],fc=new Map(Vr.map(e=>[e.key,e]));var le=8,Ot=24,qr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],gc=new Set(qr);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(e,t){let n=T(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function j(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function A(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Jr(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;let n=(a,r,c)=>(r.x-a.x)*(c.y-a.y)-(r.y-a.y)*(c.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=t.length-1;a>=0;a--){let r=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function Xr(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.map(o=>{let i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a)||1;return{x:o.x+i/r*t,y:o.y+a/r*t}})}function te(e){let t=[];for(let o of e)o.type==="row"?t.push(...z(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ee(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Xr(Jr(t),22);return n.length>=3?n:null}function He(e,t){let n=C(e,t),o=T(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var jn=24,Ln=80;function Rt(e,t){let n=e.normalize("NFKC").trim();if(n.length>jn)throw new u("invalid_operation",`${t} displayed type must be at most ${jn} characters`);return n}function Ve(e,t){if(e.displayType===void 0)return!1;let n=Rt(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function de(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Ln)throw new u("invalid_operation",`${t} displayed label must be at most ${Ln} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function k(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 kn(e,t){if(!Number.isFinite(e)||e<le||e>Ot)throw new u("invalid_operation",`${t} label size must be from ${le} to ${Ot}`)}function ue(e,t){e.size!==void 0&&e.size!==null&&kn(e.size,t),e.color!==void 0&&e.color!==null&&k(e.color,`${t} label color`)}function qe(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&kn(n.size,t),n.color!==void 0&&k(n.color,`${t} label color`))}function Je(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=k(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function Pt(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(i=>i.id!==n&&i.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function _t(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function q(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var Y=Math.PI/180,J=Math.PI/180;function ne(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function _e(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var Yr=0,Xe=120,At=4;function Qr(e){if(!Number.isFinite(e)||e<Yr||e>Xe)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Wr(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(s=>s.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(Xe,(e.floors.length-1)*At),r=Math.min(Xe,a+At),c=A(e,"floor",t.idFactory,new Set);return e.floors.push({id:c,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),_e(e),{changed:!0,floorId:c,floorCount:e.floors.length,baseHeightM:r}}function Zr(e,t){let n=T(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function ei(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(i=>i.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});Qr(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 ti(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(i=>i.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[i]=e.floors;e.objects=i.objects,e.focalPoint=i.focalPoint,e.referenceImage=i.referenceImage,e.backgroundImage=i.backgroundImage,e.floors=void 0}else _e(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:T(e).length}}function ni(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:A(e,"zone",t.idFactory,new Set),label:Pt(e,t.label),color:k(t.color,"Zone color"),...t.focalPoint?{focalPoint:_t(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function oi(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(s=>s.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(s=>[s.id,s])),i=n.filter(s=>!o.has(s));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(e),r=new Map((a.zones??[]).map(s=>[s.id,s]));for(let s of t.updates){if(!Object.keys(s.patch).length)throw new u("invalid_operation",`Zone ${s.zoneId} has no changes`);let d=r.get(s.zoneId);s.patch.label!==void 0&&(d.label=Pt(a,s.patch.label,d.id)),s.patch.color!==void 0&&(d.color=k(s.patch.color,"Zone color")),s.patch.focalPoint!==void 0&&(d.focalPoint=_t(s.patch.focalPoint,"Zone focal point"))}let c=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return c&&(e.zones=a.zones),{changed:c,zoneIds:n,zones:n.map(s=>structuredClone(r.get(s)))}}function ri(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 i=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,_e(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var Ye=[{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 Qe(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&t.set(a,(t.get(a)??0)+r)};i(e.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??e.categoryKey);return t}var En="__sl_ga__",oe=1e5,fe=1e5;function ii(e,t){return`${En}${encodeURIComponent(e)}__${t+1}`}function Mt(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){if(!i||typeof i.sourceAreaId!="string"||!i.sourceAreaId.trim()||i.sourceAreaId.length>160||!Number.isInteger(i.startIndex)||i.startIndex<0||!Number.isInteger(i.count)||i.count<1||i.startIndex+i.count>oe||(n+=i.count,n>oe))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(c=>i.startIndex<c.end&&r>c.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===e.capacity}function We(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}]:[]:Mt(e)?e.inventorySegments.map(n=>({...n})):[]}function Q(e){return We(e).flatMap(t=>Array.from({length:t.count},(n,o)=>ii(t.sourceAreaId,t.startIndex+o)))}function jt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=We(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(c=>c.sourceAreaId===e.id).reduce((c,s)=>Math.max(c,s.startIndex+s.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}function Ze(e){return e.startsWith(En)}var ai="__ungrouped__";function si(e){return e.type==="row"?z(e).map(t=>t.label):e.type==="table"?ee(e).map(t=>t.label):e.type==="booth"?wn(e).map(t=>t.label):e.type==="gaArea"?Q(e):[]}function ci(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Ae(e){let t=B(e),n=t.filter(r=>r.type==="section"),o=new Map;for(let r of n){let c=r.logicalSectionId??r.id;o.get(c)||o.set(c,{id:c,label:r.displayLabel||r.label||"Section",zone:r.zone,seatCount:0,objectIds:[],seatLabels:[]})}let i={id:ai,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},a=new Map;for(let r of t){if(!ci(r))continue;let c=si(r);if(c.length===0)continue;let s=Sn(t,r),l=s?o.get(s.logicalSectionId??s.id):i;l.seatCount+=c.length,l.objectIds.push(r.id),l.seatLabels.push(...c),a.set(r.id,l.id)}return{sections:[...o.values()],ungrouped:i.objectIds.length?i:null,objectToSection:a}}var re={vip:{key:"vip",label:"VIP",color:"#e5484d",price:120},premium:{key:"premium",label:"Premium",color:"#a86b00",price:80},standard:{key:"standard",label:"Standard",color:"#6e7bff",price:45},balcony:{key:"balcony",label:"Balcony",color:"#22a06b",price:30}};function Me(e,t,n,o,i,a,r=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function li(e,t,n,o,i,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function Tn(e,t,n,o,i,a){let r=n/2,c=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-c},{x:r,y:-c},{x:r,y:c},{x:-r,y:c}],capacity:i,categoryKey:a}}function di(e,t,n,o,i){let a=n*2,r=[];for(let c=0;c<a;c++){let s=c%2===0,l=s?["wheelchair"]:["companion"];r.push(s?{index:c,accessibility:l,wheelchairSpaceType:"no-seat"}:{index:c,accessibility:l})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Fn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[re.balcony],sectionLabel:"Balcony",build:()=>[Me("blk-b0","A",-45,18,24,"balcony",18),Me("blk-b1","B",-15,20,24,"balcony",18),Me("blk-b2","C",15,22,24,"balcony",18),Me("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[re.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>Me(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[re.standard],build:()=>[Tn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[re.premium],build:()=>Array.from({length:6},(e,t)=>li(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[re.vip],build:()=>[{type:"table",id:"blk-x0",label:"Box 1",center:{x:-70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"},{type:"table",id:"blk-x1",label:"Box 2",center:{x:70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[re.standard],build:()=>[Tn("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[re.standard],build:()=>[di("blk-wc","A",4,40,"standard")]}];function U(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function Nn(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Dn="M13 4.6a1.6 1.6 0 1 0-3.2 0 1.6 1.6 0 0 0 3.2 0 M11 6.5V13h5l2.4 6 M15 16.4A5 5 0 1 1 9 11.3",Kn=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:"M16 7a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:"M15 5a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M12 8l-4 10h8l-4-10 M10 18v4 M14 18v4"},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:Dn},{key:"first-aid",label:"First aid",group:"facilities",path:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z M12 8v8 M8 12h8"},{key:"coat-check",label:"Coat check",group:"facilities",path:"M12 6a2 2 0 0 1 0-4 2 2 0 0 1 1.6 3.2L21 13H3l8.4-7.8 M3 13h18"},{key:"atm",label:"ATM / cash",group:"facilities",path:"M2 6h20v12H2V6Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0 M6 9h.01 M18 15h.01"},{key:"info",label:"Info point",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 11v5 M12 8h.01"},{key:"lost-found",label:"Lost & found",group:"facilities",path:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14 M16 16l5 5 M9 8.5a2 2 0 1 1 3 1.7c-.8.5-1 .8-1 1.8 M11 15h.01"},{key:"restrooms",label:"Restrooms",group:"facilities",path:"M6 3h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M9 18v-3.5a3 3 0 0 1 6 0V18"},{key:"charging",label:"Charging point",group:"facilities",path:"M3 8h13v8H3V8Z M16 10h3v4h-3 M9.6 9l-2 3.5h2.5l-1.5 3"},{key:"smoking",label:"Smoking area",group:"facilities",path:"M2 15h13v3H2v-3Z M18 16h2 M19 8c0 1 1 1.5 1 2.5S19 12 19 13"},{key:"no-smoking",label:"No smoking",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M5.6 5.6l12.8 12.8 M7 13h6v2H7v-2Z"},{key:"food",label:"Food",group:"food-drink",path:"M7 3v6a2 2 0 0 0 4 0V3 M9 11v10 M17 3c-1.6 1-2.2 3-2.2 6 0 2 .9 3.2 2.2 3.6V21"},{key:"bar",label:"Bar",group:"food-drink",path:"M4 5h16l-8 8-8-8Z M12 13v6 M8 20h8"},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 8h13v4a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z M17 9h2a2 2 0 0 1 0 4h-2 M8 2v2 M11 2v2 M4 21h14"},{key:"water",label:"Water / drinks",group:"food-drink",path:"M12 22a7 7 0 0 1-7-7c0-5 7-12 7-12s7 7 7 12a7 7 0 0 1-7 7Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:"M6 8h12l-1 12H7L6 8Z M9 8V6a3 3 0 0 1 6 0v2"},{key:"screen",label:"Screen",group:"facilities",path:"M3 4h18v12H3V4Z M9 20h6 M12 16v4 M10 8l4 2-4 2V8Z"},{key:"sound-booth",label:"Sound booth",group:"facilities",path:"M6 4v16 M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4 M12 4v16 M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M18 4v16 M18 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4"},{key:"entrance",label:"Entrance",group:"navigation",path:"M14 3h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-5 M3 12h11 M10 8l4 4-4 4"},{key:"exit",label:"Exit",group:"navigation",path:"M10 3H5a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h5 M14 12h7 M17 8l4 4-4 4"},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:"M14 4.6a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0 M12.5 8l-3.5 2 1.6 3.6-2 4.4 M12.5 10l3.5 1.5 M9 10.5l-3.5 1 M15 12h6 M18 9l3 3-3 3"},{key:"stairs",label:"Stairs",group:"navigation",path:"M3 20v-4h4v-4h4v-4h4V4h5"},{key:"elevator",label:"Elevator",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M8 11l1.5-2 1.5 2 M8 14l1.5 2 1.5-2 M15 8v8"},{key:"parking",label:"Parking",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M9 17V7h4a3 3 0 0 1 0 6H9"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:Dn},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}];var ui=new Map(Kn.map(e=>[e.key,e]));function $n(e){return typeof e=="string"&&ui.has(e)}var Fc=Kn.map(e=>e.key);function Lt(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Gn(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=e.holes.map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=cn(e.outlinePath,t,n)),e.holes&&(e.holes=e.holes.map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function fi(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function je(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function et(e,t,n){let o=je(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 gi(e,t,n,o){let i=je(e,t,n),a=je(e,t,o),r=je(n,o,e),c=je(n,o,t);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&c<-1e-7||r<-1e-7&&c>1e-7)?!0:Math.abs(i)<=1e-7&&et(n,e,t)||Math.abs(a)<=1e-7&&et(o,e,t)||Math.abs(r)<=1e-7&&et(e,n,o)||Math.abs(c)<=1e-7&&et(t,n,o)}function bi(e){return e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n.x*i.y-i.x*n.y},0)}function hi(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&gi(e[t],e[n],e[o],e[i]))return!0}}return!1}function zn(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>fi(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(bi(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:hi(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function Ci(e,t){let n=C(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(y=>y.type==="table"&&y.id===h)),a=o.filter((h,y)=>!i[y]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=k(r.fill,"Table surface color"));let c=r.seatCount!==void 0,s=r.seatCountsBySide!==void 0;if(s){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let h=["top","bottom","left","right"],y=Object.keys(r.seatCountsBySide);if(y.length!==h.length||y.some(S=>!h.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of h){let v=r.seatCountsBySide[S];if(!Number.isInteger(v)||v<0||v>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let w=h.reduce((S,v)=>S+r.seatCountsBySide[v],0);if(w<1||w>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(c&&r.seatCount!==w)throw new u("invalid_operation",`seatCount must equal the ${w}-chair seatCountsBySide total`);r.seatCount=w,r.sides=h.filter(S=>r.seatCountsBySide[S]>0)}if(r.seatCount!==void 0&&(!Number.isInteger(r.seatCount)||r.seatCount<1||r.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(r.shape!==void 0&&r.shape!=="round"&&r.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(r.automaticRadius!==void 0&&typeof r.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(r.shape==="rect"&&r.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(r.bookAsWhole===!0&&r.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(r.variableOccupancy===!1&&(r.minOccupancy!==void 0||r.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(h,y,w,S)=>{if(y!==void 0&&(!Number.isFinite(y)||y<w||y>S))throw new u("invalid_operation",`${String(h)} must be from ${w} to ${S}`)};if(l("rotation",r.rotation,0,360),l("radius",r.radius,24,160),l("seatArc",r.seatArc,120,360),l("width",r.width,40,320),l("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let h=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(y=>!h.has(y)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=de(r,"Table"),g=Ve(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!s&&(c||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let y=structuredClone(h);if(Object.assign(y,r),r.fill===null&&delete y.fill,y.shape==="round")delete y.seatCountsBySide,y.automaticRadius===!0?y.radius=Mn(y.seatCount,y.seatArc):delete y.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${y.label}" is rectangular and cannot use automatic radius`,{tableId:y.id});delete y.automaticRadius}if(y.overrides&&r.seatCount!==void 0&&(y.overrides=y.overrides.filter(w=>w.index<y.seatCount),y.overrides.length||delete y.overrides),r.bookAsWhole===!1&&delete y.bookAsWhole,r.variableOccupancy===!1&&(delete y.variableOccupancy,delete y.minOccupancy,delete y.maxOccupancy),y.bookAsWhole||delete y.bookAsWhole,y.variableOccupancy||delete y.variableOccupancy,y.bookAsWhole&&y.variableOccupancy)throw new u("invalid_operation",`Table "${y.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:y.id});if((y.bookAsWhole||y.variableOccupancy)&&y.overrides?.length)throw new u("invalid_operation",`Table "${y.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:y.id,overriddenChairIndices:y.overrides.map(w=>w.index)});if(y.bookAsWhole)delete y.minOccupancy,delete y.maxOccupancy;else if(y.variableOccupancy){if(!Number.isInteger(y.minOccupancy)||!Number.isInteger(y.maxOccupancy)||y.minOccupancy<1||y.maxOccupancy<y.minOccupancy||y.maxOccupancy>y.seatCount)throw new u("invalid_operation",`Table "${y.label}" needs whole-number minimum and maximum guests from 1 to its ${y.seatCount}-chair capacity`,{tableId:y.id,seatCount:y.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:y.id});delete y.minOccupancy,delete y.maxOccupancy}if(g&&delete y.displayType,d&&delete y.displayLabel,y.shape==="rect"){if(y.width??=80,y.height??=50,y.seatCountsBySide){let w=["top","bottom","left","right"],S=w.reduce((v,P)=>v+y.seatCountsBySide[P],0);if(S!==y.seatCount)throw new u("invalid_operation",`Table "${y.label}" side counts total ${S}, but seatCount is ${y.seatCount}`,{tableId:y.id,seatCount:y.seatCount,seatCountsBySide:y.seatCountsBySide});y.sides=w.filter(v=>y.seatCountsBySide[v]>0)}}else y.radius??=40;if((y.bookAsWhole||y.variableOccupancy)&&Ze(y.label))throw new u("invalid_operation",`Grouped table label "${y.label}" uses SeatLayer's reserved GA namespace`,{tableId:y.id});return y}),f=new Map(b.map(h=>[h.id,h])),p=new Set(o),m=new Map;for(let h of T(e))for(let y of h.objects){let w=y.type==="table"?f.get(y.id)??y:y,S=[];w.type==="row"?S=z(w).map(v=>v.label):w.type==="table"?S=w.bookAsWhole||w.variableOccupancy?[w.label]:ee(w).map(v=>v.label):w.type==="booth"?S=[w.label]:w.type==="gaArea"&&(S=Q(w));for(let v of S){let P=m.get(v);if(P&&(p.has(P)||p.has(w.id)))throw new u("invalid_operation",`Inventory label "${v}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:v,conflictingObjectIds:[P,w.id]});m.set(v,P??w.id)}}let x=!1,I=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,y]of i.entries()){let w=b[h],S=JSON.stringify(y);for(let v of I)v in w||delete y[v];Object.assign(y,w),JSON.stringify(y)!==S&&(x=!0)}return{floorId:n.floorId,changed:x,tableIds:o}}function Oi(e,t){let n=C(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(p=>p.type==="booth"&&p.id===f)),a=o.filter((f,p)=>!i[p]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey);let c=(f,p,m,x)=>{if(p!==void 0&&(!Number.isFinite(p)||p<m||p>x))throw new u("invalid_operation",`${f} must be from ${m} to ${x}`)};c("width",r.width,30,400),c("height",r.height,30,400),c("rotation",r.rotation,0,360);let s=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=zn(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let l=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=de(r,"Booth"),g=Ve(r,"Booth"),b=!1;for(let f of i){let p=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,s?delete f.points:l&&(f.points=l),JSON.stringify(f)!==p&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Ri(e,t){let n=C(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let i=o.map(d=>n.objects.find(g=>g.type==="gaArea"&&g.id===d)),a=o.filter((d,g)=>!i[g]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one GA area change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(r.categoryKey!==void 0&&j(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>1e5))throw new u("invalid_operation","capacity must be an integer from 1 to 100000");if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let c=de(r,"GA area"),s=Ve(r,"GA area");if(r.capacity!==void 0)for(let d of i){if(d.inventorySegments!==void 0&&r.capacity<d.capacity)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot be reduced below ${d.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:d.id,currentCapacity:d.capacity,requestedCapacity:r.capacity});if(d.inventorySegments!==void 0&&r.capacity>d.capacity&&jt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let l=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:jt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),c&&delete d.displayLabel,s&&delete d.displayType,JSON.stringify(d)!==g&&(l=!0)}return{floorId:n.floorId,changed:l,gaAreaIds:o}}function tt(e,t){if(t.length<3)return 0;let n=i=>F(i,t,void 0),o=0;for(let i of e)n(L(i))&&(i.type==="row"?o+=z(i).length:i.type==="table"?o+=ee(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=ne(i)));return o}function Pi(e,t){let n=C(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(c=>n.objects.find(s=>s.id===c)),i=t.objectIds.filter((c,s)=>!o[s]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(t.objectIds);for(let c=n.objects.length-1;c>=0;c--)r.has(n.objects[c].id)&&n.objects.splice(c,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(c=>({id:c.id,type:c.type})),removedInventory:a.reduce((c,s)=>c+ne(s),0),remainingObjectCount:n.objects.length}}function _i(e,t){let n=C(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=k(r.color,"Text color")),r.bold!==void 0&&typeof r.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(r.italic!==void 0&&typeof r.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(r.width!==void 0&&r.width!==null&&(!Number.isFinite(r.width)||r.width<40||r.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(r.align!==void 0&&!["left","center","right"].includes(r.align))throw new u("invalid_operation","Text align must be left, center, or right");if(r.lineHeight!==void 0&&(!Number.isFinite(r.lineHeight)||r.lineHeight<.8||r.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(r.letterSpacing!==void 0&&(!Number.isFinite(r.letterSpacing)||r.letterSpacing<-2||r.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(r.underline!==void 0&&typeof r.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(r.opacity!==void 0&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(r.background!==void 0&&r.background!==null){r.background.color=k(r.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(l)||l<0||l>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(g)||g<.1||g>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(l=>Object.prototype.hasOwnProperty.call(r,l))&&i.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!$n(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(l=>l.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let s=!1;for(let l of i){let d=JSON.stringify(l);r.iconKey!==void 0&&(l.iconKey=r.iconKey),r.text!==void 0&&(l.text=r.text),r.fontSize!==void 0&&(l.fontSize=r.fontSize),r.fontFamily===null?delete l.fontFamily:r.fontFamily!==void 0&&(l.fontFamily=r.fontFamily),r.rotation!==void 0&&(l.rotation=r.rotation),r.color===null?delete l.color:r.color!==void 0&&(l.color=r.color),r.bold!==void 0&&(r.bold?l.bold=!0:delete l.bold),r.italic!==void 0&&(r.italic?l.italic=!0:delete l.italic),r.width===null?delete l.width:r.width!==void 0&&(l.width=r.width),r.align!==void 0&&(r.align==="left"?delete l.align:l.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete l.lineHeight:l.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?l.underline=!0:delete l.underline),r.opacity!==void 0&&(r.opacity===1?delete l.opacity:l.opacity=r.opacity),r.background===null?delete l.background:r.background!==void 0&&(l.background=r.background),r.labelImportance===null?delete l.labelImportance:r.labelImportance!==void 0&&(l.labelImportance=r.labelImportance),JSON.stringify(l)!==d&&(Ge(l),s=!0)}return{floorId:n.floorId,changed:s,textIds:o}}function Ai(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),c=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,s=gn(r.map(b=>({label:c(b)})),t.options),l=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=l===void 0||l===""||l==="Row"?t.displayType===void 0?void 0:null:l,g=!1;return r.forEach((b,f)=>{let p=s[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(c(b)!==p&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=p:b.displayLabel=p),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:c(b),...b.displayType?{displayType:b.displayType}:{}}))}}function Mi(e,t){let n=Fn.find(l=>l.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=C(e,t.floorId),i=new Set,a=n.build().map(l=>structuredClone(l));for(let l of a)l.id=A(e,l.type,t.idFactory,i),Gn(l,t.center.x,t.center.y);for(let l of n.categories)e.categories.some(d=>d.key===l.key)||e.categories.push({...l});let r=a.filter(l=>l.type==="row");if(r.length){let l=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Nn(d.label);g!=null&&(l=Math.max(l,g+1))}for(let d of r)d.label=U(l++)}let c=new Set(o.objects.flatMap(l=>"label"in l&&l.label?[l.label]:[]));for(let l of a){if((l.type==="table"||l.type==="booth")&&c.has(l.label)){let d=/^(.*?)(\d+)$/.exec(l.label),g=d?d[1]:`${l.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(c.has(`${g}${b}`));l.label=`${g}${b}`}"label"in l&&l.label&&c.add(l.label)}o.objects.push(...a);let s=null;if(n.sectionLabel&&t.wrapInSection!==!1){let l=te(a);if(l){let d={type:"section",id:A(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:l};o.objects.push(d),s=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(l=>l.id),...s?[s]:[]],sectionId:s}}function ji(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=Ne(t,97),i=o.slice(1).reduce((a,r,c)=>a+Math.hypot(r.x-o[c].x,r.y-o[c].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:i}}function Hn(e,t){let n=C(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=ji(t.path),a=z(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let c=z(r),s=a.map((d,g)=>Math.hypot(d.x-c[g].x,d.y-c[g].y)),l=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:s.length?s.reduce((d,g)=>d+g,0)/s.length:0,maxSeatMovement:s.length?Math.max(...s):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Li(e,t){let n=Hn(e,t);if(!n.changed)return n;let i=C(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(t.path),i.origin={...t.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function ki(e,t){let n=e.map((o,i)=>[...o,t[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let c=n[r][o];for(let s=o;s<4;s++)n[r][s]-=c*n[o][s]}}return[n[0][3],n[1][3],n[2][3]]}function Ei(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let c=0;c<3;c++){n[c]+=a[c]*r;for(let s=0;s<3;s++)t[c][s]+=a[c]*a[s]}}let o=ki(t,n);return o?{x:o[0],y:o[1]}:null}function Bn(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function Vn(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=T(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Ei(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let c=n.objects.filter(f=>f.type==="row"&&F(L(f),o.outline,o.holes)),s=c.filter(f=>!!f.path).map(f=>f.id),l=[],d=[],g=i/100;for(let f of c){if(f.path)continue;if(f.seatCount<2){l.push(f.id);continue}let p=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(p<=f.seatSpacing/2+1e-6){l.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*p))/Y,x=z(f),I=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/Y,y=(f.curve!==0?Math.sign(f.curve):x.length>1&&Math.sign(Bn(Math.atan2(x[1].x-r.x,x[1].y-r.y)/Y-I))||1)*m*(f.seatCount-1);if(Math.abs(y)>320){l.push(f.id);continue}let w=-I,S=f.curve+(y-f.curve)*g,v=f.rotation+Bn(w-f.rotation)*g,P={...f,curve:S,rotation:v},N=z(P).map((H,$)=>Math.hypot(H.x-x[$].x,H.y-x[$].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:y,resultCurve:S,fromRotation:f.rotation,resultRotation:v,rmsMovement:Math.sqrt(N.reduce((H,$)=>H+$**2,0)/N.length),maxMovement:Math.max(...N)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:s,skippedInvalidRowIds:l,averageMovement:b.length?b.reduce((f,p)=>f+p,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function Ti(e,t){let n=Vn(e,t),o=C(e,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let c=o.objects.find(s=>s.type==="row"&&s.id===r.rowId);(c.curve!==r.resultCurve||c.rotation!==r.resultRotation)&&(c.curve=r.resultCurve,c.rotation=r.resultRotation,delete c.arcFanGeneration,delete c.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function qn(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),c=q(n,o,t);return i*a<-1e-9&&r*c<-1e-9}function Un(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>qn(n,i,a,t[(r+1)%t.length]))})}function Fi(e){if(e.length<3||e.length>256||Math.abs(Se(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)&&qn(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function nt(e,t,n){let o=C(e,t),i=o.objects.find(a=>(a.type==="section"||a.type==="gaArea")&&a.id===n);if(!i)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});return{target:o,object:i,outer:i.type==="section"?i.outline:i.points}}function ot(e,t){let{target:n,object:o,outer:i}=nt(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Fi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!F(l,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Un(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],c=t.holeIndex??r.length;if(!Number.isInteger(c)||c<0||c>r.length||t.holeIndex!=null&&c>=r.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<r.length;l++){if(l===t.holeIndex)continue;let d=r[l];if(Un(a,d)||F(a[0],d,void 0)||F(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let s=n.objects.filter(l=>l.id!==o.id&&l.type!=="section"&&F(L(l),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:c,vertexCount:a.length,excludedObjectIds:s.map(l=>l.id),excludedInventoryUnits:tt(n.objects.filter(l=>l.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ni(e,t){let n=ot(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function Jn(e,t){let{target:n,object:o}=nt(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[t.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&F(L(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:tt(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Di(e,t){let n=Jn(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Ki(e){let t=Z(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Xn(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.find(c=>c.type==="section"&&c.id===r)),i=n.filter((r,c)=>!o[c]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function Yn(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),i=Ae(He(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),c=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),s=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of c){let p=r.get(f);if(p)if(p.type==="row"||p.type==="table")for(let m of Qe(p).keys())s.add(m);else(p.type==="booth"||p.type==="gaArea")&&s.add(p.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(p=>{let m=r.get(p);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:c,categoryApplicable:g,...g&&s.size===1?{categoryKey:[...s][0]}:!g&&!c.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?s.size!==1:!c.length&&d.size>1,viewApplicable:b}}function $i(e,t){j(e,t.categoryKey);let n=Yn(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=C(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,c=new Set(n.logicalSectionIds);for(let s of o.objects)s.type!=="section"||!c.has(s.logicalSectionId??s.id)||s.editor?.defaultCategoryKey!==t.categoryKey&&(s.editor={...s.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let s of o.objects){if(!i.has(s.id)||s.type!=="row"&&s.type!=="table"&&s.type!=="booth"&&s.type!=="gaArea"||(s.categoryKey!==t.categoryKey&&(s.categoryKey=t.categoryKey,a=!0),s.type!=="row"&&s.type!=="table"||!s.overrides?.length))continue;let l=s.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});l.length?s.overrides=l:delete s.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Gi(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),c=Object.keys(a).filter(f=>!r.has(f));if(c.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${c.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=Ki(a.viewFromSeatUrl)),a.labelPresentation?.position&&(!Number.isFinite(a.labelPresentation.position.x)||!Number.isFinite(a.labelPresentation.position.y)))throw new u("invalid_operation","Section label position must be finite");if(a.labelPresentation?.rotation!=null&&!Number.isFinite(a.labelPresentation.rotation))throw new u("invalid_operation","Section label rotation must be finite");if(a.labelPresentation!==void 0&&qe(a.labelPresentation,"Section"),a.labelStyle!==void 0&&ue(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(f=>f.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=k(a.color,"Section color"));let s=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=s?n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let p=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let m=x=>{f.physical3dProvenance&&(delete f.physical3dProvenance[x],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,m("height")):a.height!==void 0&&(f.height=a.height,f.physical3dProvenance={...f.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete f.rake,m("rake")):a.rake!==void 0&&(f.rake=a.rake,f.physical3dProvenance={...f.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete f.surfaceKind,m("surfaceKind")):a.surfaceKind!==void 0&&(f.surfaceKind=a.surfaceKind,f.physical3dProvenance={...f.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete f.color:a.color!==void 0&&(f.color=a.color),JSON.stringify(f)!==p&&(b=!0,g.add(f.id))}for(let f of d){let p=JSON.stringify(f),m=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let x=Je(f.labelPresentation,a.labelStyle);x?f.labelPresentation=x:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==p&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function Qn(e,t){let n=C(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&F(L(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+ne(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function zi(e,t){let n=Qn(e,t),i=C(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function Wn(e,t){let n=(...c)=>c.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=c=>({x:c.x+t.dx,y:c.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let c=L(e);o=s=>({x:c.x+(s.x-c.x)*t.factor,y:c.y+(s.y-c.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let s=t.degrees*Math.PI/180,l=Math.cos(s),d=Math.sin(s),g=L(e);o=b=>{let f=b.x-g.x,p=b.y-g.y;return{x:g.x+f*l-p*d,y:g.y+f*d+p*l}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?c=>({x:2*t.coordinate-c.x,y:c.y}):c=>({x:c.x,y:2*t.coordinate-c.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=wt(e.outlinePath,o,i,a)),e.holes&&(e.holes=e.holes.map(c=>c.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(c=>c.kind)??[]}}function Bi(e,t){let n=C(e,t.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Wn(o,t.transform)}}function Ui(e,t){let n=C(e,t.floorId),o=n.objects.find(c=>c.type==="section"&&c.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!De(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=mt(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(c=>c.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function Hi(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function Vi(e,t){return Zn(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function Zn(e,t){let n=C(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(c=>!Number.isFinite(c)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let c of o){let s=n.objects.find(h=>h.type==="section"&&h.id===c);if(!s||!Hi(s))continue;let d=structuredClone(s);a.set(s.id,{section:s,snapshot:d});let g=JSON.stringify(s),b=(s.sourceOutline??s.outline).map(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??s.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?s.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),x=m?.some(h=>Math.abs(h)>.5)===!0,I=f>.5||x?ln(b,{cornerSmoothing:f,...x?{edgeCurvature:m}:{}}):null;I?(s.sourceOutline=b,s.outlinePath=I,s.outline=mt(I),f>.5?s.cornerSmoothing=f:delete s.cornerSmoothing,x?s.edgeCurvature=[...m]:delete s.edgeCurvature):(s.outline=b,delete s.outlinePath,delete s.sourceOutline,delete s.cornerSmoothing,delete s.edgeCurvature);for(let h=0;h<(s.holes?.length??0);h+=1)ot(e,{floorId:n.floorId,objectId:s.id,points:s.holes[h],holeIndex:h});JSON.stringify(s)!==g&&(r=!0,i.add(s.id))}}catch(c){for(let{section:s,snapshot:l}of a.values()){let d=s;for(let g of Object.keys(d))delete d[g];Object.assign(s,structuredClone(l))}throw c}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}var Et=.15,Tt=1.6;var qi=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Nt(e){let t=qi.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(i=>i+i).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Dt(e,t){let n=a=>{let r=Nt(a);if(!r)return null;let c=h=>{let y=h/255;return y<=.04045?y/12.92:((y+.055)/1.055)**2.4},s=c(r[0]),l=c(r[1]),d=c(r[2]),g=(.4124*s+.3576*l+.1805*d)/.95047,b=.2126*s+.7152*l+.0722*d,f=(.0193*s+.1192*l+.9505*d)/1.08883,p=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=p(g),x=p(b),I=p(f);return[116*x-16,500*(m-x),200*(x-I)]},o=n(e),i=n(t);return o&&i?Math.hypot(o[0]-i[0],o[1]-i[1],o[2]-i[2]):null}function Ft(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function eo(e){return .2126*Ft(e[0])+.7152*Ft(e[1])+.0722*Ft(e[2])}function rt(e,t){let n=Nt(e),o=Nt(t);if(!n||!o)return null;let i=eo(n),a=eo(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var to=["butt","round","square"],no=["miter","round","bevel"],oo=["none","arrow"];function Kt(e){return e==="line"||e==="polyline"}var ro=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22}}],ml=ro.map(e=>e.key),Ji=new Map(ro.map(e=>[e.key,e]));function Le(e){return typeof e=="string"&&Ji.has(e)}var Xi=new Set(["companion","child","senior","student","membership","custom"]);function ge(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let c=r.toLocaleLowerCase("en"),s=n.get(c);if(s)throw new u("duplicate_category_label",`Categories ${s} and ${a} share the same label`,{categoryKeys:[s,a],label:r});if(n.set(c,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.referenceDirectSeatImport!==void 0){let l=i.referenceDirectSeatImport;if(l.assetId!==l.assetId.trim()||l.assetId.length>160||!l.assetId||l.familyId!==l.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(l.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.seatGlyph!=null&&!Le(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let l=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),p=f.toLocaleLowerCase("en");if(!b||b.length>160||l.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(p))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!Xi.has(g.restriction))throw new u("invalid_operation",`Ticket tier ${b} has an unknown restriction`,{categoryKey:a,tierId:b});if(g.buyerMessage!=null){if(g.buyerMessage=g.buyerMessage.normalize("NFKC").trim(),!g.buyerMessage)delete g.buyerMessage;else if(g.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${b} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:b})}if(g.currency!=null&&(g.currency=g.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(g.currency)))throw new u("invalid_operation",`Ticket tier ${b} must use a three-letter ISO currency`,{categoryKey:a,tierId:b});if(g.applicability!=null){let m=g.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),x=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(I=>!I||I.length>160)||new Set(m).size!==m.length)||x&&(!x.length||x.some(I=>!Pe.some(h=>h.key===I))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...m?{seatLabels:m}:{},...x?{accessibility:[...x]}:{}},!g.applicability.seatLabels&&!g.applicability.accessibility&&delete g.applicability}if(g.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(g.evidence.provenance)||typeof g.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(g.evidence.sourceDescription=g.evidence.sourceDescription.normalize("NFKC").trim(),!g.evidence.sourceDescription||g.evidence.sourceDescription.length>240||g.evidence.capturedAt!==void 0&&(g.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(g.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}l.add(b),d.add(p)}}}return o}function ao(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let c=o.find(g=>g.key===r.categoryKey);if(!c)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let s=structuredClone(r.patch),{tiers:l,...d}=s;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(c,d),c.notForSale===!1&&delete c.notForSale,Object.prototype.hasOwnProperty.call(s,"tiers")&&(l==null?delete c.tiers:c.tiers=l?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete c.referenceDirectSeatImport}let i=ge(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function Yi(e,t){let n=structuredClone(e.categories),o=n.find(r=>r.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let i=ge(n),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,category:e.categories.find(r=>r.key===t.categoryKey),categories:e.categories}}function Qi(e,t){let n=t.categoryKeys.map(s=>s.trim()),o=e.categories.map(s=>s.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(s=>!n.includes(s)),r=n.filter(s=>!i.has(s));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((s,l)=>s===o[l]))return{changed:!1,categoryKeys:o,categories:e.categories};let c=new Map(e.categories.map(s=>[s.key,s]));return e.categories=ge(n.map((s,l)=>{let d=structuredClone(c.get(s));return s!==o[l]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var $t=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function io(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[1];return n.length===3&&(n=n.split("").map(o=>o+o).join("")),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Wi(e,t){let n=io(e),o=io(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var Zi=3600;function so(e,t,n=$t){return n.find(i=>e.every(a=>Wi(i,a)>=Zi))??n[t%n.length]}function ea(e,t){let n=t?.palette??$t;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,c)=>({categoryKey:r.key,patch:{color:n[c%n.length]}}));return ao(e,{updates:i}),{changed:e.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:e.categories}}function ta(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(e.categories),a=i.find(s=>s.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=ge(i),c=JSON.stringify(r)!==JSON.stringify(e.categories);return c&&(e.categories=r),{changed:c,category:e.categories.find(s=>s.key===t.categoryKey),categories:e.categories}}function co(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let s=t.idFactory("cat").trim();if(s&&!n.has(s)){o=s;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=ge([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var na=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],oa={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function ra(e,t){let n=oa[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var ia=26;function aa(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,c,s]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],l=n-o/2,d=g=>Math.round((g+l)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(c)}${d(s)}`}function sa(e,t,n){let o=r=>e.every(c=>{let s=Dt(r,c);return s==null||s>=ia}),i=r=>{let c=rt(r,"#12151d"),s=rt(r,"#ffffff");return(c??0)>=3||(s??0)>=3},a=t.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let c of[.52,.44,.6]){let s=aa(r,.62,c);if(o(s)&&i(s))return s}return n}function lo(e,t){let n=Ye.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function ca(e){let t=new Map;for(let n of T(e))for(let o of n.objects){let i=Ye.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of Qe(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let c=t.get(r)??new Set;c.add(i.objectType),t.set(r,c)}}return t}function la(e,t){let n=new Set(e.categories.map(i=>i.label.toLowerCase())),o=t;for(let i=2;n.has(o.toLowerCase());i+=1)o=`${t} ${i}`;return o}function uo(e,t,n){let o=ca(e),i=l=>{let d=o.get(l);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(l=>l.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let l=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(l)return{kind:"existing",categoryKey:l.key,label:l.label}}let r=Ye.find(l=>l.objectType===n),c=a?lo(a.label,n):n==="gaArea"?"General Admission":r.creationWord,s=e.categories.find(l=>l.label.toLowerCase()===c.toLowerCase()&&i(l.key));return s?{kind:"existing",categoryKey:s.key,label:s.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:la(e,c)}}function da(e,t,n,o){let i=uo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return ua(e,n,a,i.label,o)}function ua(e,t,n,o,i){let a=i.palette??na,r=e.categories.map(d=>d.color),c=i.suggestColor?.(r.map(d=>d.toLowerCase()))??so(r,e.categories.length),s=sa(r,ra(t,a),c),l=co(e,{label:o,color:s,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=l.categories,l.category.key}function fa(e,t){let n=new Set;for(let o of T(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function ga(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=fa(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let i=ge(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var ba=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],ha=["seat","deck","shell","fascia"];function pa(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),i={...e.theme??{}};for(let a of ba){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=k(r,`Theme ${a}`))}if(n.fontFamily===null)delete i.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");i.fontFamily=a}if(n.seatScale===null)delete i.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<Et||n.seatScale>Tt)throw new u("invalid_operation",`Theme seatScale must be from ${Et} to ${Tt}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=Z(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let c of ha){let s=n.venue3d[c];s===null?delete a[c]:s!==void 0&&(a[c]=k(s,`3D venue ${c}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function ya(e,t){let n=t.url===null?null:Z(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 c=e.floors?.find(g=>g.id===t.floorId);if(!c)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let s=(c.viewFromSeatUrl??void 0)===o,l=o?t.metadata===null?void 0:t.metadata??(s?c.viewFromSeatMeta:void 0):void 0,d=!s||JSON.stringify(c.viewFromSeatMeta??null)!==JSON.stringify(l??null);return c.viewFromSeatUrl=o,c.viewFromSeatMeta=l,{changed:d,scope:"floor",floorId:t.floorId,url:c.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function ma(e,t){let n=He(e,t.floorId),o=xn(n),i=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:i==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function it(e,t){j(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let c={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(c.left,c.center,c.right)||Object.values(c).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let l=C(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:c,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function wa(e,t,n){let o=n*Y;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Sa(e,t,n,o){let i=Math.abs(o-n)*Y,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let g=e.aisleGaps[l];if(!g)return[];let b=g/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((l,d)=>l[0]-d[0]),r=[];for(let l of a){let d=r[r.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):r.push([...l])}let c=[],s=0;for(let l of r)l[0]-s>1e-6&&c.push([s,l[0]]),s=Math.max(s,l[1]);return 1-s>1e-6&&c.push([s,1]),c.filter(([l,d])=>t*i*(d-l)>=e.seatPitch*.75)}function xa(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((s,l)=>s+l,0),a=e.map(s=>o*s/i),r=a.map(s=>2+Math.floor(s)),c=t-r.reduce((s,l)=>s+l,0);return a.map((s,l)=>({index:l,fraction:s-Math.floor(s)})).sort((s,l)=>l.fraction-s.fraction||s.index-l.index).forEach(({index:s})=>{c-- >0&&r[s]++}),r}function at(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,c=Math.sign(e.endAngle-e.startAngle)||1,s=e.startAngle+c*e.taperDegrees*a+e.skewDegrees*a,l=e.endAngle-c*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(l-s)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(l-s)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=Sa(e,r,s,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([p,m])=>r*Math.abs(l-s)*Y*(m-p)),b=e.fit==="fixed-count"?xa(g,e.seatsPerRow):g.map(p=>Math.max(2,Math.round(p/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([p,m],x)=>{let I=s+(l-s)*p,h=s+(l-s)*m;e.facing==="outward"&&([I,h]=[h,I]);let y=b[x];if(y>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let w=Math.abs(h-I)*Y/(y-1),S=2*r*Math.sin(w/2),v={type:"row",id:n(i,x),label:U(e.rowLabelStart+i),origin:wa(e.center,r,I),rotation:-I,curve:h-I,seatCount:y,seatSpacing:S,categoryKey:e.categoryKey,seatLabelStart:f,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:i,segmentIndex:x}};o.push(v),f+=y})}return o}function Gt(e,t){let n=it(e,t),o=C(e,t.floorId),i=at(n,"preview-arc-fan",(s,l)=>`preview-fan-${s}-${l}`),a=i.map(s=>s.seatSpacing),r=Math.max(...a.map(s=>Math.abs(s-n.seatPitch))),c=[];return r>n.seatPitch*.12&&c.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&c.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((s,l)=>s+l.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(s=>s>0).length,warnings:c}}function va(e,t){let n=it(e,t),o=C(e,t.floorId),i=new Set,a=A(e,"fan",t.idFactory,i),r=at(n,a,()=>A(e,"r",t.idFactory,i)),c=Gt(e,t),s=null,l=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(l){if(l.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=te(r);g&&(s=A(e,"sec",t.idFactory,i),d={type:"section",id:s,label:l,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:s,groupId:a,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function fo(e,t){let n=C(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.groupId),c={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},s=it(e,c),l=new Set(at(s,t.groupId,(g,b)=>`${g}:${b}`).map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return c}function Ia(e,t){fo(e,{floorId:t.floorId,groupId:t.groupId});let n=it(e,t),o=C(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),c=new Set,s=at(n,t.groupId,(m,x)=>r.get(`${m}:${x}`)??A(e,"r",t.idFactory,c)),l=Gt(e,t),d=t.sectionLabel?.normalize("NFKC").trim(),g=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let m=te(s);m&&(g={type:"section",id:a?.id??A(e,"sec",t.idFactory,c),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,x)=>b.has(m.id)?x:1/0)),p=o.objects.filter(m=>!b.has(m.id));return p.splice(Number.isFinite(f)?f:p.length,0,...s,...g?[g]:[]),o.objects.splice(0,o.objects.length,...p),{floorId:o.floorId,rowIds:s.map(m=>m.id),sectionId:g?.id??null,groupId:t.groupId,logicalRowCount:l.logicalRowCount,rowSegmentCount:l.rowSegmentCount,totalSeats:l.totalSeats,innerRadius:l.innerRadius,outerRadius:l.outerRadius,minSeatSpacing:l.minSeatSpacing,maxSeatSpacing:l.maxSeatSpacing,maxPitchDeviation:l.maxPitchDeviation,aisleCount:l.aisleCount,warnings:l.warnings}}function Ca(e){let t=new Set(B(e).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;t.has(U(n));)n+=1;let o=U(n);return t.add(o),n+=1,o}}function go(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function Oa(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.seatSpacing??24;if(!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)throw new u("invalid_operation","Row and seat spacing must be positive finite values");if(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=C(e,t.floorId),a=new Set,r=Ca(e),c=Lt(t.rotation??0),s=t.curve??0,l=t.style,d=l?A(e,"rowblock",t.idFactory,a):void 0,g=l?go({style:l,origin:t.origin,rotation:c,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:s}):void 0,b={x:Math.cos(c*J),y:Math.sin(c*J)},f={x:-b.y,y:b.x},p=Array.from({length:t.rowCount},(I,h)=>{let y=l==="intertwined"&&h%2===1?o/2:0,w={type:"row",id:A(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+f.x*h*n+b.x*y,y:t.origin.y+f.y*h*n+b.y*y},rotation:c,curve:s,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&g&&(w.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:c,rowGap:n,seatSpacing:o,curve:s,signature:g}),w});i.objects.push(...p);let m=null,x=t.sectionLabel?.trim();if(x){let I=te(p);if(I){let h={type:"section",id:A(e,"sec",t.idFactory,a),label:x,outline:I};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:p.map(I=>I.id),sectionId:m,createdIds:[...p.map(I=>I.id),...m?[m]:[]]}}function bo(e,t){let n=new Set(B(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(i=>typeof i=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let i=`${t}${o}`;return n.add(i),o+=1,i}}function Ra(e,t){let n=new Set(B(e).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Pa=456;function ho(e){let t=Math.sqrt(Math.max(1,e)*Pa);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function _a(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=C(e,t.floorId),o=new Set,{width:i,height:a}=ho(t.capacity),r=Ra(e,(t.label??"General Admission").trim()||"General Admission"),c={type:"gaArea",id:A(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(c),{floorId:n.floorId,gaAreaId:c.id,label:r,createdIds:[c.id]}}function Aa(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.gapY??150;if(!Number.isFinite(n)||n<80||!Number.isFinite(o)||o<80)throw new u("invalid_operation","Table spacing must be at least 80 chart units");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"T"),c=[];for(let s=0;s<t.tableRows;s+=1)for(let l=0;l<t.tableColumns;l+=1)c.push({type:"table",id:A(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.tableColumns-1)/2)*n,y:t.center.y+(s-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...c),{floorId:i.floorId,tableIds:c.map(s=>s.id),createdIds:c.map(s=>s.id)}}function Ma(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.gapY??82;if(!Number.isFinite(n)||n<62||!Number.isFinite(o)||o<52)throw new u("invalid_operation","Booth spacing must clear the 62\xD752 booth footprint");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"B"),c=[];for(let s=0;s<t.boothRows;s+=1)for(let l=0;l<t.boothColumns;l+=1)c.push({type:"booth",id:A(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.boothColumns-1)/2)*n,y:t.center.y+(s-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...c),{floorId:i.floorId,boothIds:c.map(s=>s.id),createdIds:c.map(s=>s.id)}}function ja(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,c=r.filter(b=>b.segmentedRow);if(c.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:c.map(b=>b.id)});let s=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!s||s.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let l=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=t.idFactory("rowgroup");if(f&&!l.has(f)){d=f;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let g=r[0];return r.forEach((b,f)=>{b.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:f,componentCount:r.length,boundaryBefore:f===0?"start":t.boundaries[f-1],displayLabel:s,...g.displayType?{displayType:g.displayType}:{},...g.labelPresentation?{labelPresentation:structuredClone(g.labelPresentation)}:{},...g.viewFromSeatUrl?{viewFromSeatUrl:g.viewFromSeatUrl}:{},...g.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(g.viewFromSeatMeta)}:{},...g.confidenceEvidence?{confidenceEvidence:structuredClone(g.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function La(e,t){let n=C(e,t.floorId),o=t.groupId?n.objects.find(c=>c.type==="row"&&c.segmentedRow?.groupId===t.groupId):n.objects.find(c=>c.type==="row"&&c.id===t.rowId),i=t.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(c=>c.type==="row"&&c.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((c,s)=>c.segmentedRow.componentIndex-s.segmentedRow.componentIndex).map(c=>c.id);for(let c of a)delete c.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function ka(e,t){let n=C(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.groupId).sort((r,c)=>r.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(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=t.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,c)=>{let s=r.segmentedRow,l=s.viewFromSeatUrl;i!==void 0&&(s.displayLabel=i),t.boundaries&&c>0&&(s.boundaryBefore=t.boundaries[c-1]),t.smoothing!==void 0&&(s.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete s.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(s.viewFromSeatUrl=t.viewFromSeatUrl),!s.viewFromSeatUrl||t.viewFromSeatMeta===null?delete s.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?s.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&s.viewFromSeatUrl!==l&&delete s.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ea(e,t){let n=C(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,G)=>R.rowBlockGeneration.rowIndex-G.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((R,G)=>{let M=R.rowBlockGeneration;return M.kind!=="row-block-v1"||M.rowIndex!==G||M.signature!==i.signature||JSON.stringify(M)!==JSON.stringify({...i,rowIndex:G})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,c=t.rowCount??i.rowCount,s=t.seatsPerRow??i.seatsPerRow,l=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?Lt(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.origin}:{...i.origin};if(!Number.isInteger(c)||c<1||c>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(s)||s<1||s>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![l,d].every(R=>Number.isFinite(R)&&R>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let p=go({style:r,origin:f,rotation:b,rowCount:c,seatsPerRow:s,rowGap:l,seatSpacing:d,curve:g}),m={x:Math.cos(b*J),y:Math.sin(b*J)},x={x:-m.y,y:m.x},I=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),h=new Set,y=new Set(n.objects.filter(R=>R.type==="row").filter(R=>!o.includes(R)).map(R=>R.label)),w=n.objects.filter(R=>R.type==="row").length,S=()=>{for(;y.has(U(w));)w+=1;let R=U(w);return y.add(R),w+=1,R},v=[],P=[];for(let R=0;R<c;R+=1){let G=r==="intertwined"&&R%2===1?d/2:0,M=I.get(R);M||(M={type:"row",id:A(e,"r",t.idFactory,h),label:S(),origin:{...f},rotation:b,curve:g,seatCount:s,seatSpacing:d,categoryKey:o[0].categoryKey},P.push(M.id)),M.origin={x:f.x+x.x*R*l+m.x*G,y:f.y+x.y*R*l+m.y*G},M.rotation=b,M.curve=g,M.seatCount=s,M.seatSpacing=d,delete M.path,delete M.arcFanGeneration,M.overrides&&(M.overrides=M.overrides.filter(bt=>bt.index<s),M.overrides.length||delete M.overrides),M.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:R,rowCount:c,seatsPerRow:s,origin:{...f},rotation:b,rowGap:l,seatSpacing:d,curve:g,signature:p},v.push(M)}let K=o.slice(c).map(R=>R.id),N=Math.min(...o.map(R=>n.objects.indexOf(R))),H=new Set(o.map(R=>R.id)),$=n.objects.filter(R=>!H.has(R.id));return $.splice(N,0,...v),n.objects.splice(0,n.objects.length,...$),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(R=>R.id),createdRowIds:P,removedRowIds:K,changed:a!==JSON.stringify(v)||P.length>0||K.length>0}}function zt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Bt(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Ut(e){return Bt(zt(e),40)}function po(e,t=39){return Bt(zt(e),Math.max(1,t))}function be(e,t=80){return Bt(zt(e),Math.max(1,t))}function yo(e){return be(e).toLocaleLowerCase("en")}function Ht(e){return yo(e)}function mo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Ta(e){let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(X(e,o,i))}return n}function Fa(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(i?.label??`${e.label}-${o+1}`)}return n}function Na(e){return e.type==="row"?[e.label,...Ta(e)]:e.type==="table"?[e.label,...Fa(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...Q(e)]:[]}function wo(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of Na(o)){let a=Ht(i);a&&n.add(a)}return n}function Da(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Ht(e)];for(let i=0;i<t;i+=1)o.push(Ht(X(n,i)));return o.filter(Boolean)}function So(e,t,n){let o=Da(t,n);if(!o.length||o.some(i=>e.has(i)||Ze(i)))return!1;for(let i of o)e.add(i);return!0}var Ka=1e-6,$a=160,Ga=.001,za=1e-5;function he(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>$a)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function xo(e){return typeof e=="string"&&po(e)||void 0}function vo(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(Vt(e.origin)&&Vt(t.start)&&Vt(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},i=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Ga+Math.max(1,i)*za;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||i<=Ka)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let c=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,s=Math.abs(((e.rotation-c)%360+540)%360-180),l=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return s<=l}function Vt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var Ba=300;function Ua(e){let t=new Set(B(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(U(n));)n+=1;let i=U(n);return n+=1,t.add(i),i};return i=>{let a=Ut(i),r=0;return()=>{for(;a&&r<4096;r+=1){let c=`${a}-${U(r)}`;if(!t.has(c))return t.add(c),r+=1,c}return o()}}}function Ha(e){let t=wo(B(e));return(n,o)=>{let i=be(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,c=r?`${be(i,80-r.length)}${r}`:i;if(c&&So(t,c,o))return c}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function Va(e){return{ordinaryFor:Ua(e),direct:Ha(e)}}function Io(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function qa(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[c,s]of r.rows.entries()){let l=he(`${r.sourceGroupId}:${c}`),d=l&&he(s.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:s)}let i=new Map;for(let r of e){let c=he(r.referenceScan?.directSourceRowId);if(!c){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let s=i.get(c)??[];s.push(r),i.set(c,s)}let a=new Map;for(let[r,c]of i){let s=c.filter(b=>b.overrides?.length);if(!s.length)continue;let l=o.get(r),d=s[0],g=d.overrides;if(c.length!==1||s.length!==1||!g||!l||!vo(d,l))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:c.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function Co(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!(o.type==="row"&&o.referenceScan?.assetId===t&&(!n||o.referenceScan.sectionId===n)))}function Ja(e,t,n,o,i,a,r){let c=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(c){let d=Co(t,n,r).filter(g=>F(L(g),c.outline,c.holes));if(d.length)return{skip:{sectionId:c.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let s=[],l=0;for(let[d,g]of e.rows.entries()){let b=Math.min(Ba,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,p=g.end.y-g.start.y,m=Math.hypot(f,p),x=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let I=m>0?Math.atan2(p,f)*180/Math.PI:0,h=e.sourceGroupId?he(`${e.sourceGroupId}:${d}`):void 0,y=h&&he(g.directSourceRowId)===h?h:void 0,w=y?xo(g.directReviewedSuffix):void 0,S=e.sourceGroupId&&g.rowLabel?be(g.rowLabel):"",v=e.sourceGroupId&&g.rowDisplayLabel?be(g.rowDisplayLabel):"",P=!!e.sourceGroupId&&g.rowDisplayLabel==="";s.push({label:S?a(S,b):i(),displayLabel:v||(P?"":String(d+1)),origin:{x:g.start.x,y:g.start.y},rotation:I,seatCount:b,seatSpacing:x,...y?{directSourceRowId:y}:{},...w?{directReviewedSuffix:w}:{}}),l+=b}return{skip:null,rows:s,seats:l}}function Xa(e,t,n){j(e,n.categoryKey);let o=C(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let y=n.categoryKeyForSection?.(h)??n.categoryKey;j(e,y),r.set(h,y)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let c=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&c){let h=Co(o.objects,i,a.id).filter(y=>F(L(y),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:c.name,reason:"section_not_empty",objectIds:h.map(y=>y.id)}]}}let s=o.objects.filter(h=>Io(h,i,a?.id)),l=qa(s,t,a?.id),d=[],g=o.objects.filter(h=>Io(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],p=[],m=new Set,x=0,I=Va(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let y=Ja(h,o.objects,i,t.seatPitch,I.ordinaryFor(h.name),I.direct,a?.id);if(y.skip){f.push(y.skip);continue}let w=y.rows.map(S=>({type:"row",id:A(e,"r",n.idFactory,m),referenceScan:{assetId:i,...h.sectionId?{sectionId:h.sectionId}:{},...S.directSourceRowId?{directSourceRowId:S.directSourceRowId}:{},...S.directReviewedSuffix?{directReviewedSuffix:S.directReviewedSuffix}:{}},label:S.label,...S.displayLabel!==void 0?{displayLabel:S.displayLabel}:{},origin:S.origin,rotation:S.rotation,curve:0,seatCount:S.seatCount,seatSpacing:S.seatSpacing,categoryKey:r.get(h)??n.categoryKey,...S.directSourceRowId&&l.has(S.directSourceRowId)?{overrides:structuredClone(l.get(S.directSourceRowId))}:{}}));o.objects.push(...w);for(let S of w)p.push(S.id);b.push({sectionId:h.sectionId,name:h.name,seats:y.seats,rows:w.length}),x+=y.seats}return{floorId:o.floorId,assetId:i,createdRowIds:p,removedRowIds:d,totalSeats:x,perSection:b,skipped:f}}function Oo(e,t){let n=C(e,t.floorId),o=[...new Set(t.objectIds)];if(!o.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let i=o.map(f=>n.objects.find(p=>(p.type==="table"||p.type==="booth")&&p.id===f)),a=o.filter((f,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:a});let r=i[0].type;if(i.some(f=>f.type!==r))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[f,p,m]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(p)||p<1||p>m)throw new u("invalid_operation",`${f} must be a whole number from 1 to ${m}`);for(let[f,p]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(p)||p<30||p>2e3)throw new u("invalid_operation",`${f} 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 s=o.length*(c-1);if(s>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let l=i.reduce((f,p)=>f+(p.type==="table"?p.seatCount:1),0),g=(e.floors?.length?e.floors.flatMap(f=>f.objects):e.objects).reduce((f,p)=>f+(p.type==="row"||p.type==="table"?p.seatCount:p.type==="gaArea"?Math.max(0,Math.floor(p.capacity)):p.type==="booth"?1:0),0),b=l*(c-1);if(g+b>fe)throw new u("invalid_operation",`Grid inventory would exceed the ${fe} unit event limit`);return{target:n,sources:i,preview:{floorId:n.floorId,kind:r,sourceIds:o,sourceCount:o.length,cells:c,createdCount:s,addedInventory:b,resultingInventory:g+b,provenanceRemovedCount:i.filter(f=>!!f.referenceInventorySource).length*(c-1)}}}function Ya(e,t){return Oo(e,t).preview}function Qa(e,t){let{target:n,sources:o,preview:i}=Oo(e,t),a=new Set,r=new Set((e.floors?.length?e.floors.flatMap(d=>d.objects):e.objects).flatMap(d=>"label"in d&&d.label?[d.label]:[])),c=[],s=(d,g)=>{let b=Math.max(2,g),f=m=>{let x=`-${m}`;return`${d.slice(0,Math.max(1,80-x.length))}${x}`},p=f(b);for(;r.has(p);)p=f(++b);return r.add(p),p},l=1;for(let d=0;d<t.rows;d++)for(let g=0;g<t.columns;g++)if(!(d===0&&g===0)){l+=1;for(let b of o){let f=structuredClone(b);f.id=A(e,f.type,t.idFactory,a),f.label=s(b.label,l),f.center={x:b.center.x+g*t.stepX,y:b.center.y+d*t.stepY},delete f.referenceInventorySource,c.push(f)}}return n.objects.push(...c),{...i,createdIds:c.map(d=>d.id)}}function Wa(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=k(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var Za=new Set(Pe.map(e=>e.key));function ke(e){return`${e.rowId}:${e.index}`}function es(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 ts(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,Le(e.glyph)||delete e.glyph;let n=Ie(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),i={};typeof e.commercial.restrictedView=="boolean"&&(i.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(i.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(i.premium=e.commercial.premium),o&&(i.note=o),Object.keys(i).length?e.commercial=i:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&Ue(t,e)}function ns(e){return Object.keys(e).every(t=>t==="index")}function Ro(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(e,t),i=[],a=new Set,r=new Map;for(let c of n){let s=ke(c);if(a.has(s))continue;a.add(s);let l=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===c.rowId);if(!l)throw new u("object_not_found",`Unknown row or table for seat: ${s}`,{seatId:s,objectId:c.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:s,tableId:l.id});if(!Number.isInteger(c.index)||c.index<0||c.index>=l.seatCount)throw new u("invalid_operation",l.type==="row"?`Seat index is outside row bounds: ${s}`:`Chair index is outside table bounds: ${s}`,{seatId:s,objectId:c.rowId,index:c.index,seatCount:l.seatCount});i.push({rowId:c.rowId,index:c.index}),r.set(l.id,l)}return{floorId:o.floorId,refs:i,owners:r}}function qt(e,t){let n=Ro(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.patch.label!=null)throw new u("invalid_operation","A literal label can only be assigned to one seat; use labelPrefix for a bulk sequence");if(n.refs.length>1&&t.patch.displayLabel!=null)throw new u("invalid_operation","A literal display label can only be assigned to one seat; use displayLabelPrefix for a bulk sequence");if(t.patch.categoryKey&&j(e,t.patch.categoryKey),t.patch.glyph!=null&&!Le(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(r=>!Za.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),c=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,s=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(c&&s)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:ke(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=Z(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&ue(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let c=n.owners.get(a.rowId),s=JSON.stringify(c.overrides??[]),l=c.overrides??(c.overrides=[]),d=l.find(b=>b.index===a.index);d||(d={index:a.index},l.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(p=>p!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let p=Wa(d.labelStyle,f);p?d.labelStyle=p:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),ts(d,c),ns(d)&&(c.overrides=l.filter(b=>b!==d)),c.overrides?.length||delete c.overrides,JSON.stringify(c.overrides??[])!==s&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map(ke)}}function os(e,t){let n=Ro(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(s=>s.rowId===i).map(s=>s.index)),c=a.overrides.filter(s=>!r.has(s.index));c.length!==a.overrides.length&&(o=!0),a.overrides=c,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map(ke)}}function rs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(y=>y.type==="row"&&y.id===h)),a=o.filter((h,y)=>!i[y]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&j(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,y=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!y.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${y.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:c,labelRotation:s,labelStyleShape:l,displayLabel:d,displayType:g,...b}=t.patch,f=d===void 0?{}:{displayLabel:d},p=de(f,"Row"),m=g===void 0?void 0:Rt(g,"Row");if(r!==void 0&&ue(r,"Row"),c!==void 0&&!["start","end","both","none"].includes(c))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(s!=null&&(!Number.isFinite(s)||s<-180||s>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(l!==void 0&&l!=="plain"&&l!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&qe(b.labelPresentation,"Row");let x=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),I=!1;for(let h of i){let y=JSON.stringify(h),w=x(h),S=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?L(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(v=>v.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),S){let v=L(h);h.origin={x:h.origin.x+S.x-v.x,y:h.origin.y+S.y-v.y}}if(JSON.stringify(h)!==y&&(I=!0),x(h)!==w&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=Je(h.labelPresentation,r);P?h.labelPresentation=P:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(c!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};P.positionPreset=c,P.visible=c!=="none",delete P.position,h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(s!==void 0||l!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};s===null?delete P.rotation:s!==void 0&&(P.rotation=s),l!==void 0&&(P.style=l),h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(m!==void 0){let v=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==v&&(I=!0)}if(d!==void 0){let v=h.displayLabel;p?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==v&&(I=!0)}}return{floorId:n.floorId,changed:I,rowIds:o}}var is=3;function st(e){return(e%360+360)%360}function as(e){let t=e.rotation*J;return{x:Math.cos(t),y:Math.sin(t)}}function ss(e,t){let n=Math.abs(st(e-t));return n>180&&(n=360-n),n}function pe(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Po(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*J;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function cs(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=i=>({x:i.x+t,y:i.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function _o(e,t){let n=Po(e),o={x:-n.y,y:n.x},i=L(e[0]),a=e.map(s=>({row:s,coord:pe(L(s),i,o)})).sort((s,l)=>s.coord-l.coord),r=a[0].coord,c=!1;return a.forEach((s,l)=>{let d=r+l*t-s.coord;Math.abs(d)>1e-6&&(cs(s.row,o.x*d,o.y*d),delete s.row.arcFanGeneration,delete s.row.rowBlockGeneration,c=!0)}),c}function ls(e,t){let n={x:-t.y,y:t.x},o=L(e[0]),i=e.map(r=>pe(L(r),o,n)).sort((r,c)=>r-c);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function ds(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Ce(e),n=t[0],o=t[t.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,r/(e.seatCount-1))),r>1e-6&&(e.rotation=st(Math.atan2(a,i)/J)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function us(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${t}${o}`.slice(0,80);if(!n.has(i))return i}return`${t}-${Date.now().toString(36)}`}function fs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(v=>v.type==="row"&&v.id===S)),a=o.filter((S,v)=>!i[v]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,c=r.filter(S=>S.path||S.curve!==0);if(c.length)throw new u("invalid_operation","Only straight rows can be merged \u2014 straighten the rows first, then merge.",{rowIds:c.map(S=>S.id)});let s=r[0],l=r.find(S=>ss(S.rotation,s.rotation)>is);if(l)throw new u("invalid_operation","Rows must be parallel to merge \u2014 they point in different directions.",{rowIds:[s.id,l.id]});let d=as(s),g={x:-d.y,y:d.x},b=Math.max(8,s.seatSpacing*.6),f=r.find(S=>Math.abs(pe(S.origin,s.origin,g))>b);if(f){let S=Math.round(Math.abs(pe(f.origin,s.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge \u2014 a selected row is offset ${S} units from the first.`,{rowIds:[s.id,f.id]})}let p=r.slice().sort((S,v)=>pe(S.origin,s.origin,d)-pe(v.origin,s.origin,d)),m=p.reduce((S,v)=>S+v.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let x=p[0],I=[],h=0;for(let S of p){if(S.overrides)for(let v of S.overrides)I.push({...structuredClone(v),index:v.index+h});h+=S.seatCount}x.seatCount=m,x.curve=0,delete x.path,I.length?x.overrides=I:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let y=p.slice(1).map(S=>S.id),w=new Set(y);for(let S=n.objects.length-1;S>=0;S--)w.has(n.objects[S].id)&&n.objects.splice(S,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:y,seatCount:m}}function gs(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="row"&&f.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row \u2014 straighten it first, then split.",{rowIds:[o.id]});let i=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>i-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${i-1} (the seat where the second row begins)`);let r=Ce(o),c=i>1?o.curve/(i-1):0,s=i-a,l={type:"row",id:A(e,"r",t.idFactory,new Set),label:us(n.objects,o.label),origin:{...r[a]},rotation:st(o.rotation-c*a),curve:c*(s-1),seatCount:s,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(l.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(l.seatLabelStart=o.seatLabelStart),o.commercial&&(l.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(l.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(l.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(l.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,l.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=c*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(l.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:s,newLabel:l.label}}function bs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(c=>n.objects.find(s=>s.type==="row"&&s.id===c)),a=o.filter((c,s)=>!i[s]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=_o(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function hs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,c=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),s=c();for(let b of r)ds(b);let l=Po(r),d=st(Math.atan2(l.y,l.x)/J);for(let b of r)b.rotation=d;let g=ls(r,l);return _o(r,g),{floorId:n.floorId,changed:c()!==s,rowIds:o,gap:g}}var lt=tr(require("polygon-clipping"),1),Ao=100,Mo=512,Jt=8192,Do=64,jo=1e7,E=1e-7;function Ko(e,t){return Math.abs(e.x-t.x)<=E&&Math.abs(e.y-t.y)<=E}function $o(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ko(t[0],t[t.length-1]);)t.pop();return t}function Ee(e,t,n){let o=q(t,n,e);return Math.abs(o)>E?!1:e.x>=Math.min(t.x,n.x)-E&&e.x<=Math.max(t.x,n.x)+E&&e.y>=Math.min(t.y,n.y)-E&&e.y<=Math.max(t.y,n.y)+E}function Go(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),c=q(n,o,t);return(i>E&&a<-E||i<-E&&a>E)&&(r>E&&c<-E||r<-E&&c>E)?!0:Math.abs(i)<=E&&Ee(n,e,t)||Math.abs(a)<=E&&Ee(o,e,t)||Math.abs(r)<=E&&Ee(e,n,o)||Math.abs(c)<=E&&Ee(t,n,o)}function ps(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&Go(e[t],e[n],e[o],e[i]))return!0}}return!1}function Lo(e,t){return e.some((n,o)=>t.some((i,a)=>Go(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function Xt(e,t){return!t.some((n,o)=>Ee(e,n,t[(o+1)%t.length]))&&F(e,t,void 0)}function dt(e,t,n){let o=$o(e);if(o.length<3||o.length>Mo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>jo||Math.abs(i.y)>jo||Ko(i,o[(a+1)%o.length]))||Math.abs(Se(o))<=E||ps(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Mo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function ys(e){let t=dt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Do)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>dt(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((c,s)=>{let l=a[(s+1)%a.length];return[c,{x:(c.x+l.x)/2,y:(c.y+l.y)/2}]}).every(c=>Xt(c,t))||Lo(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let c=i+1;c<o.length;c+=1)if(Lo(a,o[c])||Xt(a[0],o[c])||Xt(o[c][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function ct(e){return e.map(t=>[t.x,t.y])}function ko(e){return $o(e.map(([t,n])=>({x:t,y:n})))}function Eo(e){return Math.abs(e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n[0]*i[1]-i[0]*n[1]},0))/2}function ms(e){return e.reduce((t,n)=>t+(Eo(n[0]??[])-n.slice(1).reduce((o,i)=>o+Eo(i),0)),0)}function Yt(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Yt).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Yt(t[n])}`).join(",")}}`}function To(e,t,n){let o=e[t];if(o===void 0)return null;let i=o.normalize("NFKC").trim();if(!i||i!==o||i.length>n)throw new u("invalid_operation",`GA area ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return i}function Fo(e){return Yt({categoryKey:e.categoryKey,displayLabel:To(e,"displayLabel",80),displayType:To(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function No(e,t){let n=Math.min(...e.points.map(i=>i.y)),o=Math.min(...e.points.map(i=>i.x));return[n,o,t]}function ws(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function zo(e,t){let n=C(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(o.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(o.length>Ao)throw new u("invalid_operation",`Join Areas supports at most ${Ao} areas at once`);let i=o.map(O=>n.objects.find(_=>_.type==="gaArea"&&_.id===O)),a=o.filter((O,_)=>!i[_]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=i;j(e,r[0].categoryKey);let c=Fo(r[0]),s=r.find(O=>Fo(O)!==c);if(s)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[r[0].id,s.id]});let l=Ae(e).objectToSection,d=l.get(r[0].id)??"__ungrouped__",g=r.find(O=>(l.get(O.id)??"__ungrouped__")!==d);if(g)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[r[0].id,g.id],sectionIds:[d,l.get(g.id)??"__ungrouped__"]});let b=r.reduce((O,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>oe)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return O+_.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 f=B(e).reduce((O,_)=>O+ne(_),0);if(f>fe)throw new u("invalid_operation",`Chart inventory exceeds the ${fe}-unit publication limit`,{inventory:f});let p=r.map(ys),m=p.reduce((O,_)=>O+_.outer.length+_.holes.reduce((V,W)=>V+W.length,0),0);if(m>Jt)throw new u("invalid_operation",`Join Areas supports at most ${Jt} source vertices`,{vertexCount:m});let x;try{let O=p.map(W=>[ct(W.outer)]);if(x=lt.default.union(O[0],...O.slice(1)),x.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:x.length});let _=p.flatMap(W=>W.holes.map(ht=>[ct(ht)]));_.length&&(x=lt.default.difference(x,..._));let V=p.findIndex(W=>{let ht=[ct(W.outer),...W.holes.map(ct)];return ms(lt.default.intersection(ht,x))<=E});if(V>=0)throw new u("invalid_operation",`GA area ${r[V].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:r[V].id})}catch(O){throw O instanceof u?O:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:O instanceof Error?O.message:"polygon_union_failed"})}if(x.length!==1||!x[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:x.length});let I=ko(x[0][0]),h=x[0].slice(1).map(ko),y=I.length+h.reduce((O,_)=>O+_.length,0);if(h.length>Do||y>Jt)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:h.length,vertexCount:y});dt(I,"outline",r[0].id),h.forEach(O=>dt(O,"cutout",r[0].id));let w=new Map(n.objects.map((O,_)=>[O.id,_])),S=r.slice().sort((O,_)=>ws(No(O,w.get(O.id)??Number.MAX_SAFE_INTEGER),No(_,w.get(_.id)??Number.MAX_SAFE_INTEGER))),v=S[0],P=structuredClone(e),K=C(P,n.floorId),N=K.objects.find(O=>O.type==="gaArea"&&O.id===v.id);N.points=structuredClone(I),h.length?N.holes=structuredClone(h):delete N.holes;let H=new Set(S.slice(1).map(O=>O.id));for(let O=K.objects.length-1;O>=0;O-=1)H.has(K.objects[O].id)&&K.objects.splice(O,1);let $=Ae(P).objectToSection.get(v.id)??"__ungrouped__";if($!==d)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:v.id,beforeSectionId:d,afterSectionId:$});let R=[],G=new Set;for(let O of S){if(!Mt(O))throw new u("invalid_operation",`GA area ${O.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:O.id});let _=Q(O);if(_.length!==O.capacity||_.some(V=>G.has(V)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:O.id});_.forEach(V=>G.add(V)),R.push(...We(O))}if(R.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let M=new Set(r.map(O=>O.id));for(let O of B(e).filter(_=>_.type==="gaArea"&&!M.has(_.id))){let _=Q(O).find(V=>G.has(V));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:O.id})}let bt=S.slice(1).map(O=>O.id);return{floorId:n.floorId,areaId:v.id,survivorLabel:v.label,removedAreaIds:bt,sourceAreaCount:S.length,capacity:b,inventorySegmentCount:R.length,outerVertexCount:I.length,holeCount:h.length,sectionId:d,points:I,...h.length?{holes:h}:{},segments:R}}function Ss(e,t){let{segments:n,...o}=zo(e,t);return o}function xs(e,t){let n=zo(e,t),o=C(e,n.floorId),i=o.objects.find(s=>s.type==="gaArea"&&s.id===n.areaId);i.points=structuredClone(n.points),n.holes?.length?i.holes=structuredClone(n.holes):delete i.holes,i.capacity=n.capacity,i.inventorySegments=structuredClone(n.segments);let a=new Set(n.removedAreaIds);for(let s=o.objects.length-1;s>=0;s-=1)a.has(o.objects[s].id)&&o.objects.splice(s,1);let{segments:r,...c}=n;return{...c,changed:!0}}function vs(e,t){let n=C(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.labelStyle!==void 0){let l=i.filter(d=>d.role!=="stage");if(l.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:l.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<le||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${le} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=k(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");for(let d of["bold","italic","underline"]){let g=r.labelStyle[d];if(g!=null&&typeof g!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=k(r.fill,"Shape fill")),r.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(r.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(r.stroke!==void 0&&r.stroke!==null){if(!Number.isFinite(r.stroke.width)||r.stroke.width<.5||r.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");r.stroke={color:k(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let l=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!l.length||l.length>20||l.some(d=>!d||d.length>100)||new Set(l).size!==l.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=l}if(r.lineCap!==void 0&&r.lineCap!==null&&!to.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!no.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!oo.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let l=i.filter(d=>!Kt(r.kind??d.kind));if(l.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:l.map(d=>d.id)})}let s=!1;for(let l of i){let d=JSON.stringify(l);if(r.label===null?delete l.label:r.label!==void 0&&(l.label=r.label),r.labelStyle!==void 0){let g={...l.labelStyle};r.labelStyle.size===null?delete g.size:r.labelStyle.size!==void 0&&(g.size=r.labelStyle.size),r.labelStyle.color===null?delete g.color:r.labelStyle.color!==void 0&&(g.color=r.labelStyle.color),r.labelStyle.fontFamily===null?delete g.fontFamily:r.labelStyle.fontFamily!==void 0&&(g.fontFamily=r.labelStyle.fontFamily),r.labelStyle.bold===null?delete g.bold:r.labelStyle.bold!==void 0&&(g.bold=r.labelStyle.bold),r.labelStyle.italic===null||r.labelStyle.italic===!1?delete g.italic:r.labelStyle.italic===!0&&(g.italic=!0),r.labelStyle.underline===null||r.labelStyle.underline===!1?delete g.underline:r.labelStyle.underline===!0&&(g.underline=!0),Object.keys(g).length?l.labelStyle=g:delete l.labelStyle}if(r.fill===null?delete l.fill:r.fill!==void 0&&(l.fill=r.fill),r.kind!==void 0&&(l.kind=r.kind,Kt(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),r.stroke===null?delete l.stroke:r.stroke!==void 0&&(l.stroke={...r.stroke}),r.opacity===null?delete l.opacity:r.opacity!==void 0&&(l.opacity=r.opacity),r.heightM===null?delete l.heightM:r.heightM!==void 0&&(l.heightM=r.heightM),r.eventConfigurationIds===null?delete l.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete l.lineCap:r.lineCap!==void 0&&(l.lineCap=r.lineCap),r.lineJoin===null?delete l.lineJoin:r.lineJoin!==void 0&&(l.lineJoin=r.lineJoin),r.startEnding===null?delete l.startEnding:r.startEnding!==void 0&&(l.startEnding=r.startEnding),r.endEnding===null?delete l.endEnding:r.endEnding!==void 0&&(l.endEnding=r.endEnding),r.cornerRadius===null)delete l.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(l.width??1/0,l.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(l)!==d&&(Ge(l),s=!0)}return{floorId:n.floorId,changed:s,shapeIds:o}}function Uo(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),c=Math.max(...o),s=Math.max(1,a-i),l=Math.max(1,c-r);return{cx:i+s/2,cy:r+l/2,width:s,height:l}}function Is(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let c=n.objects.find(l=>l.type==="shape"&&l.id===r.shapeId);if(!c)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let s=c.role==="stage"?Uo(c):(c.kind==="rect"||c.kind==="ellipse")&&c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null?{cx:c.x+c.width/2,cy:c.y+c.height/2,width:c.width,height:c.height}:(()=>{let l=c.points??[];if(l.length<3||l.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${c.id} has no resizable geometry`,{shapeId:c.id});let d=l.map(x=>x.x),g=l.map(x=>x.y),b=Math.min(...d),f=Math.max(...d),p=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(p+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-p)}})();return{shape:c,update:r,box:s}}),a=!1;for(let{shape:r,update:c,box:s}of i)if(!(Math.abs(s.width-c.width)<1e-9&&Math.abs(s.height-c.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=s.cx-c.width/2,r.y=s.cy-c.height/2,r.width=c.width,r.height=c.height;else{let l=c.width/s.width,d=c.height/s.height;r.points=(r.points??[]).map(g=>({x:s.cx+(g.x-s.cx)*l,y:s.cy+(g.y-s.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=s.cx-c.width/2,r.y=s.cy-c.height/2,r.width=c.width,r.height=c.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:c})=>({id:r.id,width:c.width,height:c.height}))}}function Cs(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(c=>c.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(bn.map(c=>c.key)),a=t.updates.map(c=>{if(!i.has(c.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${c.stageKind}`,{stageKind:c.stageKind});let s=n.objects.find(l=>l.type==="shape"&&l.id===c.stageId);if(!s)throw new u("object_not_found",`Unknown stage id: ${c.stageId}. Call get_chart to list current stage ids.`,{stageId:c.stageId});if(s.role!=="stage")throw new u("invalid_operation",`Shape ${c.stageId} is not tagged as a stage`,{stageId:c.stageId});return{shape:s,stageKind:c.stageKind,box:s.stageKind===c.stageKind?null:Uo(s)}}),r=!1;for(let c of a)c.box&&(c.shape.points=hn({kind:c.stageKind,...c.box}),c.shape.kind="polygon",c.shape.stageKind=c.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(c=>({id:c.shape.id,stageKind:c.stageKind}))}}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 i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function ut(e){return Array.isArray(e)?e.map(ut):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,ut(n)]))}function Rs(e,t){return JSON.stringify(ut(e))===JSON.stringify(ut(t))}function Qt(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Ps(e){return e?e.status==="retracted"?"retract":Qt(e)?"approve":"set":"clear"}function Vo(e,t){let n=Ho(e),o=Ho(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let c=n.get(r),s=o.get(r);if(c&&s&&Rs(c.evidence,s.evidence))continue;let l=s?.target??c?.target;l&&a.push({...l,operation:Ps(s?.evidence),...c?{before:c.evidence}:{},...s?{after:s.evidence}:{}})}return a}function _s(e,t){return Vo(e,t).some(n=>Qt(n.before)||Qt(n.after))}var As=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Ms=new Set(["generated","geometry-verified","configuration-verified"]),js=new Set(["none","comparable-build-reference","actual-build-checked"]),Ls=new Set(["clear","partial","obstructed"]);function Wt(e){return e.toISOString().slice(0,10)}function Zt(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function me(e,t,n){if(!Zt(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function ye(e,t,n){if(e!==void 0)return me(e,t,n)}function ft(e,t,n){let o=n?[C(e,n)]:T(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function qo(e,t){let n=T(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Te(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return qo(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(i=>i.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=ft(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function gt(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=qo(e,t.floorId);return n?i.confidenceEvidence=n:delete i.confidenceEvidence,{floorId:i.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let i=ft(e,t.objectId,t.floorId);return qt(e,{floorId:i.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:i.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function ks(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!Zt(e.label,80)||!Zt(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!Ls.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>me(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function Jo(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(!As.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Ms.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!js.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=ye(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let i=e.limitations?.map(d=>me(d,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=ye(e.assessedAt,40,"assessedAt")??Wt(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let c=ye(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Wt(new Date(r+365*24*60*60*1e3))),s=c?Date.parse(c):Number.NaN;if(c&&(!Number.isFinite(s)||s<r||s>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=ye(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");return{schema:"seatlayer.seat-confidence/1",evidenceId:me(e.evidenceId,120,"evidenceId"),modelVersion:me(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...c?{validUntil:c}:{},...l?{approvedByRole:l}:{},...ye(e.sourceLabel,120,"sourceLabel")?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:ks(e.modeledTarget)}:{}}}function we(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function Es(e,t){let n=Jo(t.evidence,t.now),o=JSON.stringify(Te(e,t)??null),i=gt(e,t,n),a=JSON.stringify(Te(e,t)??null);return we(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function Ts(e,t){let n=Te(e,t);if(!n)return we(t,{changed:!1});let o=gt(e,t,void 0);return we(t,{changed:!0,...o,evidenceId:n.evidenceId})}function Fs(e,t){let n=Te(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=me(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=ye(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!i)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let r={...n,status:"approved",approvedByRole:o,assessedAt:Wt(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let c=t.basisSha256??e.confidenceBasisSha256;c&&(r.basisSha256=c);let s=JSON.stringify(n),l=gt(e,t,r);return we(t,{changed:s!==JSON.stringify(r),...l,evidenceId:r.evidenceId,status:"approved"})}function Ns(e,t){let n=Te(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return we(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=gt(e,t,o);return we(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
|
|
1
|
+
"use strict";var Xo=Object.create;var Ne=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var Wo=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var er=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},tn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qo(t))!Zo.call(e,i)&&i!==n&&Ne(e,i,{get:()=>t[i],enumerable:!(o=Yo(t,i))||o.enumerable});return e};var tr=(e,t,n)=>(n=e!=null?Xo(Wo(e)):{},tn(t||!e||!e.__esModule?Ne(n,"default",{value:e,enumerable:!0}):n,e)),nr=e=>tn(Ne({},"__esModule",{value:!0}),e);var Ks={};er(Ks,{COLORBLIND_SAFE_PALETTE:()=>$t,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>At,DEFAULT_SECTION_CORNER_SMOOTHING:()=>St,MAX_BUYER_IMAGE_URL_LENGTH:()=>Ir,MAX_FLOOR_BASE_HEIGHT_M:()=>Ye,addArcFanRows:()=>Ia,addBookableGridArray:()=>Wa,addBoothArray:()=>ja,addChartCategory:()=>co,addChartFloor:()=>Wr,addChartZone:()=>ni,addGAArea:()=>Aa,addRowBlock:()=>Ra,addTableArray:()=>Ma,applyPolygonHole:()=>Di,applyReferenceScanRows:()=>Ya,applySectionCornerSmoothing:()=>qi,applySectionOutlineShaping:()=>Zn,applySectionRowFit:()=>Fi,approveConfidenceEvidence:()=>Ns,arcFanInputForGroup:()=>fo,assignSectionInventoryCategory:()=>$i,automaticPlacementCenter:()=>wa,clearConfidenceEvidence:()=>Fs,compactChartDoc:()=>$r,compactRowOverrides:()=>An,compactTableOverrides:()=>Mn,confidenceEvidenceChangeRequiresPublish:()=>As,confidenceEvidenceChanges:()=>Vo,confirmReferenceCategoryOutputColor:()=>na,convertGeneratedSectionToPolygon:()=>zi,countCoveredInventory:()=>tt,detectSeatLabelRun:()=>Pn,dropRedundantSeatOverrideFields:()=>He,familyCategoryLabel:()=>lo,gaAreaFootprint:()=>ho,groupRowsAsSegmented:()=>La,insertSeatingBlock:()=>ji,isSafeBuyerImageUrl:()=>yn,joinGAAreas:()=>vs,mergeRows:()=>gs,mirrorFirstFloor:()=>_e,normalizeBuyerImageUrl:()=>Z,normalizeDraftEvidence:()=>Jo,parseSeatRefId:()=>ts,pickColorblindSafeCategoryColor:()=>so,planCreationCategory:()=>uo,previewArcFanRows:()=>Bt,previewBookableGridArray:()=>Qa,previewGeneratedSectionPolygonConversion:()=>Qn,previewJoinGAAreas:()=>xs,previewPolygonHole:()=>ot,previewRemovePolygonHole:()=>Jn,previewRowCubicPath:()=>Hn,previewSectionRowFit:()=>Vn,reassignColorblindSafeCategoryColors:()=>ta,relabelChartRows:()=>Mi,removeChartCategory:()=>ba,removeChartFloor:()=>ti,removeChartObjects:()=>_i,removeChartZone:()=>ri,removePolygonHole:()=>Ki,renameChartFloor:()=>Zr,renameDirectSeatImportCategory:()=>Qi,reorderChartCategories:()=>Wi,replaceArcFanRows:()=>Ca,replaceRowBlock:()=>Ta,resetSeatOverrides:()=>rs,resizeShapes:()=>Cs,resolveCreationCategory:()=>ua,retractConfidenceEvidence:()=>Ds,roundBuyerCoordinates:()=>zr,seatRefId:()=>Ee,seatSemanticsSignature:()=>Ct,sectionInventorySelectionSummary:()=>Yn,setConfidenceEvidence:()=>Ts,setRowBlockSpacing:()=>hs,splitRow:()=>bs,straightenAndSpaceRows:()=>ps,transformSectionBoundary:()=>Ui,transformSectionBoundaryObject:()=>Wn,ungroupSegmentedRow:()=>ka,updateBooths:()=>Ri,updateCategoryDefinitions:()=>ao,updateChartFloorBaseHeight:()=>ei,updateChartTheme:()=>ya,updateChartZones:()=>oi,updateGAAreas:()=>Pi,updateRowCubicPath:()=>ki,updateRows:()=>is,updateSeatOverrides:()=>Jt,updateSectionExactPath:()=>Hi,updateSectionMetadata:()=>Bi,updateSegmentedRow:()=>Ea,updateShapes:()=>Is,updateStageKinds:()=>Os,updateTables:()=>Oi,updateTextObjects:()=>Ai,updateViewFromSeatFallback:()=>ma});module.exports=nr(Ks);var nn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function or(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/nn(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let c of a.split(/\s+/)){let s=c.length;r&&r+1+s<=o?r+=1+s:(i+=Math.max(1,Math.ceil(s/o)),r=s%o)}}return Math.max(1,i)}function on(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(c=>c.length))*nn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=or(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var Bs=Math.PI/180;function D(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function pt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function rn(e,t){let n=1-t,o=n*n*n,i=3*n*n*t,a=3*n*t*t,r=t*t*t;return{x:o*e.start.x+i*e.control1.x+a*e.control2.x+r*e.end.x,y:o*e.start.y+i*e.control1.y+a*e.control2.y+r*e.end.y}}function De(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[rn(e,.5)];let o=Array.from({length:n+1},(s,l)=>rn(e,l/n)),i=new Float64Array(o.length);for(let s=1;s<o.length;s+=1){let l=o[s].x-o[s-1].x,d=o[s].y-o[s-1].y;i[s]=i[s-1]+Math.hypot(l,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],c=1;for(let s=0;s<t;s+=1){let l=a*s/(t-1);for(;c<i.length-1&&i[c]<l;)c+=1;let d=i[c-1],g=i[c],b=g===d?0:(l-d)/(g-d);r.push({x:o[c-1].x+(o[c].x-o[c-1].x)*b,y:o[c-1].y+(o[c].y-o[c-1].y)*b})}return r}function Se(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 xe(e,t,n){return Math.max(t,Math.min(n,e))}function rr(e){return xe(e,0,1)}function an(e){let t=rr(e);return t*t*(3-2*t)}var ie=Math.PI*2;function ae(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function ir(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ie;for(;o>=ie;)o-=ie}else{for(;o>0;)o-=ie;for(;o<=-ie;)o+=ie}return o}function Ke(e){if(e.version!==1||e.closed!==!0||!ae(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!ae(n.end))return!1;if(n.kind==="line"){if(D(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!ae(n.control1)||!ae(n.control2)||D(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!ae(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(D(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(D(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||D(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return D(t,e.start)<=1e-4}function ar(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function mt(e,t=2){if(!Ke(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),c=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),s=ir(r,c,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(s)*a.radius/n));for(let d=1;d<=l;d+=1){let g=r+s*d/l;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=D(i,a.control1)+D(a.control1,a.control2)+D(a.control2,a.end),c=Math.max(2,Math.ceil(r/n));for(let s=1;s<=c;s+=1)o.push(ar(i,a,s/c))}i=a.end}return D(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function ln(e,t,n){return wt(e,i=>({x:i.x+t,y:i.y+n}))}function wt(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(i=>i.kind==="line"?{...i,end:t(i.end)}:i.kind==="arc"?{...i,center:t(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:t(i.end)}:{...i,control1:t(i.control1),control2:t(i.control2),end:t(i.end)})}}var St=45,yt=150,sr=60;function cr(e){let t=St/100;if(e<=t)return yt;let n=Math.min(1,(e-t)/(1-t));return yt-n*(yt-sr)}var sn=.5523;function cn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function lr(e){let t=[],n=[];for(e.forEach((o,i)=>{ae(o)&&(t.length&&cn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&cn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var dr=.5,ur=4/3;function fr(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,c=o/a,s=n*ur;return{kind:"bezier",control1:{x:e.x+o/3+r*s,y:e.y+i/3+c*s},control2:{x:e.x+o*2/3+r*s,y:e.y+i*2/3+c*s},end:{...t}}}function dn(e,t){let{points:n,sourceIndex:o}=lr(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,c=new Array(i).fill(0);if(r?.length)for(let w=0;w<i;w+=1){let S=r[o[w]];c[w]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let s=c.some(w=>Math.abs(w)>1e-6);if(a<=0&&!s)return null;let l=t.wideAngleThresholdDeg??cr(a),d=[];for(let w=0;w<i;w+=1)d[w]=D(n[w],n[(w+1)%i]);let g=new Array(i).fill(0);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],v=n[w],P=n[(w+1)%i],K={x:S.x-v.x,y:S.y-v.y},N={x:P.x-v.x,y:P.y-v.y},H=Math.hypot(K.x,K.y),G=Math.hypot(N.x,N.y);if(H<=1e-9||G<=1e-9)continue;let R=Math.min(1,Math.max(-1,(K.x*N.x+K.y*N.y)/(H*G))),$=Math.acos(R)*180/Math.PI;if($<l)continue;let M=an(($-l)/(180-l));g[w]=a*M*.5*Math.min(H,G)}for(let w=0;w<i;w+=1){let S=(w+1)%i,v=g[w]+g[S];if(v>d[w]&&v>1e-9){let P=d[w]/v;g[w]*=P,g[S]*=P}}let b=new Array(i),f=new Array(i);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],v=n[w],P=n[(w+1)%i];if(g[w]<=1e-6){b[w]={...v},f[w]={...v};continue}let K=D(v,S)||1,N=D(v,P)||1;b[w]={x:v.x+(S.x-v.x)/K*g[w],y:v.y+(S.y-v.y)/K*g[w]},f[w]={x:v.x+(P.x-v.x)/N*g[w],y:v.y+(P.y-v.y)/N*g[w]}}if(g.every(w=>w<=1e-6)&&!s)return null;let p=[],m={...f[0]},x=m,I=(w,S)=>{if(D(x,w)<=1e-9)return;let v=c[S];Math.abs(v)>1e-6?p.push(fr(x,w,v*dr*d[S])):p.push({kind:"line",end:{...w}}),x=w};for(let w=1;w<=i;w+=1){let S=w%i,v=n[S];I(b[S],(w-1)%i),g[S]>1e-6&&D(b[S],f[S])>1e-9&&(p.push({kind:"bezier",control1:pt(b[S],v,sn),control2:pt(f[S],v,sn),end:{...f[S]}}),x=f[S])}if(!p.length)return null;let h=p[p.length-1];D(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:p.push({kind:"line",end:{...m}}));let y={version:1,closed:!0,start:m,segments:p};return Ke(y)?y:null}var un="ABCDEFGHIJKLMNOPQRSTUVWXYZ",gr="ABCDEFGHJKLMNPQRSTUVWXYZ",br="abcdefghijklmnopqrstuvwxyz";function fn(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function hr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?gr:un;return fn(o,i)}function xt(e,t=!1){let n=t?br:un;return fn(Math.max(0,Math.floor(e)-1),n)}var pr=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function gn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of pr)for(;t>=o;)n+=i,t-=o;return n}function bn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:hr(a,t)}})}function yr(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function se(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",c=e.seatNumbering?.endAt,s=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(s/2),p=a==="updown"?t<f?n+2*t:n-1+2*(s-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${p}`}let l=a==="odd"||a==="even"?2:i,d=c!=null&&Number.isFinite(c)?c-(s-1)*l:n,g=o==="center"?yr(s)[t]:o==="rtl"?s-1-t:t,b;switch(a){case"odd":{let f=d%2===1?d:d+1;b=String(f+g*2);break}case"even":{let f=d%2===0?d:d+1;b=String(f+g*2);break}case"roman":b=gn(d+g*i);break;case"letters-upper":b=xt(d+g*i,!1);break;case"letters-lower":b=xt(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function mr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function X(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${se(e,t)}`}function ve(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return se(e,t);if(!n)return`${e.displayLabel||e.label}-${se(e,t)}`;let i=mr(n),a=n.displayOffset+t;return`${n.displayLabel}-${se(i,a)}`}var hn=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."}];var wr=Math.PI*2;function Sr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function pn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,c=Math.cos(r),s=Math.sin(r),l=i/2,d=a/2,g=[],b=(f,p)=>{g.push({x:f,y:p})};switch(t){case"rect":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rounded":{let f=Math.min(i,a)*.18,p=5,m=(x,I,h)=>{for(let y=0;y<=p;y++){let w=h+y/p*(Math.PI/2);b(x+f*Math.cos(w),I+f*Math.sin(w))}};m(l-f,-d+f,-Math.PI/2),m(l-f,d-f,0),m(-l+f,d-f,Math.PI/2),m(-l+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-l,-d),b(l,-d);let p=24;for(let m=0;m<=p;m++){let x=m/p,I=l-x*i,h=d+f*(1-Math.pow(2*I/i,2));b(I,h)}break}case"thrust":{let f=i*.18,p=a*1.1;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+p),b(-f,d+p),b(-f,d),b(-l,d);break}case"runway":{let f=i*.1,p=a*3;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+p),b(-f,d+p),b(-f,d),b(-l,d);break}case"round":case"oval-cricket":{for(let p=0;p<40;p++){let m=p/40*wr;b(l*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rink-hockey":{for(let f of xr(l,d,l*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of vr(l,d))b(f.x,f.y);break}}return g.map(f=>Sr(f.x,f.y,c,s,n,o))}function xr(e,t,n,o){let i=[],r=(c,s,l)=>{for(let d=0;d<=8;d++){let g=l+d/8*(Math.PI/2);i.push({x:c+n*Math.cos(g),y:s+o*Math.sin(g)})}};return r(e-n,-t+o,-Math.PI/2),r(e-n,t-o,0),r(-e+n,t-o,Math.PI/2),r(-e+n,-t+o,Math.PI),i}function vr(e,t){let n=Math.max(0,e-t),o=[],i=20;for(let a=0;a<=i;a++){let r=-Math.PI/2+a/i*Math.PI;o.push({x:n+t*Math.cos(r),y:t*Math.sin(r)})}for(let a=0;a<=i;a++){let r=Math.PI/2+a/i*Math.PI;o.push({x:-n+t*Math.cos(r),y:t*Math.sin(r)})}return o}var Ir=2e6,Cr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Or=/[\s"'<>`\\]/;function yn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Cr.test(e);if(Or.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Z(e){let t=e.trim();return yn(t)?t:null}function Ie(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var $e=Math.PI/180,Rr=9,ce=16;function It(e,t,n,o){let i=n*$e,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function Ce(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return De(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let l=0;l<t;l++)r.push(It(l*n,0,i,a));return r}let c=o/(t-1)*$e,s=n/(2*Math.sin(Math.abs(c)/2));for(let l=0;l<t;l++){let d=l*c,g=s*Math.sin(d),b=-s+s*Math.cos(d);r.push(It(g,b,i,a))}return r}function Pr(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function _r(e,t){let n=Pr(e);return Ce(e).map((o,i)=>{let a=n.get(i),r=Ie(a),c=X(e,i,a),s={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:c,displayLabel:ve(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(s).some(l=>l!==void 0&&l!==!1&&l!=="")?s:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function B(e){let t=[];for(let n of _r(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 Ar(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(e.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function Mr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let p=o.get(d),m=Ie(p),x=p?.label??`${e.label}-${d+1}`,I=e.displayLabel??e.label;return{index:d,label:x,displayLabel:p?.displayLabel??`${I}-${d+1}`,x:g+(p?.dx??0),y:b+(p?.dy??0),categoryKey:p?.categoryKey??e.categoryKey,skipped:!!p?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:p?.wheelchairSpaceType,commercial:p?.commercial,glyph:p?.glyph,viewUrl:p?.viewFromSeatUrl,viewMeta:p?.viewFromSeatUrl?p.viewFromSeatMeta:void 0,labelStyle:p?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+ce,g=e.rotation*$e,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let x=0;x<n;x++){let I=g+x/n*2*Math.PI;t.push(i(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let f=b*$e,p=(2*Math.PI-f)/2,m=g+p;for(let x=0;x<n;x++){let I=m+x/(n-1)*f;t.push(i(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,r=e.height??50,c=Ar(e),s=["top","bottom","left","right"],l=0;for(let d of s){let g=c[d];for(let b=0;b<g;b++){let f,p;d==="top"?(f=-a/2+(b+.5)*a/g,p=-r/2-ce):d==="bottom"?(f=-a/2+(b+.5)*a/g,p=r/2+ce):d==="left"?(f=-a/2-ce,p=-r/2+(b+.5)*r/g):(f=a/2+ce,p=-r/2+(b+.5)*r/g);let m=It(f,p,e.rotation,e.center);t.push(i(l++,m.x,m.y,d))}}return t}function ee(e){return Mr(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Sn(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function mn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,c=t[i].x,s=t[i].y;r>e.y!=s>e.y&&e.x<(c-a)*(e.y-r)/(s-r)+a&&(n=!n)}return n}function jr(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.y-n.y)*(i.y-n.y),c=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=c+1e-7})}function F(e,t,n){return mn(e,t)&&!(n??[]).some(o=>mn(e,o)||jr(e,o))}function vt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function L(e){switch(e.type){case"row":{let t=B(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let i of t)n+=i.x,o+=i.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return vt(e.points);case"section":return vt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?vt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function wn(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Lr(e,t){if(e.type!=="gaArea"||!wn(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((i,a)=>wn(i,o[a]))}function xn(e,t){let n=e.filter(r=>r.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,i=L(t);return(o?n.find(r=>(r.logicalSectionId??r.id)===o&&(Lr(t,r)||F(i,r.outline,r.holes))):void 0)??n.find(r=>F(i,r.outline,r.holes))}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 z(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var Ge=40;function vn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,c=(s,l)=>{s<o&&(o=s),l<i&&(i=l),s>a&&(a=s),l>r&&(r=l)};for(let s of z(e))if(s.type==="row"){let l=new Map((s.overrides??[]).map(d=>[d.index,d]));Ce(s).forEach((d,g)=>{let b=l.get(g);b?.skip||c(d.x+(b?.dx??0),d.y+(b?.dy??0))})}else if(s.type==="gaArea")for(let l of s.points)c(l.x,l.y);else if(s.type==="section")for(let l of s.outline)c(l.x,l.y);else if(s.type==="decorImage")c(s.x,s.y),c(s.x+s.width,s.y+s.height);else if(s.type==="shape")if(s.points&&s.points.length)for(let l of s.points)c(l.x,l.y);else s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null&&(c(s.x,s.y),c(s.x+s.width,s.y+s.height));else if(s.type==="table"){let l=ce+Rr,d=s.shape==="round"?(s.radius??40)+l:Math.max((s.width??80)/2,(s.height??50)/2)+l;c(s.center.x-d,s.center.y-d),c(s.center.x+d,s.center.y+d)}else if(s.type==="booth"){let l=Math.max(s.width,s.height)/2;c(s.center.x-l,s.center.y-l),c(s.center.x+l,s.center.y+l)}else if(s.type==="text"){if(n)continue;let l=on(s);c(s.position.x,s.position.y),c(s.position.x+l.width,s.position.y+l.height)}for(let s of[e.referenceImage,e.backgroundImage]){if(!s)continue;let{center:l,width:d}=s,g=d*3/4;c(l.x-d/2,l.y-g/2),c(l.x+d/2,l.y+g/2)}if(!isFinite(o)){let s=e.focalPoint??{x:0,y:0};return{x:s.x-200,y:s.y-200,width:400,height:400}}return{x:o-Ge,y:i-Ge,width:a-o+Ge*2,height:r-i+Ge*2}}function Be(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}var kr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Rn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Re(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Ct(e){let t=Re(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of kr){let c=i?.[r];c!==void 0&&(a[r]=c)}n.push([X(e,o,i),ve(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function Er(e){return JSON.parse(JSON.stringify(e))}function ze(e,t){let n=Er(e);return t(n)&&Ct(n)===Ct(e)?n:e}function Tr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Re(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let i=t.get(o)?.labelStyle;if(!i)return!1;if(!n)n=i;else if(!Rn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Fr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Pn(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let r=Fr(a.slice(n.length+1));if(r===void 0)return;o.push(r)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let i=o[1]-o[0];if(!(i!==1&&i!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==i)return;return i===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Nr(e){if(e.seatCount<1)return!1;let t=Re(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(X(e,i,t.get(i)));let o=Pn(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let i of e.overrides??[])delete i.label;return!0}function Dr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Re(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==se(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function He(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Rn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===X(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===ve(e,t.index)&&delete t.displayLabel}function _n(e){return Object.keys(e).every(t=>t==="index")}function Kr(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)He(e,n);let t=e.overrides.filter(n=>!_n(n));return t.length?e.overrides=t:delete e.overrides,!0}function Gr(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Re(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function An(e){if(e.type!=="row")return e;let t=ze(e,Tr);return t=ze(t,Nr),t=ze(t,Dr),t=ze(t,Kr),Gr(e,t)?t:e}function Mn(e){if(!e.overrides?.length)return e;let t=e.displayLabel??e.label,n=[];for(let i of e.overrides){let a={...i};a.label===`${e.label}-${a.index+1}`&&delete a.label,a.displayLabel===`${t}-${a.index+1}`&&delete a.displayLabel,a.categoryKey===e.categoryKey&&delete a.categoryKey,a.dx===0&&delete a.dx,a.dy===0&&delete a.dy,_n(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function In(e){return e.type==="row"?An(e):e.type==="table"?Mn(e):e}function $r(e){let t=e.objects.map(In),n=e.floors?.map(o=>({...o,objects:o.objects.map(In)}));return{...e,objects:t,...n?{floors:n}:{}}}var Cn=2,Br=3,On=6;function Oe(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function Ue(e){return{...e,x:Oe(e.x,Cn),y:Oe(e.y,Cn)}}function zr(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Ue(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Ue)),Array.isArray(t.points)&&(t.points=t.points.map(Ue)),typeof t.rotation=="number"&&(t.rotation=Oe(t.rotation,On)),typeof t.seatSpacing=="number"&&(t.seatSpacing=Oe(t.seatSpacing,On));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Ue(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let c=Oe(r,Br);c===0?delete i[a]:i[a]=c}return i})),t}var Ur=36,Hr=160;function jn(e,t=360){let n=xe(Math.round(Number.isFinite(e)?e:1),1,40),o=xe(Number.isFinite(t)?t:360,120,360);return Math.round(xe(n*4*(360/o),Ur,Hr))}var Pe=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],fc=new Map(Pe.map(e=>[e.key,e]));var Vr=[{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"}],gc=new Map(Vr.map(e=>[e.key,e]));var le=8,Ot=24,qr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],bc=new Set(qr);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(e,t){let n=T(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function j(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function A(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function Jr(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;let n=(a,r,c)=>(r.x-a.x)*(c.y-a.y)-(r.y-a.y)*(c.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=t.length-1;a>=0;a--){let r=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function Xr(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.map(o=>{let i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a)||1;return{x:o.x+i/r*t,y:o.y+a/r*t}})}function te(e){let t=[];for(let o of e)o.type==="row"?t.push(...B(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ee(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=Xr(Jr(t),22);return n.length>=3?n:null}function Ve(e,t){let n=C(e,t),o=T(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Ln=24,kn=80;function Rt(e,t){let n=e.normalize("NFKC").trim();if(n.length>Ln)throw new u("invalid_operation",`${t} displayed type must be at most ${Ln} characters`);return n}function qe(e,t){if(e.displayType===void 0)return!1;let n=Rt(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function de(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>kn)throw new u("invalid_operation",`${t} displayed label must be at most ${kn} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function k(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function En(e,t){if(!Number.isFinite(e)||e<le||e>Ot)throw new u("invalid_operation",`${t} label size must be from ${le} to ${Ot}`)}function ue(e,t){e.size!==void 0&&e.size!==null&&En(e.size,t),e.color!==void 0&&e.color!==null&&k(e.color,`${t} label color`)}function Je(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&En(n.size,t),n.color!==void 0&&k(n.color,`${t} label color`))}function Xe(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=k(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function Pt(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(i=>i.id!==n&&i.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function _t(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function q(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var Y=Math.PI/180,J=Math.PI/180;function ne(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function _e(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var Yr=0,Ye=120,At=4;function Qr(e){if(!Number.isFinite(e)||e<Yr||e>Ye)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Wr(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(s=>s.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(Ye,(e.floors.length-1)*At),r=Math.min(Ye,a+At),c=A(e,"floor",t.idFactory,new Set);return e.floors.push({id:c,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),_e(e),{changed:!0,floorId:c,floorCount:e.floors.length,baseHeightM:r}}function Zr(e,t){let n=T(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function ei(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(i=>i.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});Qr(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 ti(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(i=>i.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[i]=e.floors;e.objects=i.objects,e.focalPoint=i.focalPoint,e.referenceImage=i.referenceImage,e.backgroundImage=i.backgroundImage,e.floors=void 0}else _e(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:T(e).length}}function ni(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:A(e,"zone",t.idFactory,new Set),label:Pt(e,t.label),color:k(t.color,"Zone color"),...t.focalPoint?{focalPoint:_t(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function oi(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(s=>s.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(s=>[s.id,s])),i=n.filter(s=>!o.has(s));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(e),r=new Map((a.zones??[]).map(s=>[s.id,s]));for(let s of t.updates){if(!Object.keys(s.patch).length)throw new u("invalid_operation",`Zone ${s.zoneId} has no changes`);let d=r.get(s.zoneId);s.patch.label!==void 0&&(d.label=Pt(a,s.patch.label,d.id)),s.patch.color!==void 0&&(d.color=k(s.patch.color,"Zone color")),s.patch.focalPoint!==void 0&&(d.focalPoint=_t(s.patch.focalPoint,"Zone focal point"))}let c=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return c&&(e.zones=a.zones),{changed:c,zoneIds:n,zones:n.map(s=>structuredClone(r.get(s)))}}function ri(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 i=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,_e(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var Qe=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function We(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&t.set(a,(t.get(a)??0)+r)};i(e.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??e.categoryKey);return t}var Mt="__sl_ga__";function Ae(e){return e.startsWith(Mt)}var ii=Mt,oe=1e5,fe=1e5;function ai(e,t){return`${ii}${encodeURIComponent(e)}__${t+1}`}function jt(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){if(!i||typeof i.sourceAreaId!="string"||!i.sourceAreaId.trim()||i.sourceAreaId.length>160||!Number.isInteger(i.startIndex)||i.startIndex<0||!Number.isInteger(i.count)||i.count<1||i.startIndex+i.count>oe||(n+=i.count,n>oe))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(c=>i.startIndex<c.end&&r>c.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===e.capacity}function Ze(e){let t=Math.min(oe,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:jt(e)?e.inventorySegments.map(n=>({...n})):[]}function Q(e){return Ze(e).flatMap(t=>Array.from({length:t.count},(n,o)=>ai(t.sourceAreaId,t.startIndex+o)))}function Lt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=Ze(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(c=>c.sourceAreaId===e.id).reduce((c,s)=>Math.max(c,s.startIndex+s.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var si="__ungrouped__";function ci(e){return e.type==="row"?B(e).map(t=>t.label):e.type==="table"?ee(e).map(t=>t.label):e.type==="booth"?Sn(e).map(t=>t.label):e.type==="gaArea"?Q(e):[]}function li(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Me(e){let t=z(e),n=t.filter(r=>r.type==="section"),o=new Map;for(let r of n){let c=r.logicalSectionId??r.id;o.get(c)||o.set(c,{id:c,label:r.displayLabel||r.label||"Section",zone:r.zone,seatCount:0,objectIds:[],seatLabels:[]})}let i={id:si,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},a=new Map;for(let r of t){if(!li(r))continue;let c=ci(r);if(c.length===0)continue;let s=xn(t,r),l=s?o.get(s.logicalSectionId??s.id):i;l.seatCount+=c.length,l.objectIds.push(r.id),l.seatLabels.push(...c),a.set(r.id,l.id)}return{sections:[...o.values()],ungrouped:i.objectIds.length?i:null,objectToSection:a}}var re={vip:{key:"vip",label:"VIP",color:"#e5484d",price:120},premium:{key:"premium",label:"Premium",color:"#a86b00",price:80},standard:{key:"standard",label:"Standard",color:"#6e7bff",price:45},balcony:{key:"balcony",label:"Balcony",color:"#22a06b",price:30}};function je(e,t,n,o,i,a,r=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function di(e,t,n,o,i,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function Tn(e,t,n,o,i,a){let r=n/2,c=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-c},{x:r,y:-c},{x:r,y:c},{x:-r,y:c}],capacity:i,categoryKey:a}}function ui(e,t,n,o,i){let a=n*2,r=[];for(let c=0;c<a;c++){let s=c%2===0,l=s?["wheelchair"]:["companion"];r.push(s?{index:c,accessibility:l,wheelchairSpaceType:"no-seat"}:{index:c,accessibility:l})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Fn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[re.balcony],sectionLabel:"Balcony",build:()=>[je("blk-b0","A",-45,18,24,"balcony",18),je("blk-b1","B",-15,20,24,"balcony",18),je("blk-b2","C",15,22,24,"balcony",18),je("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[re.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>je(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[re.standard],build:()=>[Tn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[re.premium],build:()=>Array.from({length:6},(e,t)=>di(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[re.vip],build:()=>[{type:"table",id:"blk-x0",label:"Box 1",center:{x:-70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"},{type:"table",id:"blk-x1",label:"Box 2",center:{x:70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[re.standard],build:()=>[Tn("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[re.standard],build:()=>[ui("blk-wc","A",4,40,"standard")]}];function U(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function Nn(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Dn="M13 4.6a1.6 1.6 0 1 0-3.2 0 1.6 1.6 0 0 0 3.2 0 M11 6.5V13h5l2.4 6 M15 16.4A5 5 0 1 1 9 11.3",Kn=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:"M16 7a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:"M15 5a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M12 8l-4 10h8l-4-10 M10 18v4 M14 18v4"},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:Dn},{key:"first-aid",label:"First aid",group:"facilities",path:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z M12 8v8 M8 12h8"},{key:"coat-check",label:"Coat check",group:"facilities",path:"M12 6a2 2 0 0 1 0-4 2 2 0 0 1 1.6 3.2L21 13H3l8.4-7.8 M3 13h18"},{key:"atm",label:"ATM / cash",group:"facilities",path:"M2 6h20v12H2V6Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0 M6 9h.01 M18 15h.01"},{key:"info",label:"Info point",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 11v5 M12 8h.01"},{key:"lost-found",label:"Lost & found",group:"facilities",path:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14 M16 16l5 5 M9 8.5a2 2 0 1 1 3 1.7c-.8.5-1 .8-1 1.8 M11 15h.01"},{key:"restrooms",label:"Restrooms",group:"facilities",path:"M6 3h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M9 18v-3.5a3 3 0 0 1 6 0V18"},{key:"charging",label:"Charging point",group:"facilities",path:"M3 8h13v8H3V8Z M16 10h3v4h-3 M9.6 9l-2 3.5h2.5l-1.5 3"},{key:"smoking",label:"Smoking area",group:"facilities",path:"M2 15h13v3H2v-3Z M18 16h2 M19 8c0 1 1 1.5 1 2.5S19 12 19 13"},{key:"no-smoking",label:"No smoking",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M5.6 5.6l12.8 12.8 M7 13h6v2H7v-2Z"},{key:"food",label:"Food",group:"food-drink",path:"M7 3v6a2 2 0 0 0 4 0V3 M9 11v10 M17 3c-1.6 1-2.2 3-2.2 6 0 2 .9 3.2 2.2 3.6V21"},{key:"bar",label:"Bar",group:"food-drink",path:"M4 5h16l-8 8-8-8Z M12 13v6 M8 20h8"},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 8h13v4a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z M17 9h2a2 2 0 0 1 0 4h-2 M8 2v2 M11 2v2 M4 21h14"},{key:"water",label:"Water / drinks",group:"food-drink",path:"M12 22a7 7 0 0 1-7-7c0-5 7-12 7-12s7 7 7 12a7 7 0 0 1-7 7Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:"M6 8h12l-1 12H7L6 8Z M9 8V6a3 3 0 0 1 6 0v2"},{key:"screen",label:"Screen",group:"facilities",path:"M3 4h18v12H3V4Z M9 20h6 M12 16v4 M10 8l4 2-4 2V8Z"},{key:"sound-booth",label:"Sound booth",group:"facilities",path:"M6 4v16 M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4 M12 4v16 M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M18 4v16 M18 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4"},{key:"entrance",label:"Entrance",group:"navigation",path:"M14 3h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-5 M3 12h11 M10 8l4 4-4 4"},{key:"exit",label:"Exit",group:"navigation",path:"M10 3H5a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h5 M14 12h7 M17 8l4 4-4 4"},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:"M14 4.6a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0 M12.5 8l-3.5 2 1.6 3.6-2 4.4 M12.5 10l3.5 1.5 M9 10.5l-3.5 1 M15 12h6 M18 9l3 3-3 3"},{key:"stairs",label:"Stairs",group:"navigation",path:"M3 20v-4h4v-4h4v-4h4V4h5"},{key:"elevator",label:"Elevator",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M8 11l1.5-2 1.5 2 M8 14l1.5 2 1.5-2 M15 8v8"},{key:"parking",label:"Parking",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M9 17V7h4a3 3 0 0 1 0 6H9"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:Dn},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}];var fi=new Map(Kn.map(e=>[e.key,e]));function Gn(e){return typeof e=="string"&&fi.has(e)}var Kc=Kn.map(e=>e.key);function kt(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function $n(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=e.holes.map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=ln(e.outlinePath,t,n)),e.holes&&(e.holes=e.holes.map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function gi(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function Le(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function et(e,t,n){let o=Le(t,n,e);return Math.abs(o)>1e-7?!1:e.x>=Math.min(t.x,n.x)-1e-7&&e.x<=Math.max(t.x,n.x)+1e-7&&e.y>=Math.min(t.y,n.y)-1e-7&&e.y<=Math.max(t.y,n.y)+1e-7}function bi(e,t,n,o){let i=Le(e,t,n),a=Le(e,t,o),r=Le(n,o,e),c=Le(n,o,t);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&c<-1e-7||r<-1e-7&&c>1e-7)?!0:Math.abs(i)<=1e-7&&et(n,e,t)||Math.abs(a)<=1e-7&&et(o,e,t)||Math.abs(r)<=1e-7&&et(e,n,o)||Math.abs(c)<=1e-7&&et(t,n,o)}function hi(e){return e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n.x*i.y-i.x*n.y},0)}function pi(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&bi(e[t],e[n],e[o],e[i]))return!0}}return!1}function Bn(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>gi(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(hi(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:pi(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function Oi(e,t){let n=C(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(y=>y.type==="table"&&y.id===h)),a=o.filter((h,y)=>!i[y]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=k(r.fill,"Table surface color"));let c=r.seatCount!==void 0,s=r.seatCountsBySide!==void 0;if(s){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let h=["top","bottom","left","right"],y=Object.keys(r.seatCountsBySide);if(y.length!==h.length||y.some(S=>!h.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of h){let v=r.seatCountsBySide[S];if(!Number.isInteger(v)||v<0||v>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let w=h.reduce((S,v)=>S+r.seatCountsBySide[v],0);if(w<1||w>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(c&&r.seatCount!==w)throw new u("invalid_operation",`seatCount must equal the ${w}-chair seatCountsBySide total`);r.seatCount=w,r.sides=h.filter(S=>r.seatCountsBySide[S]>0)}if(r.seatCount!==void 0&&(!Number.isInteger(r.seatCount)||r.seatCount<1||r.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(r.shape!==void 0&&r.shape!=="round"&&r.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(r.automaticRadius!==void 0&&typeof r.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(r.shape==="rect"&&r.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(r.bookAsWhole===!0&&r.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(r.variableOccupancy===!1&&(r.minOccupancy!==void 0||r.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(h,y,w,S)=>{if(y!==void 0&&(!Number.isFinite(y)||y<w||y>S))throw new u("invalid_operation",`${String(h)} must be from ${w} to ${S}`)};if(l("rotation",r.rotation,0,360),l("radius",r.radius,24,160),l("seatArc",r.seatArc,120,360),l("width",r.width,40,320),l("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let h=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(y=>!h.has(y)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=de(r,"Table"),g=qe(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!s&&(c||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let y=structuredClone(h);if(Object.assign(y,r),r.fill===null&&delete y.fill,y.shape==="round")delete y.seatCountsBySide,y.automaticRadius===!0?y.radius=jn(y.seatCount,y.seatArc):delete y.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${y.label}" is rectangular and cannot use automatic radius`,{tableId:y.id});delete y.automaticRadius}if(y.overrides&&r.seatCount!==void 0&&(y.overrides=y.overrides.filter(w=>w.index<y.seatCount),y.overrides.length||delete y.overrides),r.bookAsWhole===!1&&delete y.bookAsWhole,r.variableOccupancy===!1&&(delete y.variableOccupancy,delete y.minOccupancy,delete y.maxOccupancy),y.bookAsWhole||delete y.bookAsWhole,y.variableOccupancy||delete y.variableOccupancy,y.bookAsWhole&&y.variableOccupancy)throw new u("invalid_operation",`Table "${y.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:y.id});if((y.bookAsWhole||y.variableOccupancy)&&y.overrides?.length)throw new u("invalid_operation",`Table "${y.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:y.id,overriddenChairIndices:y.overrides.map(w=>w.index)});if(y.bookAsWhole)delete y.minOccupancy,delete y.maxOccupancy;else if(y.variableOccupancy){if(!Number.isInteger(y.minOccupancy)||!Number.isInteger(y.maxOccupancy)||y.minOccupancy<1||y.maxOccupancy<y.minOccupancy||y.maxOccupancy>y.seatCount)throw new u("invalid_operation",`Table "${y.label}" needs whole-number minimum and maximum guests from 1 to its ${y.seatCount}-chair capacity`,{tableId:y.id,seatCount:y.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:y.id});delete y.minOccupancy,delete y.maxOccupancy}if(g&&delete y.displayType,d&&delete y.displayLabel,y.shape==="rect"){if(y.width??=80,y.height??=50,y.seatCountsBySide){let w=["top","bottom","left","right"],S=w.reduce((v,P)=>v+y.seatCountsBySide[P],0);if(S!==y.seatCount)throw new u("invalid_operation",`Table "${y.label}" side counts total ${S}, but seatCount is ${y.seatCount}`,{tableId:y.id,seatCount:y.seatCount,seatCountsBySide:y.seatCountsBySide});y.sides=w.filter(v=>y.seatCountsBySide[v]>0)}}else y.radius??=40;if((y.bookAsWhole||y.variableOccupancy)&&Ae(y.label))throw new u("invalid_operation",`Grouped table label "${y.label}" uses SeatLayer's reserved GA namespace`,{tableId:y.id});return y}),f=new Map(b.map(h=>[h.id,h])),p=new Set(o),m=new Map;for(let h of T(e))for(let y of h.objects){let w=y.type==="table"?f.get(y.id)??y:y,S=[];w.type==="row"?S=B(w).map(v=>v.label):w.type==="table"?S=w.bookAsWhole||w.variableOccupancy?[w.label]:ee(w).map(v=>v.label):w.type==="booth"?S=[w.label]:w.type==="gaArea"&&(S=Q(w));for(let v of S){let P=m.get(v);if(P&&(p.has(P)||p.has(w.id)))throw new u("invalid_operation",`Inventory label "${v}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:v,conflictingObjectIds:[P,w.id]});m.set(v,P??w.id)}}let x=!1,I=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,y]of i.entries()){let w=b[h],S=JSON.stringify(y);for(let v of I)v in w||delete y[v];Object.assign(y,w),JSON.stringify(y)!==S&&(x=!0)}return{floorId:n.floorId,changed:x,tableIds:o}}function Ri(e,t){let n=C(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(p=>p.type==="booth"&&p.id===f)),a=o.filter((f,p)=>!i[p]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey);let c=(f,p,m,x)=>{if(p!==void 0&&(!Number.isFinite(p)||p<m||p>x))throw new u("invalid_operation",`${f} must be from ${m} to ${x}`)};c("width",r.width,30,400),c("height",r.height,30,400),c("rotation",r.rotation,0,360);let s=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=Bn(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let l=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=de(r,"Booth"),g=qe(r,"Booth"),b=!1;for(let f of i){let p=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,s?delete f.points:l&&(f.points=l),JSON.stringify(f)!==p&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Pi(e,t){let n=C(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let i=o.map(d=>n.objects.find(g=>g.type==="gaArea"&&g.id===d)),a=o.filter((d,g)=>!i[g]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one GA area change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(r.categoryKey!==void 0&&j(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>1e5))throw new u("invalid_operation","capacity must be an integer from 1 to 100000");if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let c=de(r,"GA area"),s=qe(r,"GA area");if(r.capacity!==void 0)for(let d of i){if(d.inventorySegments!==void 0&&r.capacity<d.capacity)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot be reduced below ${d.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:d.id,currentCapacity:d.capacity,requestedCapacity:r.capacity});if(d.inventorySegments!==void 0&&r.capacity>d.capacity&&Lt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let l=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:Lt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),c&&delete d.displayLabel,s&&delete d.displayType,JSON.stringify(d)!==g&&(l=!0)}return{floorId:n.floorId,changed:l,gaAreaIds:o}}function tt(e,t){if(t.length<3)return 0;let n=i=>F(i,t,void 0),o=0;for(let i of e)n(L(i))&&(i.type==="row"?o+=B(i).length:i.type==="table"?o+=ee(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=ne(i)));return o}function _i(e,t){let n=C(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(c=>n.objects.find(s=>s.id===c)),i=t.objectIds.filter((c,s)=>!o[s]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(t.objectIds);for(let c=n.objects.length-1;c>=0;c--)r.has(n.objects[c].id)&&n.objects.splice(c,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(c=>({id:c.id,type:c.type})),removedInventory:a.reduce((c,s)=>c+ne(s),0),remainingObjectCount:n.objects.length}}function Ai(e,t){let n=C(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=k(r.color,"Text color")),r.bold!==void 0&&typeof r.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(r.italic!==void 0&&typeof r.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(r.width!==void 0&&r.width!==null&&(!Number.isFinite(r.width)||r.width<40||r.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(r.align!==void 0&&!["left","center","right"].includes(r.align))throw new u("invalid_operation","Text align must be left, center, or right");if(r.lineHeight!==void 0&&(!Number.isFinite(r.lineHeight)||r.lineHeight<.8||r.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(r.letterSpacing!==void 0&&(!Number.isFinite(r.letterSpacing)||r.letterSpacing<-2||r.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(r.underline!==void 0&&typeof r.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(r.opacity!==void 0&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(r.background!==void 0&&r.background!==null){r.background.color=k(r.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(l)||l<0||l>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(g)||g<.1||g>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(l=>Object.prototype.hasOwnProperty.call(r,l))&&i.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!Gn(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(l=>l.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let s=!1;for(let l of i){let d=JSON.stringify(l);r.iconKey!==void 0&&(l.iconKey=r.iconKey),r.text!==void 0&&(l.text=r.text),r.fontSize!==void 0&&(l.fontSize=r.fontSize),r.fontFamily===null?delete l.fontFamily:r.fontFamily!==void 0&&(l.fontFamily=r.fontFamily),r.rotation!==void 0&&(l.rotation=r.rotation),r.color===null?delete l.color:r.color!==void 0&&(l.color=r.color),r.bold!==void 0&&(r.bold?l.bold=!0:delete l.bold),r.italic!==void 0&&(r.italic?l.italic=!0:delete l.italic),r.width===null?delete l.width:r.width!==void 0&&(l.width=r.width),r.align!==void 0&&(r.align==="left"?delete l.align:l.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete l.lineHeight:l.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?l.underline=!0:delete l.underline),r.opacity!==void 0&&(r.opacity===1?delete l.opacity:l.opacity=r.opacity),r.background===null?delete l.background:r.background!==void 0&&(l.background=r.background),r.labelImportance===null?delete l.labelImportance:r.labelImportance!==void 0&&(l.labelImportance=r.labelImportance),JSON.stringify(l)!==d&&(Be(l),s=!0)}return{floorId:n.floorId,changed:s,textIds:o}}function Mi(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),c=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,s=bn(r.map(b=>({label:c(b)})),t.options),l=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=l===void 0||l===""||l==="Row"?t.displayType===void 0?void 0:null:l,g=!1;return r.forEach((b,f)=>{let p=s[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(c(b)!==p&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=p:b.displayLabel=p),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:c(b),...b.displayType?{displayType:b.displayType}:{}}))}}function ji(e,t){let n=Fn.find(l=>l.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=C(e,t.floorId),i=new Set,a=n.build().map(l=>structuredClone(l));for(let l of a)l.id=A(e,l.type,t.idFactory,i),$n(l,t.center.x,t.center.y);for(let l of n.categories)e.categories.some(d=>d.key===l.key)||e.categories.push({...l});let r=a.filter(l=>l.type==="row");if(r.length){let l=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Nn(d.label);g!=null&&(l=Math.max(l,g+1))}for(let d of r)d.label=U(l++)}let c=new Set(o.objects.flatMap(l=>"label"in l&&l.label?[l.label]:[]));for(let l of a){if((l.type==="table"||l.type==="booth")&&c.has(l.label)){let d=/^(.*?)(\d+)$/.exec(l.label),g=d?d[1]:`${l.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(c.has(`${g}${b}`));l.label=`${g}${b}`}"label"in l&&l.label&&c.add(l.label)}o.objects.push(...a);let s=null;if(n.sectionLabel&&t.wrapInSection!==!1){let l=te(a);if(l){let d={type:"section",id:A(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:l};o.objects.push(d),s=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(l=>l.id),...s?[s]:[]],sectionId:s}}function Li(e){let t=structuredClone(e);if([t.start,t.control1,t.control2,t.end].some(a=>!Number.isFinite(a.x)||!Number.isFinite(a.y)))throw new u("invalid_operation","Exact row path points must be finite");let o=De(t,97),i=o.slice(1).reduce((a,r,c)=>a+Math.hypot(r.x-o[c].x,r.y-o[c].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:i}}function Hn(e,t){let n=C(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=Li(t.path),a=B(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let c=B(r),s=a.map((d,g)=>Math.hypot(d.x-c[g].x,d.y-c[g].y)),l=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:s.length?s.reduce((d,g)=>d+g,0)/s.length:0,maxSeatMovement:s.length?Math.max(...s):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function ki(e,t){let n=Hn(e,t);if(!n.changed)return n;let i=C(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(t.path),i.origin={...t.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function Ei(e,t){let n=e.map((o,i)=>[...o,t[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let c=n[r][o];for(let s=o;s<4;s++)n[r][s]-=c*n[o][s]}}return[n[0][3],n[1][3],n[2][3]]}function Ti(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let c=0;c<3;c++){n[c]+=a[c]*r;for(let s=0;s<3;s++)t[c][s]+=a[c]*a[s]}}let o=Ei(t,n);return o?{x:o[0],y:o[1]}:null}function zn(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function Vn(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=T(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Ti(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let c=n.objects.filter(f=>f.type==="row"&&F(L(f),o.outline,o.holes)),s=c.filter(f=>!!f.path).map(f=>f.id),l=[],d=[],g=i/100;for(let f of c){if(f.path)continue;if(f.seatCount<2){l.push(f.id);continue}let p=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(p<=f.seatSpacing/2+1e-6){l.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*p))/Y,x=B(f),I=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/Y,y=(f.curve!==0?Math.sign(f.curve):x.length>1&&Math.sign(zn(Math.atan2(x[1].x-r.x,x[1].y-r.y)/Y-I))||1)*m*(f.seatCount-1);if(Math.abs(y)>320){l.push(f.id);continue}let w=-I,S=f.curve+(y-f.curve)*g,v=f.rotation+zn(w-f.rotation)*g,P={...f,curve:S,rotation:v},N=B(P).map((H,G)=>Math.hypot(H.x-x[G].x,H.y-x[G].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:y,resultCurve:S,fromRotation:f.rotation,resultRotation:v,rmsMovement:Math.sqrt(N.reduce((H,G)=>H+G**2,0)/N.length),maxMovement:Math.max(...N)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:s,skippedInvalidRowIds:l,averageMovement:b.length?b.reduce((f,p)=>f+p,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function Fi(e,t){let n=Vn(e,t),o=C(e,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let c=o.objects.find(s=>s.type==="row"&&s.id===r.rowId);(c.curve!==r.resultCurve||c.rotation!==r.resultRotation)&&(c.curve=r.resultCurve,c.rotation=r.resultRotation,delete c.arcFanGeneration,delete c.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function qn(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),c=q(n,o,t);return i*a<-1e-9&&r*c<-1e-9}function Un(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>qn(n,i,a,t[(r+1)%t.length]))})}function Ni(e){if(e.length<3||e.length>256||Math.abs(Se(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)&&qn(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function nt(e,t,n){let o=C(e,t),i=o.objects.find(a=>(a.type==="section"||a.type==="gaArea")&&a.id===n);if(!i)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});return{target:o,object:i,outer:i.type==="section"?i.outline:i.points}}function ot(e,t){let{target:n,object:o,outer:i}=nt(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Ni(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!F(l,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Un(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],c=t.holeIndex??r.length;if(!Number.isInteger(c)||c<0||c>r.length||t.holeIndex!=null&&c>=r.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<r.length;l++){if(l===t.holeIndex)continue;let d=r[l];if(Un(a,d)||F(a[0],d,void 0)||F(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let s=n.objects.filter(l=>l.id!==o.id&&l.type!=="section"&&F(L(l),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:c,vertexCount:a.length,excludedObjectIds:s.map(l=>l.id),excludedInventoryUnits:tt(n.objects.filter(l=>l.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Di(e,t){let n=ot(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function Jn(e,t){let{target:n,object:o}=nt(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[t.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&F(L(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:tt(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ki(e,t){let n=Jn(e,t),{object:o}=nt(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Gi(e){let t=Z(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Xn(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.find(c=>c.type==="section"&&c.id===r)),i=n.filter((r,c)=>!o[c]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function Yn(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),i=Me(Ve(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),c=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),s=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of c){let p=r.get(f);if(p)if(p.type==="row"||p.type==="table")for(let m of We(p).keys())s.add(m);else(p.type==="booth"||p.type==="gaArea")&&s.add(p.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(p=>{let m=r.get(p);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:c,categoryApplicable:g,...g&&s.size===1?{categoryKey:[...s][0]}:!g&&!c.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?s.size!==1:!c.length&&d.size>1,viewApplicable:b}}function $i(e,t){j(e,t.categoryKey);let n=Yn(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=C(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,c=new Set(n.logicalSectionIds);for(let s of o.objects)s.type!=="section"||!c.has(s.logicalSectionId??s.id)||s.editor?.defaultCategoryKey!==t.categoryKey&&(s.editor={...s.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let s of o.objects){if(!i.has(s.id)||s.type!=="row"&&s.type!=="table"&&s.type!=="booth"&&s.type!=="gaArea"||(s.categoryKey!==t.categoryKey&&(s.categoryKey=t.categoryKey,a=!0),s.type!=="row"&&s.type!=="table"||!s.overrides?.length))continue;let l=s.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});l.length?s.overrides=l:delete s.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Bi(e,t){let n=C(e,t.floorId),o=Xn(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),c=Object.keys(a).filter(f=>!r.has(f));if(c.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${c.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=Gi(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&&Je(a.labelPresentation,"Section"),a.labelStyle!==void 0&&ue(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(f=>f.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=k(a.color,"Section color"));let s=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=s?n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let p=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let m=x=>{f.physical3dProvenance&&(delete f.physical3dProvenance[x],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,m("height")):a.height!==void 0&&(f.height=a.height,f.physical3dProvenance={...f.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete f.rake,m("rake")):a.rake!==void 0&&(f.rake=a.rake,f.physical3dProvenance={...f.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete f.surfaceKind,m("surfaceKind")):a.surfaceKind!==void 0&&(f.surfaceKind=a.surfaceKind,f.physical3dProvenance={...f.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete f.color:a.color!==void 0&&(f.color=a.color),JSON.stringify(f)!==p&&(b=!0,g.add(f.id))}for(let f of d){let p=JSON.stringify(f),m=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let x=Xe(f.labelPresentation,a.labelStyle);x?f.labelPresentation=x:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==p&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function Qn(e,t){let n=C(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&F(L(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+ne(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function zi(e,t){let n=Qn(e,t),i=C(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function Wn(e,t){let n=(...c)=>c.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=c=>({x:c.x+t.dx,y:c.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let c=L(e);o=s=>({x:c.x+(s.x-c.x)*t.factor,y:c.y+(s.y-c.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let s=t.degrees*Math.PI/180,l=Math.cos(s),d=Math.sin(s),g=L(e);o=b=>{let f=b.x-g.x,p=b.y-g.y;return{x:g.x+f*l-p*d,y:g.y+f*d+p*l}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?c=>({x:2*t.coordinate-c.x,y:c.y}):c=>({x:c.x,y:2*t.coordinate-c.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=wt(e.outlinePath,o,i,a)),e.holes&&(e.holes=e.holes.map(c=>c.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(c=>c.kind)??[]}}function Ui(e,t){let n=C(e,t.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Wn(o,t.transform)}}function Hi(e,t){let n=C(e,t.floorId),o=n.objects.find(c=>c.type==="section"&&c.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Ke(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=mt(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(c=>c.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function Vi(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function qi(e,t){return Zn(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function Zn(e,t){let n=C(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(c=>!Number.isFinite(c)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let c of o){let s=n.objects.find(h=>h.type==="section"&&h.id===c);if(!s||!Vi(s))continue;let d=structuredClone(s);a.set(s.id,{section:s,snapshot:d});let g=JSON.stringify(s),b=(s.sourceOutline??s.outline).map(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??s.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?s.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),x=m?.some(h=>Math.abs(h)>.5)===!0,I=f>.5||x?dn(b,{cornerSmoothing:f,...x?{edgeCurvature:m}:{}}):null;I?(s.sourceOutline=b,s.outlinePath=I,s.outline=mt(I),f>.5?s.cornerSmoothing=f:delete s.cornerSmoothing,x?s.edgeCurvature=[...m]:delete s.edgeCurvature):(s.outline=b,delete s.outlinePath,delete s.sourceOutline,delete s.cornerSmoothing,delete s.edgeCurvature);for(let h=0;h<(s.holes?.length??0);h+=1)ot(e,{floorId:n.floorId,objectId:s.id,points:s.holes[h],holeIndex:h});JSON.stringify(s)!==g&&(r=!0,i.add(s.id))}}catch(c){for(let{section:s,snapshot:l}of a.values()){let d=s;for(let g of Object.keys(d))delete d[g];Object.assign(s,structuredClone(l))}throw c}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}var Tt=.15,Ft=1.6;var Ji=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Dt(e){let t=Ji.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(i=>i+i).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Kt(e,t){let n=a=>{let r=Dt(a);if(!r)return null;let c=h=>{let y=h/255;return y<=.04045?y/12.92:((y+.055)/1.055)**2.4},s=c(r[0]),l=c(r[1]),d=c(r[2]),g=(.4124*s+.3576*l+.1805*d)/.95047,b=.2126*s+.7152*l+.0722*d,f=(.0193*s+.1192*l+.9505*d)/1.08883,p=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=p(g),x=p(b),I=p(f);return[116*x-16,500*(m-x),200*(x-I)]},o=n(e),i=n(t);return o&&i?Math.hypot(o[0]-i[0],o[1]-i[1],o[2]-i[2]):null}function Nt(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function eo(e){return .2126*Nt(e[0])+.7152*Nt(e[1])+.0722*Nt(e[2])}function rt(e,t){let n=Dt(e),o=Dt(t);if(!n||!o)return null;let i=eo(n),a=eo(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var to=["butt","round","square"],no=["miter","round","bevel"],oo=["none","arrow"];function Gt(e){return e==="line"||e==="polyline"}var ro=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22}}],xl=ro.map(e=>e.key),Xi=new Map(ro.map(e=>[e.key,e]));function ke(e){return typeof e=="string"&&Xi.has(e)}var Yi=new Set(["companion","child","senior","student","membership","custom"]);function ge(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let c=r.toLocaleLowerCase("en"),s=n.get(c);if(s)throw new u("duplicate_category_label",`Categories ${s} and ${a} share the same label`,{categoryKeys:[s,a],label:r});if(n.set(c,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.referenceDirectSeatImport!==void 0){let l=i.referenceDirectSeatImport;if(l.assetId!==l.assetId.trim()||l.assetId.length>160||!l.assetId||l.familyId!==l.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(l.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.seatGlyph!=null&&!ke(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let l=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),p=f.toLocaleLowerCase("en");if(!b||b.length>160||l.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(p))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!Yi.has(g.restriction))throw new u("invalid_operation",`Ticket tier ${b} has an unknown restriction`,{categoryKey:a,tierId:b});if(g.buyerMessage!=null){if(g.buyerMessage=g.buyerMessage.normalize("NFKC").trim(),!g.buyerMessage)delete g.buyerMessage;else if(g.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${b} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:b})}if(g.currency!=null&&(g.currency=g.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(g.currency)))throw new u("invalid_operation",`Ticket tier ${b} must use a three-letter ISO currency`,{categoryKey:a,tierId:b});if(g.applicability!=null){let m=g.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),x=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(I=>!I||I.length>160)||new Set(m).size!==m.length)||x&&(!x.length||x.some(I=>!Pe.some(h=>h.key===I))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...m?{seatLabels:m}:{},...x?{accessibility:[...x]}:{}},!g.applicability.seatLabels&&!g.applicability.accessibility&&delete g.applicability}if(g.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(g.evidence.provenance)||typeof g.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(g.evidence.sourceDescription=g.evidence.sourceDescription.normalize("NFKC").trim(),!g.evidence.sourceDescription||g.evidence.sourceDescription.length>240||g.evidence.capturedAt!==void 0&&(g.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(g.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}l.add(b),d.add(p)}}}return o}function ao(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let c=o.find(g=>g.key===r.categoryKey);if(!c)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let s=structuredClone(r.patch),{tiers:l,...d}=s;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(c,d),c.notForSale===!1&&delete c.notForSale,Object.prototype.hasOwnProperty.call(s,"tiers")&&(l==null?delete c.tiers:c.tiers=l?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete c.referenceDirectSeatImport}let i=ge(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function Qi(e,t){let n=structuredClone(e.categories),o=n.find(r=>r.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let i=ge(n),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,category:e.categories.find(r=>r.key===t.categoryKey),categories:e.categories}}function Wi(e,t){let n=t.categoryKeys.map(s=>s.trim()),o=e.categories.map(s=>s.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(s=>!n.includes(s)),r=n.filter(s=>!i.has(s));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((s,l)=>s===o[l]))return{changed:!1,categoryKeys:o,categories:e.categories};let c=new Map(e.categories.map(s=>[s.key,s]));return e.categories=ge(n.map((s,l)=>{let d=structuredClone(c.get(s));return s!==o[l]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var $t=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function io(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[1];return n.length===3&&(n=n.split("").map(o=>o+o).join("")),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Zi(e,t){let n=io(e),o=io(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var ea=3600;function so(e,t,n=$t){return n.find(i=>e.every(a=>Zi(i,a)>=ea))??n[t%n.length]}function ta(e,t){let n=t?.palette??$t;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,c)=>({categoryKey:r.key,patch:{color:n[c%n.length]}}));return ao(e,{updates:i}),{changed:e.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:e.categories}}function na(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(e.categories),a=i.find(s=>s.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=ge(i),c=JSON.stringify(r)!==JSON.stringify(e.categories);return c&&(e.categories=r),{changed:c,category:e.categories.find(s=>s.key===t.categoryKey),categories:e.categories}}function co(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let s=t.idFactory("cat").trim();if(s&&!n.has(s)){o=s;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=ge([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var oa=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],ra={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function ia(e,t){let n=ra[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var aa=26;function sa(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,c,s]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],l=n-o/2,d=g=>Math.round((g+l)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(c)}${d(s)}`}function ca(e,t,n){let o=r=>e.every(c=>{let s=Kt(r,c);return s==null||s>=aa}),i=r=>{let c=rt(r,"#12151d"),s=rt(r,"#ffffff");return(c??0)>=3||(s??0)>=3},a=t.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let c of[.52,.44,.6]){let s=sa(r,.62,c);if(o(s)&&i(s))return s}return n}function lo(e,t){let n=Qe.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function la(e){let t=new Map;for(let n of T(e))for(let o of n.objects){let i=Qe.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of We(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let c=t.get(r)??new Set;c.add(i.objectType),t.set(r,c)}}return t}function da(e,t){let n=new Set(e.categories.map(i=>i.label.toLowerCase())),o=t;for(let i=2;n.has(o.toLowerCase());i+=1)o=`${t} ${i}`;return o}function uo(e,t,n){let o=la(e),i=l=>{let d=o.get(l);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(l=>l.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let l=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(l)return{kind:"existing",categoryKey:l.key,label:l.label}}let r=Qe.find(l=>l.objectType===n),c=a?lo(a.label,n):n==="gaArea"?"General Admission":r.creationWord,s=e.categories.find(l=>l.label.toLowerCase()===c.toLowerCase()&&i(l.key));return s?{kind:"existing",categoryKey:s.key,label:s.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:da(e,c)}}function ua(e,t,n,o){let i=uo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return fa(e,n,a,i.label,o)}function fa(e,t,n,o,i){let a=i.palette??oa,r=e.categories.map(d=>d.color),c=i.suggestColor?.(r.map(d=>d.toLowerCase()))??so(r,e.categories.length),s=ca(r,ia(t,a),c),l=co(e,{label:o,color:s,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=l.categories,l.category.key}function ga(e,t){let n=new Set;for(let o of T(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function ba(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=ga(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let i=ge(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var ha=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],pa=["seat","deck","shell","fascia"];function ya(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),i={...e.theme??{}};for(let a of ha){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=k(r,`Theme ${a}`))}if(n.fontFamily===null)delete i.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");i.fontFamily=a}if(n.seatScale===null)delete i.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<Tt||n.seatScale>Ft)throw new u("invalid_operation",`Theme seatScale must be from ${Tt} to ${Ft}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=Z(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let c of pa){let s=n.venue3d[c];s===null?delete a[c]:s!==void 0&&(a[c]=k(s,`3D venue ${c}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function ma(e,t){let n=t.url===null?null:Z(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 c=e.floors?.find(g=>g.id===t.floorId);if(!c)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let s=(c.viewFromSeatUrl??void 0)===o,l=o?t.metadata===null?void 0:t.metadata??(s?c.viewFromSeatMeta:void 0):void 0,d=!s||JSON.stringify(c.viewFromSeatMeta??null)!==JSON.stringify(l??null);return c.viewFromSeatUrl=o,c.viewFromSeatMeta=l,{changed:d,scope:"floor",floorId:t.floorId,url:c.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function wa(e,t){let n=Ve(e,t.floorId),o=vn(n),i=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:i==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function it(e,t){j(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let c={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(c.left,c.center,c.right)||Object.values(c).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let l=C(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:c,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function Sa(e,t,n){let o=n*Y;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function xa(e,t,n,o){let i=Math.abs(o-n)*Y,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let g=e.aisleGaps[l];if(!g)return[];let b=g/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((l,d)=>l[0]-d[0]),r=[];for(let l of a){let d=r[r.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):r.push([...l])}let c=[],s=0;for(let l of r)l[0]-s>1e-6&&c.push([s,l[0]]),s=Math.max(s,l[1]);return 1-s>1e-6&&c.push([s,1]),c.filter(([l,d])=>t*i*(d-l)>=e.seatPitch*.75)}function va(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((s,l)=>s+l,0),a=e.map(s=>o*s/i),r=a.map(s=>2+Math.floor(s)),c=t-r.reduce((s,l)=>s+l,0);return a.map((s,l)=>({index:l,fraction:s-Math.floor(s)})).sort((s,l)=>l.fraction-s.fraction||s.index-l.index).forEach(({index:s})=>{c-- >0&&r[s]++}),r}function at(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,c=Math.sign(e.endAngle-e.startAngle)||1,s=e.startAngle+c*e.taperDegrees*a+e.skewDegrees*a,l=e.endAngle-c*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(l-s)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(l-s)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=xa(e,r,s,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([p,m])=>r*Math.abs(l-s)*Y*(m-p)),b=e.fit==="fixed-count"?va(g,e.seatsPerRow):g.map(p=>Math.max(2,Math.round(p/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([p,m],x)=>{let I=s+(l-s)*p,h=s+(l-s)*m;e.facing==="outward"&&([I,h]=[h,I]);let y=b[x];if(y>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let w=Math.abs(h-I)*Y/(y-1),S=2*r*Math.sin(w/2),v={type:"row",id:n(i,x),label:U(e.rowLabelStart+i),origin:Sa(e.center,r,I),rotation:-I,curve:h-I,seatCount:y,seatSpacing:S,categoryKey:e.categoryKey,seatLabelStart:f,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:i,segmentIndex:x}};o.push(v),f+=y})}return o}function Bt(e,t){let n=it(e,t),o=C(e,t.floorId),i=at(n,"preview-arc-fan",(s,l)=>`preview-fan-${s}-${l}`),a=i.map(s=>s.seatSpacing),r=Math.max(...a.map(s=>Math.abs(s-n.seatPitch))),c=[];return r>n.seatPitch*.12&&c.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&c.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((s,l)=>s+l.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(s=>s>0).length,warnings:c}}function Ia(e,t){let n=it(e,t),o=C(e,t.floorId),i=new Set,a=A(e,"fan",t.idFactory,i),r=at(n,a,()=>A(e,"r",t.idFactory,i)),c=Bt(e,t),s=null,l=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(l){if(l.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=te(r);g&&(s=A(e,"sec",t.idFactory,i),d={type:"section",id:s,label:l,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:s,groupId:a,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function fo(e,t){let n=C(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.groupId),c={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},s=it(e,c),l=new Set(at(s,t.groupId,(g,b)=>`${g}:${b}`).map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return c}function Ca(e,t){fo(e,{floorId:t.floorId,groupId:t.groupId});let n=it(e,t),o=C(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),c=new Set,s=at(n,t.groupId,(m,x)=>r.get(`${m}:${x}`)??A(e,"r",t.idFactory,c)),l=Bt(e,t),d=t.sectionLabel?.normalize("NFKC").trim(),g=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let m=te(s);m&&(g={type:"section",id:a?.id??A(e,"sec",t.idFactory,c),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,x)=>b.has(m.id)?x:1/0)),p=o.objects.filter(m=>!b.has(m.id));return p.splice(Number.isFinite(f)?f:p.length,0,...s,...g?[g]:[]),o.objects.splice(0,o.objects.length,...p),{floorId:o.floorId,rowIds:s.map(m=>m.id),sectionId:g?.id??null,groupId:t.groupId,logicalRowCount:l.logicalRowCount,rowSegmentCount:l.rowSegmentCount,totalSeats:l.totalSeats,innerRadius:l.innerRadius,outerRadius:l.outerRadius,minSeatSpacing:l.minSeatSpacing,maxSeatSpacing:l.maxSeatSpacing,maxPitchDeviation:l.maxPitchDeviation,aisleCount:l.aisleCount,warnings:l.warnings}}function Oa(e){let t=new Set(z(e).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;t.has(U(n));)n+=1;let o=U(n);return t.add(o),n+=1,o}}function go(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function Ra(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.seatSpacing??24;if(!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)throw new u("invalid_operation","Row and seat spacing must be positive finite values");if(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=C(e,t.floorId),a=new Set,r=Oa(e),c=kt(t.rotation??0),s=t.curve??0,l=t.style,d=l?A(e,"rowblock",t.idFactory,a):void 0,g=l?go({style:l,origin:t.origin,rotation:c,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:s}):void 0,b={x:Math.cos(c*J),y:Math.sin(c*J)},f={x:-b.y,y:b.x},p=Array.from({length:t.rowCount},(I,h)=>{let y=l==="intertwined"&&h%2===1?o/2:0,w={type:"row",id:A(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+f.x*h*n+b.x*y,y:t.origin.y+f.y*h*n+b.y*y},rotation:c,curve:s,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&g&&(w.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:c,rowGap:n,seatSpacing:o,curve:s,signature:g}),w});i.objects.push(...p);let m=null,x=t.sectionLabel?.trim();if(x){let I=te(p);if(I){let h={type:"section",id:A(e,"sec",t.idFactory,a),label:x,outline:I};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:p.map(I=>I.id),sectionId:m,createdIds:[...p.map(I=>I.id),...m?[m]:[]]}}function bo(e,t){let n=new Set(z(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(i=>typeof i=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let i=`${t}${o}`;return n.add(i),o+=1,i}}function Pa(e,t){let n=new Set(z(e).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var _a=456;function ho(e){let t=Math.sqrt(Math.max(1,e)*_a);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Aa(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=C(e,t.floorId),o=new Set,{width:i,height:a}=ho(t.capacity),r=Pa(e,(t.label??"General Admission").trim()||"General Admission"),c={type:"gaArea",id:A(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(c),{floorId:n.floorId,gaAreaId:c.id,label:r,createdIds:[c.id]}}function Ma(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.gapY??150;if(!Number.isFinite(n)||n<80||!Number.isFinite(o)||o<80)throw new u("invalid_operation","Table spacing must be at least 80 chart units");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"T"),c=[];for(let s=0;s<t.tableRows;s+=1)for(let l=0;l<t.tableColumns;l+=1)c.push({type:"table",id:A(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.tableColumns-1)/2)*n,y:t.center.y+(s-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...c),{floorId:i.floorId,tableIds:c.map(s=>s.id),createdIds:c.map(s=>s.id)}}function ja(e,t){if(j(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.gapY??82;if(!Number.isFinite(n)||n<62||!Number.isFinite(o)||o<52)throw new u("invalid_operation","Booth spacing must clear the 62\xD752 booth footprint");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=C(e,t.floorId),a=new Set,r=bo(e,"B"),c=[];for(let s=0;s<t.boothRows;s+=1)for(let l=0;l<t.boothColumns;l+=1)c.push({type:"booth",id:A(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(l-(t.boothColumns-1)/2)*n,y:t.center.y+(s-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...c),{floorId:i.floorId,boothIds:c.map(s=>s.id),createdIds:c.map(s=>s.id)}}function La(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,c=r.filter(b=>b.segmentedRow);if(c.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:c.map(b=>b.id)});let s=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!s||s.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let l=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=t.idFactory("rowgroup");if(f&&!l.has(f)){d=f;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let g=r[0];return r.forEach((b,f)=>{b.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:f,componentCount:r.length,boundaryBefore:f===0?"start":t.boundaries[f-1],displayLabel:s,...g.displayType?{displayType:g.displayType}:{},...g.labelPresentation?{labelPresentation:structuredClone(g.labelPresentation)}:{},...g.viewFromSeatUrl?{viewFromSeatUrl:g.viewFromSeatUrl}:{},...g.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(g.viewFromSeatMeta)}:{},...g.confidenceEvidence?{confidenceEvidence:structuredClone(g.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function ka(e,t){let n=C(e,t.floorId),o=t.groupId?n.objects.find(c=>c.type==="row"&&c.segmentedRow?.groupId===t.groupId):n.objects.find(c=>c.type==="row"&&c.id===t.rowId),i=t.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(c=>c.type==="row"&&c.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((c,s)=>c.segmentedRow.componentIndex-s.segmentedRow.componentIndex).map(c=>c.id);for(let c of a)delete c.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function Ea(e,t){let n=C(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.groupId).sort((r,c)=>r.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(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=t.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,c)=>{let s=r.segmentedRow,l=s.viewFromSeatUrl;i!==void 0&&(s.displayLabel=i),t.boundaries&&c>0&&(s.boundaryBefore=t.boundaries[c-1]),t.smoothing!==void 0&&(s.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete s.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(s.viewFromSeatUrl=t.viewFromSeatUrl),!s.viewFromSeatUrl||t.viewFromSeatMeta===null?delete s.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?s.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&s.viewFromSeatUrl!==l&&delete s.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ta(e,t){let n=C(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,$)=>R.rowBlockGeneration.rowIndex-$.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((R,$)=>{let M=R.rowBlockGeneration;return M.kind!=="row-block-v1"||M.rowIndex!==$||M.signature!==i.signature||JSON.stringify(M)!==JSON.stringify({...i,rowIndex:$})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,c=t.rowCount??i.rowCount,s=t.seatsPerRow??i.seatsPerRow,l=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?kt(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.origin}:{...i.origin};if(!Number.isInteger(c)||c<1||c>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(s)||s<1||s>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![l,d].every(R=>Number.isFinite(R)&&R>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let p=go({style:r,origin:f,rotation:b,rowCount:c,seatsPerRow:s,rowGap:l,seatSpacing:d,curve:g}),m={x:Math.cos(b*J),y:Math.sin(b*J)},x={x:-m.y,y:m.x},I=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),h=new Set,y=new Set(n.objects.filter(R=>R.type==="row").filter(R=>!o.includes(R)).map(R=>R.label)),w=n.objects.filter(R=>R.type==="row").length,S=()=>{for(;y.has(U(w));)w+=1;let R=U(w);return y.add(R),w+=1,R},v=[],P=[];for(let R=0;R<c;R+=1){let $=r==="intertwined"&&R%2===1?d/2:0,M=I.get(R);M||(M={type:"row",id:A(e,"r",t.idFactory,h),label:S(),origin:{...f},rotation:b,curve:g,seatCount:s,seatSpacing:d,categoryKey:o[0].categoryKey},P.push(M.id)),M.origin={x:f.x+x.x*R*l+m.x*$,y:f.y+x.y*R*l+m.y*$},M.rotation=b,M.curve=g,M.seatCount=s,M.seatSpacing=d,delete M.path,delete M.arcFanGeneration,M.overrides&&(M.overrides=M.overrides.filter(bt=>bt.index<s),M.overrides.length||delete M.overrides),M.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:R,rowCount:c,seatsPerRow:s,origin:{...f},rotation:b,rowGap:l,seatSpacing:d,curve:g,signature:p},v.push(M)}let K=o.slice(c).map(R=>R.id),N=Math.min(...o.map(R=>n.objects.indexOf(R))),H=new Set(o.map(R=>R.id)),G=n.objects.filter(R=>!H.has(R.id));return G.splice(N,0,...v),n.objects.splice(0,n.objects.length,...G),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(R=>R.id),createdRowIds:P,removedRowIds:K,changed:a!==JSON.stringify(v)||P.length>0||K.length>0}}function zt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Ut(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Ht(e){return Ut(zt(e),40)}function po(e,t=39){return Ut(zt(e),Math.max(1,t))}function be(e,t=80){return Ut(zt(e),Math.max(1,t))}function yo(e){return be(e).toLocaleLowerCase("en")}function Vt(e){return yo(e)}function mo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Fa(e){let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(X(e,o,i))}return n}function Na(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=mo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(i?.label??`${e.label}-${o+1}`)}return n}function Da(e){return e.type==="row"?[e.label,...Fa(e)]:e.type==="table"?[e.label,...Na(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...Q(e)]:[]}function wo(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of Da(o)){let a=Vt(i);a&&n.add(a)}return n}function Ka(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Vt(e)];for(let i=0;i<t;i+=1)o.push(Vt(X(n,i)));return o.filter(Boolean)}function So(e,t,n){let o=Ka(t,n);if(!o.length||o.some(i=>e.has(i)||Ae(i)))return!1;for(let i of o)e.add(i);return!0}var Ga=1e-6,$a=160,Ba=.001,za=1e-5;function he(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>$a)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function xo(e){return typeof e=="string"&&po(e)||void 0}function vo(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(qt(e.origin)&&qt(t.start)&&qt(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},i=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Ba+Math.max(1,i)*za;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||i<=Ga)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let c=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,s=Math.abs(((e.rotation-c)%360+540)%360-180),l=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return s<=l}function qt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var Ua=300;function Ha(e){let t=new Set(z(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(U(n));)n+=1;let i=U(n);return n+=1,t.add(i),i};return i=>{let a=Ht(i),r=0;return()=>{for(;a&&r<4096;r+=1){let c=`${a}-${U(r)}`;if(!t.has(c))return t.add(c),r+=1,c}return o()}}}function Va(e){let t=wo(z(e));return(n,o)=>{let i=be(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,c=r?`${be(i,80-r.length)}${r}`:i;if(c&&So(t,c,o))return c}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function qa(e){return{ordinaryFor:Ha(e),direct:Va(e)}}function Io(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Ja(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[c,s]of r.rows.entries()){let l=he(`${r.sourceGroupId}:${c}`),d=l&&he(s.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:s)}let i=new Map;for(let r of e){let c=he(r.referenceScan?.directSourceRowId);if(!c){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let s=i.get(c)??[];s.push(r),i.set(c,s)}let a=new Map;for(let[r,c]of i){let s=c.filter(b=>b.overrides?.length);if(!s.length)continue;let l=o.get(r),d=s[0],g=d.overrides;if(c.length!==1||s.length!==1||!g||!l||!vo(d,l))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:c.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function Co(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!(o.type==="row"&&o.referenceScan?.assetId===t&&(!n||o.referenceScan.sectionId===n)))}function Xa(e,t,n,o,i,a,r){let c=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(c){let d=Co(t,n,r).filter(g=>F(L(g),c.outline,c.holes));if(d.length)return{skip:{sectionId:c.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let s=[],l=0;for(let[d,g]of e.rows.entries()){let b=Math.min(Ua,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,p=g.end.y-g.start.y,m=Math.hypot(f,p),x=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let I=m>0?Math.atan2(p,f)*180/Math.PI:0,h=e.sourceGroupId?he(`${e.sourceGroupId}:${d}`):void 0,y=h&&he(g.directSourceRowId)===h?h:void 0,w=y?xo(g.directReviewedSuffix):void 0,S=e.sourceGroupId&&g.rowLabel?be(g.rowLabel):"",v=e.sourceGroupId&&g.rowDisplayLabel?be(g.rowDisplayLabel):"",P=!!e.sourceGroupId&&g.rowDisplayLabel==="";s.push({label:S?a(S,b):i(),displayLabel:v||(P?"":String(d+1)),origin:{x:g.start.x,y:g.start.y},rotation:I,seatCount:b,seatSpacing:x,...y?{directSourceRowId:y}:{},...w?{directReviewedSuffix:w}:{}}),l+=b}return{skip:null,rows:s,seats:l}}function Ya(e,t,n){j(e,n.categoryKey);let o=C(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let y=n.categoryKeyForSection?.(h)??n.categoryKey;j(e,y),r.set(h,y)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let c=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&c){let h=Co(o.objects,i,a.id).filter(y=>F(L(y),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:c.name,reason:"section_not_empty",objectIds:h.map(y=>y.id)}]}}let s=o.objects.filter(h=>Io(h,i,a?.id)),l=Ja(s,t,a?.id),d=[],g=o.objects.filter(h=>Io(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],p=[],m=new Set,x=0,I=qa(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let y=Xa(h,o.objects,i,t.seatPitch,I.ordinaryFor(h.name),I.direct,a?.id);if(y.skip){f.push(y.skip);continue}let w=y.rows.map(S=>({type:"row",id:A(e,"r",n.idFactory,m),referenceScan:{assetId:i,...h.sectionId?{sectionId:h.sectionId}:{},...S.directSourceRowId?{directSourceRowId:S.directSourceRowId}:{},...S.directReviewedSuffix?{directReviewedSuffix:S.directReviewedSuffix}:{}},label:S.label,...S.displayLabel!==void 0?{displayLabel:S.displayLabel}:{},origin:S.origin,rotation:S.rotation,curve:0,seatCount:S.seatCount,seatSpacing:S.seatSpacing,categoryKey:r.get(h)??n.categoryKey,...S.directSourceRowId&&l.has(S.directSourceRowId)?{overrides:structuredClone(l.get(S.directSourceRowId))}:{}}));o.objects.push(...w);for(let S of w)p.push(S.id);b.push({sectionId:h.sectionId,name:h.name,seats:y.seats,rows:w.length}),x+=y.seats}return{floorId:o.floorId,assetId:i,createdRowIds:p,removedRowIds:d,totalSeats:x,perSection:b,skipped:f}}function Oo(e,t){let n=C(e,t.floorId),o=[...new Set(t.objectIds)];if(!o.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let i=o.map(f=>n.objects.find(p=>(p.type==="table"||p.type==="booth")&&p.id===f)),a=o.filter((f,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:a});let r=i[0].type;if(i.some(f=>f.type!==r))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[f,p,m]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(p)||p<1||p>m)throw new u("invalid_operation",`${f} must be a whole number from 1 to ${m}`);for(let[f,p]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(p)||p<30||p>2e3)throw new u("invalid_operation",`${f} 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 s=o.length*(c-1);if(s>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let l=i.reduce((f,p)=>f+(p.type==="table"?p.seatCount:1),0),g=(e.floors?.length?e.floors.flatMap(f=>f.objects):e.objects).reduce((f,p)=>f+(p.type==="row"||p.type==="table"?p.seatCount:p.type==="gaArea"?Math.max(0,Math.floor(p.capacity)):p.type==="booth"?1:0),0),b=l*(c-1);if(g+b>fe)throw new u("invalid_operation",`Grid inventory would exceed the ${fe} unit event limit`);return{target:n,sources:i,preview:{floorId:n.floorId,kind:r,sourceIds:o,sourceCount:o.length,cells:c,createdCount:s,addedInventory:b,resultingInventory:g+b,provenanceRemovedCount:i.filter(f=>!!f.referenceInventorySource).length*(c-1)}}}function Qa(e,t){return Oo(e,t).preview}function Wa(e,t){let{target:n,sources:o,preview:i}=Oo(e,t),a=new Set,r=new Set((e.floors?.length?e.floors.flatMap(d=>d.objects):e.objects).flatMap(d=>"label"in d&&d.label?[d.label]:[])),c=[],s=(d,g)=>{let b=Math.max(2,g),f=m=>{let x=`-${m}`;return`${d.slice(0,Math.max(1,80-x.length))}${x}`},p=f(b);for(;r.has(p);)p=f(++b);return r.add(p),p},l=1;for(let d=0;d<t.rows;d++)for(let g=0;g<t.columns;g++)if(!(d===0&&g===0)){l+=1;for(let b of o){let f=structuredClone(b);f.id=A(e,f.type,t.idFactory,a),f.label=s(b.label,l),f.center={x:b.center.x+g*t.stepX,y:b.center.y+d*t.stepY},delete f.referenceInventorySource,c.push(f)}}return n.objects.push(...c),{...i,createdIds:c.map(d=>d.id)}}function Za(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=k(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var es=new Set(Pe.map(e=>e.key));function Ee(e){return`${e.rowId}:${e.index}`}function ts(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 ns(e,t){e.label||delete e.label,e.displayLabel||delete e.displayLabel,e.dx||delete e.dx,e.dy||delete e.dy,e.skip||delete e.skip,e.categoryKey||delete e.categoryKey,ke(e.glyph)||delete e.glyph;let n=Ie(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),i={};typeof e.commercial.restrictedView=="boolean"&&(i.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(i.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(i.premium=e.commercial.premium),o&&(i.note=o),Object.keys(i).length?e.commercial=i:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&He(t,e)}function os(e){return Object.keys(e).every(t=>t==="index")}function Ro(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(e,t),i=[],a=new Set,r=new Map;for(let c of n){let s=Ee(c);if(a.has(s))continue;a.add(s);let l=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===c.rowId);if(!l)throw new u("object_not_found",`Unknown row or table for seat: ${s}`,{seatId:s,objectId:c.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:s,tableId:l.id});if(!Number.isInteger(c.index)||c.index<0||c.index>=l.seatCount)throw new u("invalid_operation",l.type==="row"?`Seat index is outside row bounds: ${s}`:`Chair index is outside table bounds: ${s}`,{seatId:s,objectId:c.rowId,index:c.index,seatCount:l.seatCount});i.push({rowId:c.rowId,index:c.index}),r.set(l.id,l)}return{floorId:o.floorId,refs:i,owners:r}}function Jt(e,t){let n=Ro(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.patch.label!=null)throw new u("invalid_operation","A literal label can only be assigned to one seat; use labelPrefix for a bulk sequence");if(n.refs.length>1&&t.patch.displayLabel!=null)throw new u("invalid_operation","A literal display label can only be assigned to one seat; use displayLabelPrefix for a bulk sequence");if(t.patch.categoryKey&&j(e,t.patch.categoryKey),t.patch.glyph!=null&&!ke(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(r=>!es.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),c=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,s=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(c&&s)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Ee(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=Z(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&ue(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let c=n.owners.get(a.rowId),s=JSON.stringify(c.overrides??[]),l=c.overrides??(c.overrides=[]),d=l.find(b=>b.index===a.index);d||(d={index:a.index},l.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(p=>p!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let p=Za(d.labelStyle,f);p?d.labelStyle=p:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),ns(d,c),os(d)&&(c.overrides=l.filter(b=>b!==d)),c.overrides?.length||delete c.overrides,JSON.stringify(c.overrides??[])!==s&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map(Ee)}}function rs(e,t){let n=Ro(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(s=>s.rowId===i).map(s=>s.index)),c=a.overrides.filter(s=>!r.has(s.index));c.length!==a.overrides.length&&(o=!0),a.overrides=c,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map(Ee)}}function is(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(y=>y.type==="row"&&y.id===h)),a=o.filter((h,y)=>!i[y]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&j(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,y=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!y.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${y.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:c,labelRotation:s,labelStyleShape:l,displayLabel:d,displayType:g,...b}=t.patch,f=d===void 0?{}:{displayLabel:d},p=de(f,"Row"),m=g===void 0?void 0:Rt(g,"Row");if(r!==void 0&&ue(r,"Row"),c!==void 0&&!["start","end","both","none"].includes(c))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(s!=null&&(!Number.isFinite(s)||s<-180||s>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(l!==void 0&&l!=="plain"&&l!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&Je(b.labelPresentation,"Row");let x=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),I=!1;for(let h of i){let y=JSON.stringify(h),w=x(h),S=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?L(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(v=>v.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),S){let v=L(h);h.origin={x:h.origin.x+S.x-v.x,y:h.origin.y+S.y-v.y}}if(JSON.stringify(h)!==y&&(I=!0),x(h)!==w&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=Xe(h.labelPresentation,r);P?h.labelPresentation=P:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(c!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};P.positionPreset=c,P.visible=c!=="none",delete P.position,h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(s!==void 0||l!==void 0){let v=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};s===null?delete P.rotation:s!==void 0&&(P.rotation=s),l!==void 0&&(P.style=l),h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==v&&(I=!0)}if(m!==void 0){let v=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==v&&(I=!0)}if(d!==void 0){let v=h.displayLabel;p?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==v&&(I=!0)}}return{floorId:n.floorId,changed:I,rowIds:o}}var as=3;function st(e){return(e%360+360)%360}function ss(e){let t=e.rotation*J;return{x:Math.cos(t),y:Math.sin(t)}}function cs(e,t){let n=Math.abs(st(e-t));return n>180&&(n=360-n),n}function pe(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Po(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*J;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function ls(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=i=>({x:i.x+t,y:i.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function _o(e,t){let n=Po(e),o={x:-n.y,y:n.x},i=L(e[0]),a=e.map(s=>({row:s,coord:pe(L(s),i,o)})).sort((s,l)=>s.coord-l.coord),r=a[0].coord,c=!1;return a.forEach((s,l)=>{let d=r+l*t-s.coord;Math.abs(d)>1e-6&&(ls(s.row,o.x*d,o.y*d),delete s.row.arcFanGeneration,delete s.row.rowBlockGeneration,c=!0)}),c}function ds(e,t){let n={x:-t.y,y:t.x},o=L(e[0]),i=e.map(r=>pe(L(r),o,n)).sort((r,c)=>r-c);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function us(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Ce(e),n=t[0],o=t[t.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,r/(e.seatCount-1))),r>1e-6&&(e.rotation=st(Math.atan2(a,i)/J)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function fs(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${t}${o}`.slice(0,80);if(!n.has(i))return i}return`${t}-${Date.now().toString(36)}`}function gs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(v=>v.type==="row"&&v.id===S)),a=o.filter((S,v)=>!i[v]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,c=r.filter(S=>S.path||S.curve!==0);if(c.length)throw new u("invalid_operation","Only straight rows can be merged \u2014 straighten the rows first, then merge.",{rowIds:c.map(S=>S.id)});let s=r[0],l=r.find(S=>cs(S.rotation,s.rotation)>as);if(l)throw new u("invalid_operation","Rows must be parallel to merge \u2014 they point in different directions.",{rowIds:[s.id,l.id]});let d=ss(s),g={x:-d.y,y:d.x},b=Math.max(8,s.seatSpacing*.6),f=r.find(S=>Math.abs(pe(S.origin,s.origin,g))>b);if(f){let S=Math.round(Math.abs(pe(f.origin,s.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge \u2014 a selected row is offset ${S} units from the first.`,{rowIds:[s.id,f.id]})}let p=r.slice().sort((S,v)=>pe(S.origin,s.origin,d)-pe(v.origin,s.origin,d)),m=p.reduce((S,v)=>S+v.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let x=p[0],I=[],h=0;for(let S of p){if(S.overrides)for(let v of S.overrides)I.push({...structuredClone(v),index:v.index+h});h+=S.seatCount}x.seatCount=m,x.curve=0,delete x.path,I.length?x.overrides=I:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let y=p.slice(1).map(S=>S.id),w=new Set(y);for(let S=n.objects.length-1;S>=0;S--)w.has(n.objects[S].id)&&n.objects.splice(S,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:y,seatCount:m}}function bs(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="row"&&f.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row \u2014 straighten it first, then split.",{rowIds:[o.id]});let i=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>i-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${i-1} (the seat where the second row begins)`);let r=Ce(o),c=i>1?o.curve/(i-1):0,s=i-a,l={type:"row",id:A(e,"r",t.idFactory,new Set),label:fs(n.objects,o.label),origin:{...r[a]},rotation:st(o.rotation-c*a),curve:c*(s-1),seatCount:s,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(l.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(l.seatLabelStart=o.seatLabelStart),o.commercial&&(l.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(l.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(l.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(l.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,l.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=c*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(l.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:s,newLabel:l.label}}function hs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(c=>n.objects.find(s=>s.type==="row"&&s.id===c)),a=o.filter((c,s)=>!i[s]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=_o(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function ps(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,c=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),s=c();for(let b of r)us(b);let l=Po(r),d=st(Math.atan2(l.y,l.x)/J);for(let b of r)b.rotation=d;let g=ds(r,l);return _o(r,g),{floorId:n.floorId,changed:c()!==s,rowIds:o,gap:g}}var lt=tr(require("polygon-clipping"),1),Ao=100,Mo=512,Xt=8192,Do=64,jo=1e7,E=1e-7;function Ko(e,t){return Math.abs(e.x-t.x)<=E&&Math.abs(e.y-t.y)<=E}function Go(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ko(t[0],t[t.length-1]);)t.pop();return t}function Te(e,t,n){let o=q(t,n,e);return Math.abs(o)>E?!1:e.x>=Math.min(t.x,n.x)-E&&e.x<=Math.max(t.x,n.x)+E&&e.y>=Math.min(t.y,n.y)-E&&e.y<=Math.max(t.y,n.y)+E}function $o(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),c=q(n,o,t);return(i>E&&a<-E||i<-E&&a>E)&&(r>E&&c<-E||r<-E&&c>E)?!0:Math.abs(i)<=E&&Te(n,e,t)||Math.abs(a)<=E&&Te(o,e,t)||Math.abs(r)<=E&&Te(e,n,o)||Math.abs(c)<=E&&Te(t,n,o)}function ys(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&$o(e[t],e[n],e[o],e[i]))return!0}}return!1}function Lo(e,t){return e.some((n,o)=>t.some((i,a)=>$o(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function Yt(e,t){return!t.some((n,o)=>Te(e,n,t[(o+1)%t.length]))&&F(e,t,void 0)}function dt(e,t,n){let o=Go(e);if(o.length<3||o.length>Mo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>jo||Math.abs(i.y)>jo||Ko(i,o[(a+1)%o.length]))||Math.abs(Se(o))<=E||ys(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Mo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function ms(e){let t=dt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Do)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>dt(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((c,s)=>{let l=a[(s+1)%a.length];return[c,{x:(c.x+l.x)/2,y:(c.y+l.y)/2}]}).every(c=>Yt(c,t))||Lo(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let c=i+1;c<o.length;c+=1)if(Lo(a,o[c])||Yt(a[0],o[c])||Yt(o[c][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function ct(e){return e.map(t=>[t.x,t.y])}function ko(e){return Go(e.map(([t,n])=>({x:t,y:n})))}function Eo(e){return Math.abs(e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n[0]*i[1]-i[0]*n[1]},0))/2}function ws(e){return e.reduce((t,n)=>t+(Eo(n[0]??[])-n.slice(1).reduce((o,i)=>o+Eo(i),0)),0)}function Qt(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Qt).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Qt(t[n])}`).join(",")}}`}function To(e,t,n){let o=e[t];if(o===void 0)return null;let i=o.normalize("NFKC").trim();if(!i||i!==o||i.length>n)throw new u("invalid_operation",`GA area ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return i}function Fo(e){return Qt({categoryKey:e.categoryKey,displayLabel:To(e,"displayLabel",80),displayType:To(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function No(e,t){let n=Math.min(...e.points.map(i=>i.y)),o=Math.min(...e.points.map(i=>i.x));return[n,o,t]}function Ss(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function Bo(e,t){let n=C(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(o.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(o.length>Ao)throw new u("invalid_operation",`Join Areas supports at most ${Ao} areas at once`);let i=o.map(O=>n.objects.find(_=>_.type==="gaArea"&&_.id===O)),a=o.filter((O,_)=>!i[_]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=i;j(e,r[0].categoryKey);let c=Fo(r[0]),s=r.find(O=>Fo(O)!==c);if(s)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[r[0].id,s.id]});let l=Me(e).objectToSection,d=l.get(r[0].id)??"__ungrouped__",g=r.find(O=>(l.get(O.id)??"__ungrouped__")!==d);if(g)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[r[0].id,g.id],sectionIds:[d,l.get(g.id)??"__ungrouped__"]});let b=r.reduce((O,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>oe)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return O+_.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 f=z(e).reduce((O,_)=>O+ne(_),0);if(f>fe)throw new u("invalid_operation",`Chart inventory exceeds the ${fe}-unit publication limit`,{inventory:f});let p=r.map(ms),m=p.reduce((O,_)=>O+_.outer.length+_.holes.reduce((V,W)=>V+W.length,0),0);if(m>Xt)throw new u("invalid_operation",`Join Areas supports at most ${Xt} source vertices`,{vertexCount:m});let x;try{let O=p.map(W=>[ct(W.outer)]);if(x=lt.default.union(O[0],...O.slice(1)),x.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:x.length});let _=p.flatMap(W=>W.holes.map(ht=>[ct(ht)]));_.length&&(x=lt.default.difference(x,..._));let V=p.findIndex(W=>{let ht=[ct(W.outer),...W.holes.map(ct)];return ws(lt.default.intersection(ht,x))<=E});if(V>=0)throw new u("invalid_operation",`GA area ${r[V].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:r[V].id})}catch(O){throw O instanceof u?O:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:O instanceof Error?O.message:"polygon_union_failed"})}if(x.length!==1||!x[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:x.length});let I=ko(x[0][0]),h=x[0].slice(1).map(ko),y=I.length+h.reduce((O,_)=>O+_.length,0);if(h.length>Do||y>Xt)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:h.length,vertexCount:y});dt(I,"outline",r[0].id),h.forEach(O=>dt(O,"cutout",r[0].id));let w=new Map(n.objects.map((O,_)=>[O.id,_])),S=r.slice().sort((O,_)=>Ss(No(O,w.get(O.id)??Number.MAX_SAFE_INTEGER),No(_,w.get(_.id)??Number.MAX_SAFE_INTEGER))),v=S[0],P=structuredClone(e),K=C(P,n.floorId),N=K.objects.find(O=>O.type==="gaArea"&&O.id===v.id);N.points=structuredClone(I),h.length?N.holes=structuredClone(h):delete N.holes;let H=new Set(S.slice(1).map(O=>O.id));for(let O=K.objects.length-1;O>=0;O-=1)H.has(K.objects[O].id)&&K.objects.splice(O,1);let G=Me(P).objectToSection.get(v.id)??"__ungrouped__";if(G!==d)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:v.id,beforeSectionId:d,afterSectionId:G});let R=[],$=new Set;for(let O of S){if(!jt(O))throw new u("invalid_operation",`GA area ${O.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:O.id});let _=Q(O);if(_.length!==O.capacity||_.some(V=>$.has(V)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:O.id});_.forEach(V=>$.add(V)),R.push(...Ze(O))}if(R.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let M=new Set(r.map(O=>O.id));for(let O of z(e).filter(_=>_.type==="gaArea"&&!M.has(_.id))){let _=Q(O).find(V=>$.has(V));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:O.id})}let bt=S.slice(1).map(O=>O.id);return{floorId:n.floorId,areaId:v.id,survivorLabel:v.label,removedAreaIds:bt,sourceAreaCount:S.length,capacity:b,inventorySegmentCount:R.length,outerVertexCount:I.length,holeCount:h.length,sectionId:d,points:I,...h.length?{holes:h}:{},segments:R}}function xs(e,t){let{segments:n,...o}=Bo(e,t);return o}function vs(e,t){let n=Bo(e,t),o=C(e,n.floorId),i=o.objects.find(s=>s.type==="gaArea"&&s.id===n.areaId);i.points=structuredClone(n.points),n.holes?.length?i.holes=structuredClone(n.holes):delete i.holes,i.capacity=n.capacity,i.inventorySegments=structuredClone(n.segments);let a=new Set(n.removedAreaIds);for(let s=o.objects.length-1;s>=0;s-=1)a.has(o.objects[s].id)&&o.objects.splice(s,1);let{segments:r,...c}=n;return{...c,changed:!0}}function Is(e,t){let n=C(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.labelStyle!==void 0){let l=i.filter(d=>d.role!=="stage");if(l.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:l.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<le||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${le} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=k(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");for(let d of["bold","italic","underline"]){let g=r.labelStyle[d];if(g!=null&&typeof g!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=k(r.fill,"Shape fill")),r.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(r.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(r.stroke!==void 0&&r.stroke!==null){if(!Number.isFinite(r.stroke.width)||r.stroke.width<.5||r.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");r.stroke={color:k(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let l=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!l.length||l.length>20||l.some(d=>!d||d.length>100)||new Set(l).size!==l.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=l}if(r.lineCap!==void 0&&r.lineCap!==null&&!to.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!no.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!oo.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let l=i.filter(d=>!Gt(r.kind??d.kind));if(l.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:l.map(d=>d.id)})}let s=!1;for(let l of i){let d=JSON.stringify(l);if(r.label===null?delete l.label:r.label!==void 0&&(l.label=r.label),r.labelStyle!==void 0){let g={...l.labelStyle};r.labelStyle.size===null?delete g.size:r.labelStyle.size!==void 0&&(g.size=r.labelStyle.size),r.labelStyle.color===null?delete g.color:r.labelStyle.color!==void 0&&(g.color=r.labelStyle.color),r.labelStyle.fontFamily===null?delete g.fontFamily:r.labelStyle.fontFamily!==void 0&&(g.fontFamily=r.labelStyle.fontFamily),r.labelStyle.bold===null?delete g.bold:r.labelStyle.bold!==void 0&&(g.bold=r.labelStyle.bold),r.labelStyle.italic===null||r.labelStyle.italic===!1?delete g.italic:r.labelStyle.italic===!0&&(g.italic=!0),r.labelStyle.underline===null||r.labelStyle.underline===!1?delete g.underline:r.labelStyle.underline===!0&&(g.underline=!0),Object.keys(g).length?l.labelStyle=g:delete l.labelStyle}if(r.fill===null?delete l.fill:r.fill!==void 0&&(l.fill=r.fill),r.kind!==void 0&&(l.kind=r.kind,Gt(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),r.stroke===null?delete l.stroke:r.stroke!==void 0&&(l.stroke={...r.stroke}),r.opacity===null?delete l.opacity:r.opacity!==void 0&&(l.opacity=r.opacity),r.heightM===null?delete l.heightM:r.heightM!==void 0&&(l.heightM=r.heightM),r.eventConfigurationIds===null?delete l.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete l.lineCap:r.lineCap!==void 0&&(l.lineCap=r.lineCap),r.lineJoin===null?delete l.lineJoin:r.lineJoin!==void 0&&(l.lineJoin=r.lineJoin),r.startEnding===null?delete l.startEnding:r.startEnding!==void 0&&(l.startEnding=r.startEnding),r.endEnding===null?delete l.endEnding:r.endEnding!==void 0&&(l.endEnding=r.endEnding),r.cornerRadius===null)delete l.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(l.width??1/0,l.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(l)!==d&&(Be(l),s=!0)}return{floorId:n.floorId,changed:s,shapeIds:o}}function Uo(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),c=Math.max(...o),s=Math.max(1,a-i),l=Math.max(1,c-r);return{cx:i+s/2,cy:r+l/2,width:s,height:l}}function Cs(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let c=n.objects.find(l=>l.type==="shape"&&l.id===r.shapeId);if(!c)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let s=c.role==="stage"?Uo(c):(c.kind==="rect"||c.kind==="ellipse")&&c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null?{cx:c.x+c.width/2,cy:c.y+c.height/2,width:c.width,height:c.height}:(()=>{let l=c.points??[];if(l.length<3||l.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${c.id} has no resizable geometry`,{shapeId:c.id});let d=l.map(x=>x.x),g=l.map(x=>x.y),b=Math.min(...d),f=Math.max(...d),p=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(p+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-p)}})();return{shape:c,update:r,box:s}}),a=!1;for(let{shape:r,update:c,box:s}of i)if(!(Math.abs(s.width-c.width)<1e-9&&Math.abs(s.height-c.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=s.cx-c.width/2,r.y=s.cy-c.height/2,r.width=c.width,r.height=c.height;else{let l=c.width/s.width,d=c.height/s.height;r.points=(r.points??[]).map(g=>({x:s.cx+(g.x-s.cx)*l,y:s.cy+(g.y-s.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=s.cx-c.width/2,r.y=s.cy-c.height/2,r.width=c.width,r.height=c.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:c})=>({id:r.id,width:c.width,height:c.height}))}}function Os(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(c=>c.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(hn.map(c=>c.key)),a=t.updates.map(c=>{if(!i.has(c.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${c.stageKind}`,{stageKind:c.stageKind});let s=n.objects.find(l=>l.type==="shape"&&l.id===c.stageId);if(!s)throw new u("object_not_found",`Unknown stage id: ${c.stageId}. Call get_chart to list current stage ids.`,{stageId:c.stageId});if(s.role!=="stage")throw new u("invalid_operation",`Shape ${c.stageId} is not tagged as a stage`,{stageId:c.stageId});return{shape:s,stageKind:c.stageKind,box:s.stageKind===c.stageKind?null:Uo(s)}}),r=!1;for(let c of a)c.box&&(c.shape.points=pn({kind:c.stageKind,...c.box}),c.shape.kind="polygon",c.shape.stageKind=c.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(c=>({id:c.shape.id,stageKind:c.stageKind}))}}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 i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function ut(e){return Array.isArray(e)?e.map(ut):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,ut(n)]))}function Ps(e,t){return JSON.stringify(ut(e))===JSON.stringify(ut(t))}function Wt(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function _s(e){return e?e.status==="retracted"?"retract":Wt(e)?"approve":"set":"clear"}function Vo(e,t){let n=Ho(e),o=Ho(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let c=n.get(r),s=o.get(r);if(c&&s&&Ps(c.evidence,s.evidence))continue;let l=s?.target??c?.target;l&&a.push({...l,operation:_s(s?.evidence),...c?{before:c.evidence}:{},...s?{after:s.evidence}:{}})}return a}function As(e,t){return Vo(e,t).some(n=>Wt(n.before)||Wt(n.after))}var Ms=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),js=new Set(["generated","geometry-verified","configuration-verified"]),Ls=new Set(["none","comparable-build-reference","actual-build-checked"]),ks=new Set(["clear","partial","obstructed"]);function Zt(e){return e.toISOString().slice(0,10)}function en(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function me(e,t,n){if(!en(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function ye(e,t,n){if(e!==void 0)return me(e,t,n)}function ft(e,t,n){let o=n?[C(e,n)]:T(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function qo(e,t){let n=T(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Fe(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return qo(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(i=>i.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=ft(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function gt(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=qo(e,t.floorId);return n?i.confidenceEvidence=n:delete i.confidenceEvidence,{floorId:i.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let i=ft(e,t.objectId,t.floorId);return Jt(e,{floorId:i.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:i.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=ft(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function Es(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!en(e.label,80)||!en(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!ks.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>me(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function Jo(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(!Ms.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!js.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Ls.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=ye(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let i=e.limitations?.map(d=>me(d,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=ye(e.assessedAt,40,"assessedAt")??Zt(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let c=ye(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Zt(new Date(r+365*24*60*60*1e3))),s=c?Date.parse(c):Number.NaN;if(c&&(!Number.isFinite(s)||s<r||s>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=ye(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");return{schema:"seatlayer.seat-confidence/1",evidenceId:me(e.evidenceId,120,"evidenceId"),modelVersion:me(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...c?{validUntil:c}:{},...l?{approvedByRole:l}:{},...ye(e.sourceLabel,120,"sourceLabel")?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:Es(e.modeledTarget)}:{}}}function we(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function Ts(e,t){let n=Jo(t.evidence,t.now),o=JSON.stringify(Fe(e,t)??null),i=gt(e,t,n),a=JSON.stringify(Fe(e,t)??null);return we(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function Fs(e,t){let n=Fe(e,t);if(!n)return we(t,{changed:!1});let o=gt(e,t,void 0);return we(t,{changed:!0,...o,evidenceId:n.evidenceId})}function Ns(e,t){let n=Fe(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=me(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=ye(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!i)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let r={...n,status:"approved",approvedByRole:o,assessedAt:Zt(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let c=t.basisSha256??e.confidenceBasisSha256;c&&(r.basisSha256=c);let s=JSON.stringify(n),l=gt(e,t,r);return we(t,{changed:s!==JSON.stringify(r),...l,evidenceId:r.evidenceId,status:"approved"})}function Ds(e,t){let n=Fe(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return we(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=gt(e,t,o);return we(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
|