@seatlayer/core 0.99.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{categoryInventory-DdJdJ4Og.d.ts → categoryInventory-DZ5IcDOy.d.ts} +1 -1
- package/dist/{categoryInventory-DuOez0-4.d.cts → categoryInventory-H77A_8pF.d.cts} +1 -1
- package/dist/{chunk-KFVUBZMK.js → chunk-2RNZOV5I.js} +1 -1
- package/dist/{chunk-HYEZPOZU.js → chunk-52XO3LA7.js} +1 -1
- package/dist/{chunk-VWT44HBR.js → chunk-5HXTEMRE.js} +1 -1
- package/dist/{chunk-UIMDB6GZ.js → chunk-5PFYIYM5.js} +1 -1
- package/dist/chunk-FLZKBXHA.js +1 -0
- package/dist/{chunk-23OTKCJU.js → chunk-JK3DUFRX.js} +1 -1
- package/dist/chunk-NO6OLVTT.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.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/quality/index.js +1 -1
- 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.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/{eventConfigurations-BISNREZL.d.ts → eventConfigurations-B6aS6c-_.d.ts} +1 -1
- package/dist/{eventConfigurations-DYn5XP3J.d.cts → eventConfigurations-ClFqXQi9.d.cts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -13
- package/dist/index.d.ts +18 -13
- package/dist/index.js +1 -1
- package/dist/{labeling-owTTG6e0.d.cts → labeling-ByEZkLee.d.cts} +1 -1
- package/dist/{labeling-CzuSxAkr.d.ts → labeling-CP3GhUrf.d.ts} +1 -1
- package/dist/{renderedQuality-Bl1Kq_XO.d.cts → renderedQuality--H0toc-2.d.cts} +1 -1
- package/dist/{renderedQuality-BMSbVkwu.d.ts → renderedQuality-Bo4k99GE.d.ts} +1 -1
- package/dist/{renderer-njHDbIqI.d.ts → renderer-BPhSZUGh.d.cts} +12 -1
- package/dist/{renderer-Ccv8ZDZS.d.cts → renderer-CWbam_zr.d.ts} +12 -1
- package/dist/{seatTypeIcons-QwEebl3k.d.cts → seatTypeIcons-B2tvcQ0H.d.cts} +1 -1
- package/dist/{seatTypeIcons-dy3XQVWN.d.ts → seatTypeIcons-CSt1isBY.d.ts} +1 -1
- package/dist/{sections-DSIfnBJY.d.cts → sections-C_AKwOIh.d.cts} +1 -1
- package/dist/{sections-C8VTe6BN.d.ts → sections-JHox6Lsw.d.ts} +1 -1
- package/dist/{segmentedRowModel-CDvvJJ4-.d.cts → segmentedRowModel-CZ0Ciea-.d.cts} +1 -1
- package/dist/{segmentedRowModel-I8eYUQft.d.ts → segmentedRowModel-DQO0vHR1.d.ts} +1 -1
- package/dist/{tableSizing-BLtQ-KV0.d.ts → tableSizing-ClgbhNks.d.ts} +3 -3
- package/dist/{tableSizing-CB8g2Fs0.d.cts → tableSizing-Cp5T_6Lw.d.cts} +3 -3
- package/dist/{ticketRestrictions-BvlWLw10.d.cts → ticketRestrictions-BHNbxzFT.d.cts} +2 -2
- package/dist/{ticketRestrictions-DUjN2bZn.d.ts → ticketRestrictions-DUdzkp4F.d.ts} +2 -2
- package/dist/{types-DWx32xXH.d.cts → types-5AlKCD4j.d.cts} +17 -0
- package/dist/{types-DWx32xXH.d.ts → types-5AlKCD4j.d.ts} +17 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +127 -53
- package/dist/view3d/index.d.cts +34 -5
- package/dist/view3d/index.d.ts +34 -5
- package/dist/view3d/index.js +125 -51
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-K22SISYC.js +0 -1
- package/dist/chunk-QJXSZT3H.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var nr=Object.create;var Ke=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var ir=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var sr=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},rn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rr(t))!ar.call(e,i)&&i!==n&&Ke(e,i,{get:()=>t[i],enumerable:!(o=or(t,i))||o.enumerable});return e};var cr=(e,t,n)=>(n=e!=null?nr(ir(e)):{},rn(t||!e||!e.__esModule?Ke(n,"default",{value:e,enumerable:!0}):n,e)),lr=e=>rn(Ke({},"__esModule",{value:!0}),e);var Qs={};sr(Qs,{COLORBLIND_SAFE_PALETTE:()=>zt,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>Mt,DEFAULT_SECTION_CORNER_SMOOTHING:()=>It,MAX_BUYER_IMAGE_URL_LENGTH:()=>jr,MAX_FLOOR_BASE_HEIGHT_M:()=>We,addArcFanRows:()=>ka,addBookableGridArray:()=>cs,addBoothArray:()=>$a,addChartCategory:()=>bo,addChartFloor:()=>ii,addChartZone:()=>li,addGAArea:()=>Ga,addRowBlock:()=>Fa,addTableArray:()=>Ka,applyPolygonHole:()=>Ji,applyReferenceScanRows:()=>as,applySectionCornerSmoothing:()=>na,applySectionEstimates:()=>oa,applySectionOutlineShaping:()=>ro,applySectionRowFit:()=>Vi,approveConfidenceEvidence:()=>Xs,arcFanInputForGroup:()=>yo,assignSectionInventoryCategory:()=>Qi,automaticPlacementCenter:()=>Aa,clearConfidenceEvidence:()=>Js,compactChartDoc:()=>Jr,compactRowOverrides:()=>kn,compactTableOverrides:()=>En,confidenceEvidenceChangeRequiresPublish:()=>$s,confidenceEvidenceChanges:()=>Qo,confidenceEvidenceIndex:()=>Ns,confirmReferenceCategoryOutputColor:()=>fa,convertGeneratedSectionToPolygon:()=>Zi,countCoveredInventory:()=>rt,detectSeatLabelRun:()=>jn,dropRedundantSeatOverrideFields:()=>Je,familyCategoryLabel:()=>ho,gaAreaFootprint:()=>xo,groupRowsAsSegmented:()=>Ba,insertSeatingBlock:()=>$i,isSafeBuyerImageUrl:()=>xn,joinGAAreas:()=>Ls,mergeRows:()=>vs,mirrorFirstFloor:()=>ie,normalizeBuyerImageUrl:()=>ee,normalizeDraftEvidence:()=>Wo,parseSeatRefId:()=>us,pickColorblindSafeCategoryColor:()=>go,planCreationCategory:()=>po,previewArcFanRows:()=>Ut,previewBookableGridArray:()=>ss,previewGeneratedSectionPolygonConversion:()=>no,previewJoinGAAreas:()=>js,previewPolygonHole:()=>at,previewRemovePolygonHole:()=>Wn,previewRowCubicPath:()=>Yn,previewSectionRowFit:()=>Qn,reassignColorblindSafeCategoryColors:()=>ua,relabelChartRows:()=>Ki,removeChartCategory:()=>Ca,removeChartFloor:()=>ci,removeChartObjects:()=>Di,removeChartZone:()=>ui,removePolygonHole:()=>Xi,renameChartFloor:()=>ai,renameDirectSeatImportCategory:()=>sa,reorderChartCategories:()=>ca,replaceArcFanRows:()=>Ea,replaceRowBlock:()=>Ha,resetSeatOverrides:()=>bs,resizeShapes:()=>Es,resolveCreationCategory:()=>Sa,retractConfidenceEvidence:()=>Ys,roundBuyerCoordinates:()=>Yr,seatRefId:()=>Ne,seatSemanticsSignature:()=>Rt,sectionInventorySelectionSummary:()=>to,setConfidenceEvidence:()=>qs,setRowBlockSpacing:()=>Os,splitRow:()=>Cs,straightenAndSpaceRows:()=>Rs,transformSectionBoundary:()=>Wi,transformSectionBoundaryObject:()=>oo,ungroupSegmentedRow:()=>za,updateBooths:()=>Fi,updateCategoryDefinitions:()=>fo,updateChartFloorBaseHeight:()=>si,updateChartTheme:()=>Pa,updateChartZones:()=>di,updateGAAreas:()=>Ni,updateRowCubicPath:()=>zi,updateRows:()=>hs,updateSeatOverrides:()=>Yt,updateSectionExactPath:()=>ea,updateSectionMetadata:()=>Ft,updateSegmentedRow:()=>Ua,updateShapes:()=>ks,updateStageKinds:()=>Ts,updateTables:()=>Ti,updateTextObjects:()=>Gi,updateViewFromSeatFallback:()=>_a});module.exports=lr(Qs);var an=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function dr(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/an(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let s of a.split(/\s+/)){let l=s.length;r&&r+1+l<=o?r+=1+l:(i+=Math.max(1,Math.ceil(l/o)),r=l%o)}}return Math.max(1,i)}function sn(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*an(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=dr(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var ec=Math.PI/180;function D(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function mt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function cn(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 $e(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[cn(e,.5)];let o=Array.from({length:n+1},(l,c)=>cn(e,c/n)),i=new Float64Array(o.length);for(let l=1;l<o.length;l+=1){let c=o[l].x-o[l-1].x,d=o[l].y-o[l-1].y;i[l]=i[l-1]+Math.hypot(c,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],s=1;for(let l=0;l<t;l+=1){let c=a*l/(t-1);for(;s<i.length-1&&i[s]<c;)s+=1;let d=i[s-1],g=i[s],b=g===d?0:(c-d)/(g-d);r.push({x:o[s-1].x+(o[s].x-o[s-1].x)*b,y:o[s-1].y+(o[s].y-o[s-1].y)*b})}return r}function ve(e){if(e.length<3)return 0;let t=0;for(let n=0,o=e.length-1;n<e.length;o=n++)t+=(e[o].x+e[n].x)*(e[o].y-e[n].y);return Math.abs(t)/2}function Ce(e,t,n){return Math.max(t,Math.min(n,e))}function ur(e){return Ce(e,0,1)}function ln(e){let t=ur(e);return t*t*(3-2*t)}var se=Math.PI*2;function ce(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function fr(e,t,n){let o=t-e;if(n){for(;o<0;)o+=se;for(;o>=se;)o-=se}else{for(;o>0;)o-=se;for(;o<=-se;)o+=se}return o}function Be(e){if(e.version!==1||e.closed!==!0||!ce(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||!ce(n.end))return!1;if(n.kind==="line"){if(D(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!ce(n.control1)||!ce(n.control2)||D(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!ce(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 gr(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 xt(e,t=2){if(!Be(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),l=fr(r,s,a.clockwise),c=Math.max(2,Math.ceil(Math.abs(l)*a.radius/n));for(let d=1;d<=c;d+=1){let g=r+l*d/c;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=D(i,a.control1)+D(a.control1,a.control2)+D(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let l=1;l<=s;l+=1)o.push(gr(i,a,l/s))}i=a.end}return D(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function fn(e,t,n){return St(e,i=>({x:i.x+t,y:i.y+n}))}function St(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 It=45,wt=150,br=60;function hr(e){let t=It/100;if(e<=t)return wt;let n=Math.min(1,(e-t)/(1-t));return wt-n*(wt-br)}var dn=.5523;function un(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function pr(e){let t=[],n=[];for(e.forEach((o,i)=>{ce(o)&&(t.length&&un(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&un(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var yr=.5,mr=4/3;function wr(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,s=o/a,l=n*mr;return{kind:"bezier",control1:{x:e.x+o/3+r*l,y:e.y+i/3+s*l},control2:{x:e.x+o*2/3+r*l,y:e.y+i*2/3+s*l},end:{...t}}}function gn(e,t){let{points:n,sourceIndex:o}=pr(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let x=0;x<i;x+=1){let S=r[o[x]];s[x]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let l=s.some(x=>Math.abs(x)>1e-6);if(a<=0&&!l)return null;let c=t.wideAngleThresholdDeg??hr(a),d=[];for(let x=0;x<i;x+=1)d[x]=D(n[x],n[(x+1)%i]);let g=new Array(i).fill(0);for(let x=0;x<i;x+=1){let S=n[(x-1+i)%i],I=n[x],P=n[(x+1)%i],N={x:S.x-I.x,y:S.y-I.y},G={x:P.x-I.x,y:P.y-I.y},K=Math.hypot(N.x,N.y),$=Math.hypot(G.x,G.y);if(K<=1e-9||$<=1e-9)continue;let R=Math.min(1,Math.max(-1,(N.x*G.x+N.y*G.y)/(K*$))),z=Math.acos(R)*180/Math.PI;if(z<c)continue;let A=ln((z-c)/(180-c));g[x]=a*A*.5*Math.min(K,$)}for(let x=0;x<i;x+=1){let S=(x+1)%i,I=g[x]+g[S];if(I>d[x]&&I>1e-9){let P=d[x]/I;g[x]*=P,g[S]*=P}}let b=new Array(i),f=new Array(i);for(let x=0;x<i;x+=1){let S=n[(x-1+i)%i],I=n[x],P=n[(x+1)%i];if(g[x]<=1e-6){b[x]={...I},f[x]={...I};continue}let N=D(I,S)||1,G=D(I,P)||1;b[x]={x:I.x+(S.x-I.x)/N*g[x],y:I.y+(S.y-I.y)/N*g[x]},f[x]={x:I.x+(P.x-I.x)/G*g[x],y:I.y+(P.y-I.y)/G*g[x]}}if(g.every(x=>x<=1e-6)&&!l)return null;let y=[],m={...f[0]},w=m,v=(x,S)=>{if(D(w,x)<=1e-9)return;let I=s[S];Math.abs(I)>1e-6?y.push(wr(w,x,I*yr*d[S])):y.push({kind:"line",end:{...x}}),w=x};for(let x=1;x<=i;x+=1){let S=x%i,I=n[S];v(b[S],(x-1)%i),g[S]>1e-6&&D(b[S],f[S])>1e-9&&(y.push({kind:"bezier",control1:mt(b[S],I,dn),control2:mt(f[S],I,dn),end:{...f[S]}}),w=f[S])}if(!y.length)return null;let h=y[y.length-1];D(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:y.push({kind:"line",end:{...m}}));let p={version:1,closed:!0,start:m,segments:y};return Be(p)?p:null}var bn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",xr="ABCDEFGHJKLMNPQRSTUVWXYZ",Sr="abcdefghijklmnopqrstuvwxyz";function hn(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 Ir(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?xr:bn;return hn(o,i)}function vt(e,t=!1){let n=t?Sr:bn;return hn(Math.max(0,Math.floor(e)-1),n)}var vr=[[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 pn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of vr)for(;t>=o;)n+=i,t-=o;return n}function yn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:Ir(a,t)}})}function Cr(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 le(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,l=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(l/2),y=a==="updown"?t<f?n+2*t:n-1+2*(l-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${y}`}let c=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(l-1)*c:n,g=o==="center"?Cr(l)[t]:o==="rtl"?l-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=pn(d+g*i);break;case"letters-upper":b=vt(d+g*i,!1);break;case"letters-lower":b=vt(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function Or(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Y(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${le(e,t)}`}function Oe(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return le(e,t);if(!n)return`${e.displayLabel||e.label}-${le(e,t)}`;let i=Or(n),a=n.displayOffset+t;return`${n.displayLabel}-${le(i,a)}`}var mn=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."},{key:"pitch-rugby",label:"Rugby pitch",blurb:"100 \xD7 70 m field of play with in-goal areas, 22 m and 10 m lines."},{key:"diamond-baseball",label:"Baseball field",blurb:"Diamond, infield, mound and foul lines out to 99 m poles."},{key:"court-basketball",label:"Basketball court",blurb:"28 \xD7 15 m court with keys and three-point lines."},{key:"court-tennis",label:"Tennis court",blurb:"23.77 \xD7 10.97 m doubles court with run-off and net."},{key:"ring-boxing",label:"Boxing ring",blurb:"Raised ring, 6.1 m inside the ropes, coloured corners."}];var Rr=Math.PI*2;function Pr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function wn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,s=Math.cos(r),l=Math.sin(r),c=i/2,d=a/2,g=[],b=(f,y)=>{g.push({x:f,y})};switch(t){case"rect":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"rounded":{let f=Math.min(i,a)*.18,y=5,m=(w,v,h)=>{for(let p=0;p<=y;p++){let x=h+p/y*(Math.PI/2);b(w+f*Math.cos(x),v+f*Math.sin(x))}};m(c-f,-d+f,-Math.PI/2),m(c-f,d-f,0),m(-c+f,d-f,Math.PI/2),m(-c+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-c,-d),b(c,-d);let y=24;for(let m=0;m<=y;m++){let w=m/y,v=c-w*i,h=d+f*(1-Math.pow(2*v/i,2));b(v,h)}break}case"thrust":{let f=i*.18,y=a*1.1;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"runway":{let f=i*.1,y=a*3;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"round":case"oval-cricket":{for(let y=0;y<40;y++){let m=y/40*Rr;b(c*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"diamond-baseball":{for(let f of Mr(c,d))b(f.x,f.y);break}case"rink-hockey":{for(let f of _r(c,d,c*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of Ar(c,d))b(f.x,f.y);break}}return g.map(f=>Pr(f.x,f.y,s,l,n,o))}function _r(e,t,n,o){let i=[],r=(s,l,c)=>{for(let d=0;d<=8;d++){let g=c+d/8*(Math.PI/2);i.push({x:s+n*Math.cos(g),y:l+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 Ar(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 Re=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},i=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=i+70,r=[],s=Math.atan2(o.y-i,o.x),l=Math.atan2(o.y-i,-o.x);for(let c=0;c<=24;c++){let d=s+(l-s)*c/24;r.push({x:a*Math.cos(d),y:i+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:r}})();function Mr(e,t){let n=e/Re.half,o=t/Re.half;return[{x:-Re.backstop*n,y:t},{x:Re.backstop*n,y:t},...Re.fence.map(i=>({x:i.x*n,y:i.y*o}))]}var jr=2e6,Lr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,kr=/[\s"'<>`\\]/;function xn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Lr.test(e);if(kr.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ee(e){let t=e.trim();return xn(t)?t:null}function Pe(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Ue=Math.PI/180,Er=9,de=16;function Ot(e,t,n,o){let i=n*Ue,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function ue(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return $e(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let c=0;c<t;c++)r.push(Ot(c*n,0,i,a));return r}let s=o/(t-1)*Ue,l=n/(2*Math.sin(Math.abs(s)/2));for(let c=0;c<t;c++){let d=c*s,g=l*Math.sin(d),b=-l+l*Math.cos(d);r.push(Ot(g,b,i,a))}return r}function vn(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Tr(e,t){let n=vn(e);return ue(e).map((o,i)=>{let a=n.get(i),r=Pe(a),s=Y(e,i,a),l={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Oe(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(l).some(c=>c!==void 0&&c!==!1&&c!=="")?l:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function H(e){let t=[];for(let n of Tr(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 Fr(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 Nr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let y=o.get(d),m=Pe(y),w=y?.label??`${e.label}-${d+1}`,v=e.displayLabel??e.label;return{index:d,label:w,displayLabel:y?.displayLabel??`${v}-${d+1}`,x:g+(y?.dx??0),y:b+(y?.dy??0),categoryKey:y?.categoryKey??e.categoryKey,skipped:!!y?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:y?.wheelchairSpaceType,commercial:y?.commercial,glyph:y?.glyph,viewUrl:y?.viewFromSeatUrl,viewMeta:y?.viewFromSeatUrl?y.viewFromSeatMeta:void 0,labelStyle:y?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+de,g=e.rotation*Ue,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let w=0;w<n;w++){let v=g+w/n*2*Math.PI;t.push(i(w,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let f=b*Ue,y=(2*Math.PI-f)/2,m=g+y;for(let w=0;w<n;w++){let v=m+w/(n-1)*f;t.push(i(w,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let a=e.width??80,r=e.height??50,s=Fr(e),l=["top","bottom","left","right"],c=0;for(let d of l){let g=s[d];for(let b=0;b<g;b++){let f,y;d==="top"?(f=-a/2+(b+.5)*a/g,y=-r/2-de):d==="bottom"?(f=-a/2+(b+.5)*a/g,y=r/2+de):d==="left"?(f=-a/2-de,y=-r/2+(b+.5)*r/g):(f=a/2+de,y=-r/2+(b+.5)*r/g);let m=Ot(f,y,e.rotation,e.center);t.push(i(c++,m.x,m.y,d))}}return t}function ne(e){return Nr(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 Cn(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 Sn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,s=t[i].x,l=t[i].y;r>e.y!=l>e.y&&e.x<(s-a)*(e.y-r)/(l-r)+a&&(n=!n)}return n}function Dr(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.y-n.y)*(i.y-n.y),s=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=s+1e-7})}function te(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function F(e,t,n){return Sn(e,t)&&!te(n).some(o=>Sn(e,o)||Dr(e,o))}function Ct(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=ue(e),n=vn(e),o=0,i=0,a=0;for(let r=0;r<t.length;r++){let s=n.get(r);s?.skip||(o+=t[r].x+(s?.dx??0),i+=t[r].y+(s?.dy??0),a++)}return a?{x:o/a,y:i/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Ct(e.points);case"section":return Ct(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Ct(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 In(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Gr(e,t){if(e.type!=="gaArea"||!In(e.points,t.outline))return!1;let n=te(e.holes),o=te(t.holes);return n.length===o.length&&n.every((i,a)=>In(i,o[a]))}function On(e,t,n=e.filter(i=>i.type==="section"),o=L(t)){let i="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(i?n.find(r=>(r.logicalSectionId??r.id)===i&&(Gr(t,r)||F(o,r.outline,r.holes))):void 0)??n.find(r=>F(o,r.outline,r.holes))}function k(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function B(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var ze=40;function Rn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,s=(c,d)=>{c<o&&(o=c),d<i&&(i=d),c>a&&(a=c),d>r&&(r=d)},l=c=>{if(Array.isArray(c))for(let d of c)!d||typeof d!="object"||s(d.x,d.y)};for(let c of B(e))if(c.type==="row"){let d=new Map((c.overrides??[]).map(g=>[g.index,g]));ue(c).forEach((g,b)=>{let f=d.get(b);f?.skip||s(g.x+(f?.dx??0),g.y+(f?.dy??0))})}else if(c.type==="gaArea")l(c.points);else if(c.type==="section")l(c.outline);else if(c.type==="decorImage")s(c.x,c.y),s(c.x+c.width,c.y+c.height);else if(c.type==="shape")c.points&&c.points.length?l(c.points):c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null&&(s(c.x,c.y),s(c.x+c.width,c.y+c.height));else if(c.type==="table"){let d=de+Er,g=c.shape==="round"?(c.radius??40)+d:Math.max((c.width??80)/2,(c.height??50)/2)+d;s(c.center.x-g,c.center.y-g),s(c.center.x+g,c.center.y+g)}else if(c.type==="booth"){let d=Math.max(c.width,c.height)/2;s(c.center.x-d,c.center.y-d),s(c.center.x+d,c.center.y+d)}else if(c.type==="text"){if(n)continue;let d=sn(c);s(c.position.x,c.position.y),s(c.position.x+d.width,c.position.y+d.height)}for(let c of[e.referenceImage,e.backgroundImage]){if(!c)continue;let{center:d,width:g}=c;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(g))continue;let b=g*3/4;s(d.x-g/2,d.y-b/2),s(d.x+g/2,d.y+b/2)}if(!isFinite(o)){let c=e.focalPoint??{x:0,y:0};return{x:c.x-200,y:c.y-200,width:400,height:400}}return{x:o-ze,y:i-ze,width:a-o+ze*2,height:r-i+ze*2}}function He(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 Mn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Ae(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Rt(e){let t=Ae(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of Kr){let s=i?.[r];s!==void 0&&(a[r]=s)}n.push([Y(e,o,i),Oe(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function $r(e){return JSON.parse(JSON.stringify(e))}function Ve(e,t){let n=$r(e);return t(n)&&Rt(n)===Rt(e)?n:e}function Br(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Ae(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(!Mn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function zr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function jn(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=zr(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 Ur(e){if(e.seatCount<1)return!1;let t=Ae(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(Y(e,i,t.get(i)));let o=jn(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 Hr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Ae(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==le(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Je(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Mn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===Y(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===Oe(e,t.index)&&delete t.displayLabel}function Ln(e){return Object.keys(e).every(t=>t==="index")}function Vr(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Je(e,n);let t=e.overrides.filter(n=>!Ln(n));return t.length?e.overrides=t:delete e.overrides,!0}function qr(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Ae(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function kn(e){if(e.type!=="row")return e;let t=Ve(e,Br);return t=Ve(t,Ur),t=Ve(t,Hr),t=Ve(t,Vr),qr(e,t)?t:e}function En(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,Ln(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function Pn(e){return e.type==="row"?kn(e):e.type==="table"?En(e):e}function Jr(e){let t=e.objects.map(Pn),n=e.floors?.map(o=>({...o,objects:o.objects.map(Pn)}));return{...e,objects:t,...n?{floors:n}:{}}}var _n=2,Xr=3,An=6;function _e(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 qe(e){return{...e,x:_e(e.x,_n),y:_e(e.y,_n)}}function Yr(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=qe(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(qe)),Array.isArray(t.points)&&(t.points=t.points.map(qe)),typeof t.rotation=="number"&&(t.rotation=_e(t.rotation,An)),typeof t.seatSpacing=="number"&&(t.seatSpacing=_e(t.seatSpacing,An));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:qe(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let s=_e(r,Xr);s===0?delete i[a]:i[a]=s}return i})),t}var Qr=36,Zr=160;function Tn(e,t=360){let n=Ce(Math.round(Number.isFinite(e)?e:1),1,40),o=Ce(Number.isFinite(t)?t:360,120,360);return Math.round(Ce(n*4*(360/o),Qr,Zr))}var Fn=["horizontal","vertical","auto"];var Me=[{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"}],Oc=new Map(Me.map(e=>[e.key,e]));var Wr=[{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"}],Rc=new Map(Wr.map(e=>[e.key,e]));var fe=8,Pt=24,ei=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Pc=new Set(ei);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function j(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function M(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function ti(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;let n=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=t.length-1;a>=0;a--){let r=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function ni(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.map(o=>{let i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a)||1;return{x:o.x+i/r*t,y:o.y+a/r*t}})}function oe(e){let t=[];for(let o of e)o.type==="row"?t.push(...H(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ne(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=ni(ti(t),22);return n.length>=3?n:null}function Xe(e,t){let n=C(e,t),o=k(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Nn=24,Dn=80;function _t(e,t){let n=e.normalize("NFKC").trim();if(n.length>Nn)throw new u("invalid_operation",`${t} displayed type must be at most ${Nn} characters`);return n}function Ye(e,t){if(e.displayType===void 0)return!1;let n=_t(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function ge(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Dn)throw new u("invalid_operation",`${t} displayed label must be at most ${Dn} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function E(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function Gn(e,t){if(!Number.isFinite(e)||e<fe||e>Pt)throw new u("invalid_operation",`${t} label size must be from ${fe} to ${Pt}`)}function be(e,t){e.size!==void 0&&e.size!==null&&Gn(e.size,t),e.color!==void 0&&e.color!==null&&E(e.color,`${t} label color`)}function Qe(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&Gn(n.size,t),n.color!==void 0&&E(n.color,`${t} label color`))}function Ze(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=E(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function At(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 je(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function q(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var Q=Math.PI/180,J=Math.PI/180;function re(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function ie(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 oi=0,We=120,Mt=4;function ri(e){if(!Number.isFinite(e)||e<oi||e>We)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ii(e,t){let n=k(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.name??String(n.length+1)).normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(l=>l.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(We,(e.floors.length-1)*Mt),r=Math.min(We,a+Mt),s=M(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),ie(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:r}}function ai(e,t){let n=k(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function si(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});ri(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 ci(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 ie(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:k(e).length}}function li(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:M(e,"zone",t.idFactory,new Set),label:At(e,t.label),color:E(t.color,"Zone color"),...t.focalPoint?{focalPoint:je(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function di(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(l=>l.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((e.zones??[]).map(l=>[l.id,l])),i=n.filter(l=>!o.has(l));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(e),r=new Map((a.zones??[]).map(l=>[l.id,l]));for(let l of t.updates){if(!Object.keys(l.patch).length)throw new u("invalid_operation",`Zone ${l.zoneId} has no changes`);let d=r.get(l.zoneId);l.patch.label!==void 0&&(d.label=At(a,l.patch.label,d.id)),l.patch.color!==void 0&&(d.color=E(l.patch.color,"Zone color")),l.patch.focalPoint!==void 0&&(d.focalPoint=je(l.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(l=>structuredClone(r.get(l)))}}function ui(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=k(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.zoneId,sectionIds:o.map(a=>a.id),requiresClearSectionAssignments:!0});let i=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,ie(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var et=[{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 tt(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 jt="__sl_ga__";function Le(e){return e.startsWith(jt)}var fi=jt,X=1e5;function gi(e,t){return`${fi}${encodeURIComponent(e)}__${t+1}`}function Lt(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){if(!i||typeof i.sourceAreaId!="string"||!i.sourceAreaId.trim()||i.sourceAreaId.length>160||!Number.isInteger(i.startIndex)||i.startIndex<0||!Number.isInteger(i.count)||i.count<1||i.startIndex+i.count>X||(n+=i.count,n>X))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(s=>i.startIndex<s.end&&r>s.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===e.capacity}function nt(e){let t=Math.min(X,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Lt(e)?e.inventorySegments.map(n=>({...n})):[]}function Z(e){return nt(e).flatMap(t=>Array.from({length:t.count},(n,o)=>gi(t.sourceAreaId,t.startIndex+o)))}function kt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=nt(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,l)=>Math.max(s,l.startIndex+l.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var bi="__ungrouped__";function hi(e){return e.type==="row"?H(e).map(t=>t.label):e.type==="table"?ne(e).map(t=>t.label):e.type==="booth"?Cn(e).map(t=>t.label):e.type==="gaArea"?Z(e):[]}function pi(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function yi(e){return e.displayLabel||e.label||"Section"}function mi(e){let t=new Map;for(let n of B(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:yi(n),zone:n.zone})}return t}function wi(e,t){let n=B(e),o=n.filter(s=>s.type==="section"),i=new Map;for(let[s,l]of mi(e))i.set(s,{id:s,label:l.label,zone:l.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:bi,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},r=new Map;for(let s of n){if(!pi(s))continue;let l=hi(s);if(l.length===0)continue;let c;if(t)c=t.get(s.id);else{let g=On(n,s,o);c=g?g.logicalSectionId??g.id:void 0}let d=c?i.get(c):a;d.seatCount+=l.length,d.objectIds.push(s.id),d.seatLabels.push(...l),r.set(s.id,d.id)}return{sections:[...i.values()],ungrouped:a.objectIds.length?a:null,objectToSection:r}}function ke(e){return wi(e,null)}var ae={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 Ee(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 xi(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 Kn(e,t,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}function Si(e,t,n,o,i){let a=n*2,r=[];for(let s=0;s<a;s++){let l=s%2===0,c=l?["wheelchair"]:["companion"];r.push(l?{index:s,accessibility:c,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:c})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var $n=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[ae.balcony],sectionLabel:"Balcony",build:()=>[Ee("blk-b0","A",-45,18,24,"balcony",18),Ee("blk-b1","B",-15,20,24,"balcony",18),Ee("blk-b2","C",15,22,24,"balcony",18),Ee("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[ae.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>Ee(`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:[ae.standard],build:()=>[Kn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[ae.premium],build:()=>Array.from({length:6},(e,t)=>xi(`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:[ae.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:[ae.standard],build:()=>[Kn("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:[ae.standard],build:()=>[Si("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 Bn(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 zn="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",Un=[{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:zn},{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:zn},{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 Ii=new Map(Un.map(e=>[e.key,e]));function Hn(e){return typeof e=="string"&&Ii.has(e)}var Zc=Un.map(e=>e.key);function Et(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 Vn(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=te(e.holes).map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=fn(e.outlinePath,t,n)),e.holes&&(e.holes=te(e.holes).map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function vi(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function Te(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function ot(e,t,n){let o=Te(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 Ci(e,t,n,o){let i=Te(e,t,n),a=Te(e,t,o),r=Te(n,o,e),s=Te(n,o,t);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)?!0:Math.abs(i)<=1e-7&&ot(n,e,t)||Math.abs(a)<=1e-7&&ot(o,e,t)||Math.abs(r)<=1e-7&&ot(e,n,o)||Math.abs(s)<=1e-7&&ot(t,n,o)}function Oi(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 Ri(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)&&Ci(e[t],e[n],e[o],e[i]))return!0}}return!1}function qn(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)=>vi(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Oi(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Ri(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function Ti(e,t){let n=C(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(p=>p.type==="table"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=E(r.fill,"Table surface color"));let s=r.seatCount!==void 0,l=r.seatCountsBySide!==void 0;if(l){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let h=["top","bottom","left","right"],p=Object.keys(r.seatCountsBySide);if(p.length!==h.length||p.some(S=>!h.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of h){let I=r.seatCountsBySide[S];if(!Number.isInteger(I)||I<0||I>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let x=h.reduce((S,I)=>S+r.seatCountsBySide[I],0);if(x<1||x>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==x)throw new u("invalid_operation",`seatCount must equal the ${x}-chair seatCountsBySide total`);r.seatCount=x,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 c=(h,p,x,S)=>{if(p!==void 0&&(!Number.isFinite(p)||p<x||p>S))throw new u("invalid_operation",`${String(h)} must be from ${x} to ${S}`)};if(c("rotation",r.rotation,0,360),c("radius",r.radius,24,160),c("seatArc",r.seatArc,120,360),c("width",r.width,40,320),c("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let h=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(p=>!h.has(p)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=ge(r,"Table"),g=Ye(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!l&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let p=structuredClone(h);if(Object.assign(p,r),r.fill===null&&delete p.fill,p.shape==="round")delete p.seatCountsBySide,p.automaticRadius===!0?p.radius=Tn(p.seatCount,p.seatArc):delete p.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${p.label}" is rectangular and cannot use automatic radius`,{tableId:p.id});delete p.automaticRadius}if(p.overrides&&r.seatCount!==void 0&&(p.overrides=p.overrides.filter(x=>x.index<p.seatCount),p.overrides.length||delete p.overrides),r.bookAsWhole===!1&&delete p.bookAsWhole,r.variableOccupancy===!1&&(delete p.variableOccupancy,delete p.minOccupancy,delete p.maxOccupancy),p.bookAsWhole||delete p.bookAsWhole,p.variableOccupancy||delete p.variableOccupancy,p.bookAsWhole&&p.variableOccupancy)throw new u("invalid_operation",`Table "${p.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:p.id});if((p.bookAsWhole||p.variableOccupancy)&&p.overrides?.length)throw new u("invalid_operation",`Table "${p.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:p.id,overriddenChairIndices:p.overrides.map(x=>x.index)});if(p.bookAsWhole)delete p.minOccupancy,delete p.maxOccupancy;else if(p.variableOccupancy){if(!Number.isInteger(p.minOccupancy)||!Number.isInteger(p.maxOccupancy)||p.minOccupancy<1||p.maxOccupancy<p.minOccupancy||p.maxOccupancy>p.seatCount)throw new u("invalid_operation",`Table "${p.label}" needs whole-number minimum and maximum guests from 1 to its ${p.seatCount}-chair capacity`,{tableId:p.id,seatCount:p.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:p.id});delete p.minOccupancy,delete p.maxOccupancy}if(g&&delete p.displayType,d&&delete p.displayLabel,p.shape==="rect"){if(p.width??=80,p.height??=50,p.seatCountsBySide){let x=["top","bottom","left","right"],S=x.reduce((I,P)=>I+p.seatCountsBySide[P],0);if(S!==p.seatCount)throw new u("invalid_operation",`Table "${p.label}" side counts total ${S}, but seatCount is ${p.seatCount}`,{tableId:p.id,seatCount:p.seatCount,seatCountsBySide:p.seatCountsBySide});p.sides=x.filter(I=>p.seatCountsBySide[I]>0)}}else p.radius??=40;if((p.bookAsWhole||p.variableOccupancy)&&Le(p.label))throw new u("invalid_operation",`Grouped table label "${p.label}" uses SeatLayer's reserved GA namespace`,{tableId:p.id});return p}),f=new Map(b.map(h=>[h.id,h])),y=new Set(o),m=new Map;for(let h of k(e))for(let p of h.objects){let x=p.type==="table"?f.get(p.id)??p:p,S=[];x.type==="row"?S=H(x).map(I=>I.label):x.type==="table"?S=x.bookAsWhole||x.variableOccupancy?[x.label]:ne(x).map(I=>I.label):x.type==="booth"?S=[x.label]:x.type==="gaArea"&&(S=Z(x));for(let I of S){let P=m.get(I);if(P&&(y.has(P)||y.has(x.id)))throw new u("invalid_operation",`Inventory label "${I}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:I,conflictingObjectIds:[P,x.id]});m.set(I,P??x.id)}}let w=!1,v=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,p]of i.entries()){let x=b[h],S=JSON.stringify(p);for(let I of v)I in x||delete p[I];Object.assign(p,x),JSON.stringify(p)!==S&&(w=!0)}return{floorId:n.floorId,changed:w,tableIds:o}}function Fi(e,t){let n=C(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(y=>y.type==="booth"&&y.id===f)),a=o.filter((f,y)=>!i[y]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&j(e,r.categoryKey);let s=(f,y,m,w)=>{if(y!==void 0&&(!Number.isFinite(y)||y<m||y>w))throw new u("invalid_operation",`${f} must be from ${m} to ${w}`)};s("width",r.width,30,400),s("height",r.height,30,400),s("rotation",r.rotation,0,360);let l=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=qn(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let c=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=ge(r,"Booth"),g=Ye(r,"Booth"),b=!1;for(let f of i){let y=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,l?delete f.points:c&&(f.points=c),JSON.stringify(f)!==y&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Ni(e,t){let n=C(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let i=o.map(d=>n.objects.find(g=>g.type==="gaArea"&&g.id===d)),a=o.filter((d,g)=>!i[g]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one GA area change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(r.categoryKey!==void 0&&j(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>X))throw new u("invalid_operation",`capacity must be an integer from 1 to ${X}`);if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=ge(r,"GA area"),l=Ye(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&&kt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let c=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:kt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),s&&delete d.displayLabel,l&&delete d.displayType,JSON.stringify(d)!==g&&(c=!0)}return{floorId:n.floorId,changed:c,gaAreaIds:o}}function rt(e,t){if(t.length<3)return 0;let n=i=>F(i,t,void 0),o=0;for(let i of e)n(L(i))&&(i.type==="row"?o+=H(i).length:i.type==="table"?o+=ne(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=re(i)));return o}function Di(e,t){let n=C(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(l=>l.id===s)),i=t.objectIds.filter((s,l)=>!o[l]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)r.has(n.objects[s].id)&&n.objects.splice(s,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,l)=>s+re(l),0),remainingObjectCount:n.objects.length}}function Gi(e,t){let n=C(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(c=>n.objects.find(d=>d.type==="text"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=E(r.color,"Text color")),r.bold!==void 0&&typeof r.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(r.italic!==void 0&&typeof r.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(r.width!==void 0&&r.width!==null&&(!Number.isFinite(r.width)||r.width<40||r.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(r.align!==void 0&&!["left","center","right"].includes(r.align))throw new u("invalid_operation","Text align must be left, center, or right");if(r.lineHeight!==void 0&&(!Number.isFinite(r.lineHeight)||r.lineHeight<.8||r.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(r.letterSpacing!==void 0&&(!Number.isFinite(r.letterSpacing)||r.letterSpacing<-2||r.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(r.underline!==void 0&&typeof r.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(r.opacity!==void 0&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(r.background!==void 0&&r.background!==null){r.background.color=E(r.background.color,"Text background color");let{padding:c=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(c)||c<0||c>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(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(c=>Object.prototype.hasOwnProperty.call(r,c))&&i.some(c=>c.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!Hn(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(c=>c.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let l=!1;for(let c of i){let d=JSON.stringify(c);r.iconKey!==void 0&&(c.iconKey=r.iconKey),r.text!==void 0&&(c.text=r.text),r.fontSize!==void 0&&(c.fontSize=r.fontSize),r.fontFamily===null?delete c.fontFamily:r.fontFamily!==void 0&&(c.fontFamily=r.fontFamily),r.rotation!==void 0&&(c.rotation=r.rotation),r.color===null?delete c.color:r.color!==void 0&&(c.color=r.color),r.bold!==void 0&&(r.bold?c.bold=!0:delete c.bold),r.italic!==void 0&&(r.italic?c.italic=!0:delete c.italic),r.width===null?delete c.width:r.width!==void 0&&(c.width=r.width),r.align!==void 0&&(r.align==="left"?delete c.align:c.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete c.lineHeight:c.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete c.letterSpacing:c.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?c.underline=!0:delete c.underline),r.opacity!==void 0&&(r.opacity===1?delete c.opacity:c.opacity=r.opacity),r.background===null?delete c.background:r.background!==void 0&&(c.background=r.background),r.labelImportance===null?delete c.labelImportance:r.labelImportance!==void 0&&(c.labelImportance=r.labelImportance),JSON.stringify(c)!==d&&(He(c),l=!0)}return{floorId:n.floorId,changed:l,textIds:o}}function Ki(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),s=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,l=yn(r.map(b=>({label:s(b)})),t.options),c=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=c===void 0||c===""||c==="Row"?t.displayType===void 0?void 0:null:c,g=!1;return r.forEach((b,f)=>{let y=l[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(b)!==y&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=y:b.displayLabel=y),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:s(b),...b.displayType?{displayType:b.displayType}:{}}))}}function $i(e,t){let n=$n.find(c=>c.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=C(e,t.floorId),i=new Set,a=n.build().map(c=>structuredClone(c));for(let c of a)c.id=M(e,c.type,t.idFactory,i),Vn(c,t.center.x,t.center.y);for(let c of n.categories)e.categories.some(d=>d.key===c.key)||e.categories.push({...c});let r=a.filter(c=>c.type==="row");if(r.length){let c=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Bn(d.label);g!=null&&(c=Math.max(c,g+1))}for(let d of r)d.label=U(c++)}let s=new Set(o.objects.flatMap(c=>"label"in c&&c.label?[c.label]:[]));for(let c of a){if((c.type==="table"||c.type==="booth")&&s.has(c.label)){let d=/^(.*?)(\d+)$/.exec(c.label),g=d?d[1]:`${c.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(s.has(`${g}${b}`));c.label=`${g}${b}`}"label"in c&&c.label&&s.add(c.label)}o.objects.push(...a);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let c=oe(a);if(c){let d={type:"section",id:M(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:c};o.objects.push(d),l=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(c=>c.id),...l?[l]:[]],sectionId:l}}function Bi(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=$e(t,97),i=o.slice(1).reduce((a,r,s)=>a+Math.hypot(r.x-o[s].x,r.y-o[s].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:i}}function Yn(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=Bi(t.path),a=H(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=H(r),l=a.map((d,g)=>Math.hypot(d.x-s[g].x,d.y-s[g].y)),c=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:l.length?l.reduce((d,g)=>d+g,0)/l.length:0,maxSeatMovement:l.length?Math.max(...l):0,convertingFromParametric:!o.path,changed:c,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function zi(e,t){let n=Yn(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 Ui(e,t){let n=e.map((o,i)=>[...o,t[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let s=n[r][o];for(let l=o;l<4;l++)n[r][l]-=s*n[o][l]}}return[n[0][3],n[1][3],n[2][3]]}function Hi(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*r;for(let l=0;l<3;l++)t[s][l]+=a[s]*a[l]}}let o=Ui(t,n);return o?{x:o[0],y:o[1]}:null}function Jn(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function Qn(e,t){let n=C(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=k(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Hi(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(f=>f.type==="row"&&F(L(f),o.outline,o.holes)),l=s.filter(f=>!!f.path).map(f=>f.id),c=[],d=[],g=i/100;for(let f of s){if(f.path)continue;if(f.seatCount<2){c.push(f.id);continue}let y=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(y<=f.seatSpacing/2+1e-6){c.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*y))/Q,w=H(f),v=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/Q,p=(f.curve!==0?Math.sign(f.curve):w.length>1&&Math.sign(Jn(Math.atan2(w[1].x-r.x,w[1].y-r.y)/Q-v))||1)*m*(f.seatCount-1);if(Math.abs(p)>320){c.push(f.id);continue}let x=-v,S=f.curve+(p-f.curve)*g,I=f.rotation+Jn(x-f.rotation)*g,P={...f,curve:S,rotation:I},G=H(P).map((K,$)=>Math.hypot(K.x-w[$].x,K.y-w[$].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:p,resultCurve:S,fromRotation:f.rotation,resultRotation:I,rmsMovement:Math.sqrt(G.reduce((K,$)=>K+$**2,0)/G.length),maxMovement:Math.max(...G)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:l,skippedInvalidRowIds:c,averageMovement:b.length?b.reduce((f,y)=>f+y,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function Vi(e,t){let n=Qn(e,t),o=C(e,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let s=o.objects.find(l=>l.type==="row"&&l.id===r.rowId);(s.curve!==r.resultCurve||s.rotation!==r.resultRotation)&&(s.curve=r.resultCurve,s.rotation=r.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function Zn(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),s=q(n,o,t);return i*a<-1e-9&&r*s<-1e-9}function Xn(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>Zn(n,i,a,t[(r+1)%t.length]))})}function qi(e){if(e.length<3||e.length>256||Math.abs(ve(e))<1||e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)))return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(!(n===t+1||t===0&&n===e.length-1)&&Zn(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function it(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 at(e,t){let{target:n,object:o,outer:i}=it(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!qi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(c=>!F(c,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Xn(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=t.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||t.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let c=0;c<r.length;c++){if(c===t.holeIndex)continue;let d=r[c];if(Xn(a,d)||F(a[0],d,void 0)||F(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let l=n.objects.filter(c=>c.id!==o.id&&c.type!=="section"&&F(L(c),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:l.map(c=>c.id),excludedInventoryUnits:rt(n.objects.filter(c=>c.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Ji(e,t){let n=at(e,t),{object:o}=it(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 Wn(e,t){let{target:n,object:o}=it(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:rt(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Xi(e,t){let n=Wn(e,t),{object:o}=it(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Yi(e){let t=ee(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function eo(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.find(s=>s.type==="section"&&s.id===r)),i=n.filter((r,s)=>!o[s]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function to(e,t){let n=C(e,t.floorId),o=eo(n.objects,t.sectionIds),i=ke(Xe(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),s=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),l=new Set,c=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of s){let y=r.get(f);if(y)if(y.type==="row"||y.type==="table")for(let m of tt(y).keys())l.add(m);else(y.type==="booth"||y.type==="gaArea")&&l.add(y.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(y=>{let m=r.get(y);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:g,...g&&l.size===1?{categoryKey:[...l][0]}:!g&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?l.size!==1:!s.length&&d.size>1,viewApplicable:b}}function Qi(e,t){j(e,t.categoryKey);let n=to(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=C(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,s=new Set(n.logicalSectionIds);for(let l of o.objects)l.type!=="section"||!s.has(l.logicalSectionId??l.id)||l.editor?.defaultCategoryKey!==t.categoryKey&&(l.editor={...l.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let l of o.objects){if(!i.has(l.id)||l.type!=="row"&&l.type!=="table"&&l.type!=="booth"&&l.type!=="gaArea"||(l.categoryKey!==t.categoryKey&&(l.categoryKey=t.categoryKey,a=!0),l.type!=="row"&&l.type!=="table"||!l.overrides?.length))continue;let c=l.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});c.length?l.overrides=c:delete l.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Ft(e,t){let n=C(e,t.floorId),o=eo(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(f=>!r.has(f));if(s.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${s.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=Yi(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&&be(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(f=>f.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=E(a.color,"Section color"));let l=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,c=new Set(o.logicalSectionIds),d=l?n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let y=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let m=w=>{f.physical3dProvenance&&(delete f.physical3dProvenance[w],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,m("height")):a.height!==void 0&&(f.height=a.height,f.physical3dProvenance={...f.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete f.rake,m("rake")):a.rake!==void 0&&(f.rake=a.rake,f.physical3dProvenance={...f.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete f.surfaceKind,m("surfaceKind")):a.surfaceKind!==void 0&&(f.surfaceKind=a.surfaceKind,f.physical3dProvenance={...f.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete f.color:a.color!==void 0&&(f.color=a.color),JSON.stringify(f)!==y&&(b=!0,g.add(f.id))}for(let f of d){let y=JSON.stringify(f),m=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let w=Ze(f.labelPresentation,a.labelStyle);w?f.labelPresentation=w:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==y&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function no(e,t){let n=C(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&F(L(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+re(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function Zi(e,t){let n=no(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 oo(e,t){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let s=L(e);o=l=>({x:s.x+(l.x-s.x)*t.factor,y:s.y+(l.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let l=t.degrees*Math.PI/180,c=Math.cos(l),d=Math.sin(l),g=L(e);o=b=>{let f=b.x-g.x,y=b.y-g.y;return{x:g.x+f*c-y*d,y:g.y+f*d+y*c}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=St(e.outlinePath,o,i,a)),e.holes&&(e.holes=te(e.holes).map(s=>s.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function Wi(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,...oo(o,t.transform)}}function ea(e,t){let n=C(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Be(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=xt(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function ta(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function na(e,t){return ro(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function ro(e,t){let n=C(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(s=>!Number.isFinite(s)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let l=n.objects.find(h=>h.type==="section"&&h.id===s);if(!l||!ta(l))continue;let d=structuredClone(l);a.set(l.id,{section:l,snapshot:d});let g=JSON.stringify(l),b=(l.sourceOutline??l.outline).map(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??l.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?l.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),w=m?.some(h=>Math.abs(h)>.5)===!0,v=f>.5||w?gn(b,{cornerSmoothing:f,...w?{edgeCurvature:m}:{}}):null;v?(l.sourceOutline=b,l.outlinePath=v,l.outline=xt(v),f>.5?l.cornerSmoothing=f:delete l.cornerSmoothing,w?l.edgeCurvature=[...m]:delete l.edgeCurvature):(l.outline=b,delete l.outlinePath,delete l.sourceOutline,delete l.cornerSmoothing,delete l.edgeCurvature);for(let h=0;h<(l.holes?.length??0);h+=1)at(e,{floorId:n.floorId,objectId:l.id,points:l.holes[h],holeIndex:h});JSON.stringify(l)!==g&&(r=!0,i.add(l.id))}}catch(s){for(let{section:l,snapshot:c}of a.values()){let d=l;for(let g of Object.keys(d))delete d[g];Object.assign(l,structuredClone(c))}throw s}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}function oa(e,t,n={}){let o=!1;for(let i of t){let a=Ft(e,{floorId:i.floorId,sectionIds:[i.sectionId],patch:{height:i.height,rake:i.rake,surfaceKind:i.surfaceKind}});o||=a.changed}if(n.stage){let i=C(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);i&&i.role!=="stage"&&(i.role="stage",o=!0),i&&n.stage.stageKind&&!i.stageKind&&(i.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:i,floorId:a,role:r}of n.roles??[]){let s=C(e,a).objects.find(l=>l.type==="shape"&&l.id===i);s&&!s.role&&(s.role=r,o=!0)}for(let{floorId:i,point:a}of n.focal??[]){let r=je(a,"focalPoint"),s=i?e.floors?.find(c=>c.id===i):void 0,l=s?s.focalPoint:e.focalPoint;l?.x===r.x&&l?.y===r.y||(s?s.focalPoint=r:e.focalPoint=r,o=!0)}return e.floors?.length&&ie(e),{changed:o}}var Nt=.15,Dt=1.6;var ra=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Kt(e){let t=ra.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 $t(e,t){let n=a=>{let r=Kt(a);if(!r)return null;let s=h=>{let p=h/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4},l=s(r[0]),c=s(r[1]),d=s(r[2]),g=(.4124*l+.3576*c+.1805*d)/.95047,b=.2126*l+.7152*c+.0722*d,f=(.0193*l+.1192*c+.9505*d)/1.08883,y=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=y(g),w=y(b),v=y(f);return[116*w-16,500*(m-w),200*(w-v)]},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 Gt(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function io(e){return .2126*Gt(e[0])+.7152*Gt(e[1])+.0722*Gt(e[2])}function st(e,t){let n=Kt(e),o=Kt(t);if(!n||!o)return null;let i=io(n),a=io(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var ao=["butt","round","square"],so=["miter","round","bevel"],co=["none","arrow"];function Bt(e){return e==="line"||e==="polyline"}var lo=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Kl=lo.map(e=>e.key),ia=new Map(lo.map(e=>[e.key,e]));function Fe(e){return typeof e=="string"&&ia.has(e)}var aa=new Set(["companion","child","senior","student","membership","custom"]);function he(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=r.toLocaleLowerCase("en"),l=n.get(s);if(l)throw new u("duplicate_category_label",`Categories ${l} and ${a} share the same label`,{categoryKeys:[l,a],label:r});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.referenceDirectSeatImport!==void 0){let c=i.referenceDirectSeatImport;if(c.assetId!==c.assetId.trim()||c.assetId.length>160||!c.assetId||c.familyId!==c.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(c.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.seatGlyph!=null&&!Fe(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let c=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),y=f.toLocaleLowerCase("en");if(!b||b.length>160||c.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(y))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!aa.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(v=>v.normalize("NFKC").trim()),w=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(v=>!v||v.length>160)||new Set(m).size!==m.length)||w&&(!w.length||w.some(v=>!Me.some(h=>h.key===v))||new Set(w).size!==w.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...m?{seatLabels:m}:{},...w?{accessibility:[...w]}:{}},!g.applicability.seatLabels&&!g.applicability.accessibility&&delete g.applicability}if(g.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(g.evidence.provenance)||typeof g.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(g.evidence.sourceDescription=g.evidence.sourceDescription.normalize("NFKC").trim(),!g.evidence.sourceDescription||g.evidence.sourceDescription.length>240||g.evidence.capturedAt!==void 0&&(g.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(g.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}c.add(b),d.add(y)}}}return o}function fo(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let s=o.find(g=>g.key===r.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let l=structuredClone(r.patch),{tiers:c,...d}=l;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(s,d),s.notForSale===!1&&delete s.notForSale,Object.prototype.hasOwnProperty.call(l,"tiers")&&(c==null?delete s.tiers:s.tiers=c?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete s.referenceDirectSeatImport}let i=he(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function sa(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=he(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 ca(e,t){let n=t.categoryKeys.map(l=>l.trim()),o=e.categories.map(l=>l.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(l=>!n.includes(l)),r=n.filter(l=>!i.has(l));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((l,c)=>l===o[c]))return{changed:!1,categoryKeys:o,categories:e.categories};let s=new Map(e.categories.map(l=>[l.key,l]));return e.categories=he(n.map((l,c)=>{let d=structuredClone(s.get(l));return l!==o[c]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var zt=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function uo(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 la(e,t){let n=uo(e),o=uo(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var da=3600;function go(e,t,n=zt){return n.find(i=>e.every(a=>la(i,a)>=da))??n[t%n.length]}function ua(e,t){let n=t?.palette??zt;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return fo(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 fa(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(e.categories),a=i.find(l=>l.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=he(i),s=JSON.stringify(r)!==JSON.stringify(e.categories);return s&&(e.categories=r),{changed:s,category:e.categories.find(l=>l.key===t.categoryKey),categories:e.categories}}function bo(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let l=t.idFactory("cat").trim();if(l&&!n.has(l)){o=l;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=he([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var ga=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],ba={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function ha(e,t){let n=ba[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var pa=26;function ya(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,s,l]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],c=n-o/2,d=g=>Math.round((g+c)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(s)}${d(l)}`}function ma(e,t,n){let o=r=>e.every(s=>{let l=$t(r,s);return l==null||l>=pa}),i=r=>{let s=st(r,"#12151d"),l=st(r,"#ffffff");return(s??0)>=3||(l??0)>=3},a=t.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let s of[.52,.44,.6]){let l=ya(r,.62,s);if(o(l)&&i(l))return l}return n}function ho(e,t){let n=et.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function wa(e){let t=new Map;for(let n of k(e))for(let o of n.objects){let i=et.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of tt(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=t.get(r)??new Set;s.add(i.objectType),t.set(r,s)}}return t}function xa(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 po(e,t,n){let o=wa(e),i=c=>{let d=o.get(c);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(c=>c.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let c=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(c)return{kind:"existing",categoryKey:c.key,label:c.label}}let r=et.find(c=>c.objectType===n),s=a?ho(a.label,n):n==="gaArea"?"General Admission":r.creationWord,l=e.categories.find(c=>c.label.toLowerCase()===s.toLowerCase()&&i(c.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:xa(e,s)}}function Sa(e,t,n,o){let i=po(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 Ia(e,n,a,i.label,o)}function Ia(e,t,n,o,i){let a=i.palette??ga,r=e.categories.map(d=>d.color),s=i.suggestColor?.(r.map(d=>d.toLowerCase()))??go(r,e.categories.length),l=ma(r,ha(t,a),s),c=bo(e,{label:o,color:l,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=c.categories,c.category.key}function va(e,t){let n=new Set;for(let o of k(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function Ca(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=va(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=he(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var Oa=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],Ra=["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 Oa){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=E(r,`Theme ${a}`))}if(n.fontFamily===null)delete i.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");i.fontFamily=a}if(n.seatScale===null)delete i.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<Nt||n.seatScale>Dt)throw new u("invalid_operation",`Theme seatScale must be from ${Nt} to ${Dt}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=ee(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let s of Ra){let l=n.venue3d[s];l===null?delete a[s]:l!==void 0&&(a[s]=E(l,`3D venue ${s}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function _a(e,t){let n=t.url===null?null:ee(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(g=>g.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let l=(s.viewFromSeatUrl??void 0)===o,c=o?t.metadata===null?void 0:t.metadata??(l?s.viewFromSeatMeta:void 0):void 0,d=!l||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(c??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=c,{changed:d,scope:"floor",floorId:t.floorId,url:s.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function Aa(e,t){let n=Xe(e,t.floorId),o=Rn(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 ct(e,t){j(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let s={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(s.left,s.center,s.right)||Object.values(s).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let c=C(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:t.rowLabelStart??c,seatLabelStart:t.seatLabelStart??1}}function Ma(e,t,n){let o=n*Q;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function ja(e,t,n,o){let i=Math.abs(o-n)*Q,a=[["left",.25],["center",.5],["right",.75]].flatMap(([c,d])=>{let g=e.aisleGaps[c];if(!g)return[];let b=g/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((c,d)=>c[0]-d[0]),r=[];for(let c of a){let d=r[r.length-1];d&&c[0]<=d[1]?d[1]=Math.max(d[1],c[1]):r.push([...c])}let s=[],l=0;for(let c of r)c[0]-l>1e-6&&s.push([l,c[0]]),l=Math.max(l,c[1]);return 1-l>1e-6&&s.push([l,1]),s.filter(([c,d])=>t*i*(d-c)>=e.seatPitch*.75)}function La(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((l,c)=>l+c,0),a=e.map(l=>o*l/i),r=a.map(l=>2+Math.floor(l)),s=t-r.reduce((l,c)=>l+c,0);return a.map((l,c)=>({index:c,fraction:l-Math.floor(l)})).sort((l,c)=>c.fraction-l.fraction||l.index-c.index).forEach(({index:l})=>{s-- >0&&r[l]++}),r}function lt(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,l=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,c=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(c-l)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(c-l)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=ja(e,r,l,c);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([y,m])=>r*Math.abs(c-l)*Q*(m-y)),b=e.fit==="fixed-count"?La(g,e.seatsPerRow):g.map(y=>Math.max(2,Math.round(y/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([y,m],w)=>{let v=l+(c-l)*y,h=l+(c-l)*m;e.facing==="outward"&&([v,h]=[h,v]);let p=b[w];if(p>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let x=Math.abs(h-v)*Q/(p-1),S=2*r*Math.sin(x/2),I={type:"row",id:n(i,w),label:U(e.rowLabelStart+i),origin:Ma(e.center,r,v),rotation:-v,curve:h-v,seatCount:p,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:w}};o.push(I),f+=p})}return o}function Ut(e,t){let n=ct(e,t),o=C(e,t.floorId),i=lt(n,"preview-arc-fan",(l,c)=>`preview-fan-${l}-${c}`),a=i.map(l=>l.seatSpacing),r=Math.max(...a.map(l=>Math.abs(l-n.seatPitch))),s=[];return r>n.seatPitch*.12&&s.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((l,c)=>l+c.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(l=>l>0).length,warnings:s}}function ka(e,t){let n=ct(e,t),o=C(e,t.floorId),i=new Set,a=M(e,"fan",t.idFactory,i),r=lt(n,a,()=>M(e,"r",t.idFactory,i)),s=Ut(e,t),l=null,c=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(c){if(c.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=oe(r);g&&(l=M(e,"sec",t.idFactory,i),d={type:"section",id:l,label:c,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:l,groupId:a,logicalRowCount:s.logicalRowCount,rowSegmentCount:s.rowSegmentCount,totalSeats:s.totalSeats,innerRadius:s.innerRadius,outerRadius:s.outerRadius,minSeatSpacing:s.minSeatSpacing,maxSeatSpacing:s.maxSeatSpacing,maxPitchDeviation:s.maxPitchDeviation,aisleCount:s.aisleCount,warnings:s.warnings}}function yo(e,t){let n=C(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},l=ct(e,s),c=new Set(lt(l,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(c.size!==d.size||[...c].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return s}function Ea(e,t){yo(e,{floorId:t.floorId,groupId:t.groupId});let n=ct(e,t),o=C(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),s=new Set,l=lt(n,t.groupId,(m,w)=>r.get(`${m}:${w}`)??M(e,"r",t.idFactory,s)),c=Ut(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=oe(l);m&&(g={type:"section",id:a?.id??M(e,"sec",t.idFactory,s),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,w)=>b.has(m.id)?w:1/0)),y=o.objects.filter(m=>!b.has(m.id));return y.splice(Number.isFinite(f)?f:y.length,0,...l,...g?[g]:[]),o.objects.splice(0,o.objects.length,...y),{floorId:o.floorId,rowIds:l.map(m=>m.id),sectionId:g?.id??null,groupId:t.groupId,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function Ta(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 mo(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 Fa(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=Ta(e),s=Et(t.rotation??0),l=t.curve??0,c=t.style,d=c?M(e,"rowblock",t.idFactory,a):void 0,g=c?mo({style:c,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:l}):void 0,b={x:Math.cos(s*J),y:Math.sin(s*J)},f={x:-b.y,y:b.x},y=Array.from({length:t.rowCount},(v,h)=>{let p=c==="intertwined"&&h%2===1?o/2:0,x={type:"row",id:M(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+f.x*h*n+b.x*p,y:t.origin.y+f.y*h*n+b.y*p},rotation:s,curve:l,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return c&&d&&g&&(x.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:c,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:l,signature:g}),x});i.objects.push(...y);let m=null,w=t.sectionLabel?.trim();if(w){let v=oe(y);if(v){let h={type:"section",id:M(e,"sec",t.idFactory,a),label:w,outline:v};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:y.map(v=>v.id),sectionId:m,createdIds:[...y.map(v=>v.id),...m?[m]:[]]}}function wo(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 Na(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 Da=456;function xo(e){let t=Math.sqrt(Math.max(1,e)*Da);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ga(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}=xo(t.capacity),r=Na(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:M(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function Ka(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=wo(e,"T"),s=[];for(let l=0;l<t.tableRows;l+=1)for(let c=0;c<t.tableColumns;c+=1)s.push({type:"table",id:M(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.tableColumns-1)/2)*n,y:t.center.y+(l-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...s),{floorId:i.floorId,tableIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function $a(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=wo(e,"B"),s=[];for(let l=0;l<t.boothRows;l+=1)for(let c=0;c<t.boothColumns;c+=1)s.push({type:"booth",id:M(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.boothColumns-1)/2)*n,y:t.center.y+(l-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function Ba(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(b=>b.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(b=>b.id)});let l=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!l||l.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let c=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=t.idFactory("rowgroup");if(f&&!c.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:l,...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 za(e,t){let n=C(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),i=t.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((s,l)=>s.segmentedRow.componentIndex-l.segmentedRow.componentIndex).map(s=>s.id);for(let s of a)delete s.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function Ua(e,t){let n=C(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.groupId).sort((r,s)=>r.segmentedRow.componentIndex-s.segmentedRow.componentIndex);if(o.length<2)throw new u("object_not_found","The segmented row is incomplete or missing on the selected floor");if(t.boundaries&&(t.boundaries.length!==o.length-1||t.boundaries.some(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=t.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,s)=>{let l=r.segmentedRow,c=l.viewFromSeatUrl;i!==void 0&&(l.displayLabel=i),t.boundaries&&s>0&&(l.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(l.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete l.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(l.viewFromSeatUrl=t.viewFromSeatUrl),!l.viewFromSeatUrl||t.viewFromSeatMeta===null?delete l.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?l.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&l.viewFromSeatUrl!==c&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ha(e,t){if(typeof t.groupId!="string"||!t.groupId)throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let n=C(e,t.floorId),o=n.objects.filter(R=>R.type==="row"&&R.rowBlockGeneration?.groupId===t.groupId).sort((R,z)=>R.rowBlockGeneration.rowIndex-z.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((R,z)=>{let A=R.rowBlockGeneration;return A.kind!=="row-block-v1"||A.rowIndex!==z||A.signature!==i.signature||JSON.stringify(A)!==JSON.stringify({...i,rowIndex:z})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,s=t.rowCount??i.rowCount,l=t.seatsPerRow??i.seatsPerRow,c=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?Et(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.origin}:{...i.origin};if(!Number.isInteger(s)||s<1||s>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(l)||l<1||l>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![c,d].every(R=>Number.isFinite(R)&&R>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let y=mo({style:r,origin:f,rotation:b,rowCount:s,seatsPerRow:l,rowGap:c,seatSpacing:d,curve:g}),m={x:Math.cos(b*J),y:Math.sin(b*J)},w={x:-m.y,y:m.x},v=new Map(o.map(R=>[R.rowBlockGeneration.rowIndex,R])),h=new Set,p=new Set(n.objects.filter(R=>R.type==="row").filter(R=>!o.includes(R)).map(R=>R.label)),x=n.objects.filter(R=>R.type==="row").length,S=()=>{for(;p.has(U(x));)x+=1;let R=U(x);return p.add(R),x+=1,R},I=[],P=[];for(let R=0;R<s;R+=1){let z=r==="intertwined"&&R%2===1?d/2:0,A=v.get(R);A||(A={type:"row",id:M(e,"r",t.idFactory,h),label:S(),origin:{...f},rotation:b,curve:g,seatCount:l,seatSpacing:d,categoryKey:o[0].categoryKey},P.push(A.id)),A.origin={x:f.x+w.x*R*c+m.x*z,y:f.y+w.y*R*c+m.y*z},A.rotation=b,A.curve=g,A.seatCount=l,A.seatSpacing=d,delete A.path,delete A.arcFanGeneration,A.overrides&&(A.overrides=A.overrides.filter(Ie=>Ie.index<l),A.overrides.length||delete A.overrides),A.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:R,rowCount:s,seatsPerRow:l,origin:{...f},rotation:b,rowGap:c,seatSpacing:d,curve:g,signature:y},I.push(A)}let N=o.slice(s).map(R=>R.id),G=Math.min(...o.map(R=>n.objects.indexOf(R))),K=new Set(o.map(R=>R.id)),$=n.objects.filter(R=>!K.has(R.id));return $.splice(G,0,...I),n.objects.splice(0,n.objects.length,...$),{floorId:n.floorId,groupId:t.groupId,rowIds:I.map(R=>R.id),createdRowIds:P,removedRowIds:N,changed:a!==JSON.stringify(I)||P.length>0||N.length>0}}function Ht(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Vt(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function qt(e){return Vt(Ht(e),40)}function So(e,t=39){return Vt(Ht(e),Math.max(1,t))}function pe(e,t=80){return Vt(Ht(e),Math.max(1,t))}function Io(e){return pe(e).toLocaleLowerCase("en")}function Jt(e){return Io(e)}function vo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Va(e){let t=vo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(Y(e,o,i))}return n}function qa(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=vo(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 Ja(e){return e.type==="row"?[e.label,...Va(e)]:e.type==="table"?[e.label,...qa(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...Z(e)]:[]}function Co(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of Ja(o)){let a=Jt(i);a&&n.add(a)}return n}function Xa(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Jt(e)];for(let i=0;i<t;i+=1)o.push(Jt(Y(n,i)));return o.filter(Boolean)}function Oo(e,t,n){let o=Xa(t,n);if(!o.length||o.some(i=>e.has(i)||Le(i)))return!1;for(let i of o)e.add(i);return!0}var Ya=1e-6,Qa=160,Za=.001,Wa=1e-5;function ye(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>Qa)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function Ro(e){return typeof e=="string"&&So(e)||void 0}function Po(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(Xt(e.origin)&&Xt(t.start)&&Xt(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=Za+Math.max(1,i)*Wa;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<=Ya)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,l=Math.abs(((e.rotation-s)%360+540)%360-180),c=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return l<=c}function Xt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var es=300;function ts(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=qt(i),r=0;return()=>{for(;a&&r<4096;r+=1){let s=`${a}-${U(r)}`;if(!t.has(s))return t.add(s),r+=1,s}return o()}}}function ns(e){let t=Co(B(e));return(n,o)=>{let i=pe(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,s=r?`${pe(i,80-r.length)}${r}`:i;if(s&&Oo(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function os(e){return{ordinaryFor:ts(e),direct:ns(e)}}function _o(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function rs(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[s,l]of r.rows.entries()){let c=ye(`${r.sourceGroupId}:${s}`),d=c&&ye(l.directSourceRowId)===c?c:void 0;d&&o.set(d,o.has(d)?null:l)}let i=new Map;for(let r of e){let s=ye(r.referenceScan?.directSourceRowId);if(!s){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let l=i.get(s)??[];l.push(r),i.set(s,l)}let a=new Map;for(let[r,s]of i){let l=s.filter(b=>b.overrides?.length);if(!l.length)continue;let c=o.get(r),d=l[0],g=d.overrides;if(s.length!==1||l.length!==1||!g||!c||!Po(d,c))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:s.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function Ao(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 is(e,t,n,o,i,a,r){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=Ao(t,n,r).filter(g=>F(L(g),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let l=[],c=0;for(let[d,g]of e.rows.entries()){let b=Math.min(es,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,y=g.end.y-g.start.y,m=Math.hypot(f,y),w=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(w)||w<=0)continue;let v=m>0?Math.atan2(y,f)*180/Math.PI:0,h=e.sourceGroupId?ye(`${e.sourceGroupId}:${d}`):void 0,p=h&&ye(g.directSourceRowId)===h?h:void 0,x=p?Ro(g.directReviewedSuffix):void 0,S=e.sourceGroupId&&g.rowLabel?pe(g.rowLabel):"",I=e.sourceGroupId&&g.rowDisplayLabel?pe(g.rowDisplayLabel):"",P=!!e.sourceGroupId&&g.rowDisplayLabel==="";l.push({label:S?a(S,b):i(),displayLabel:I||(P?"":String(d+1)),origin:{x:g.start.x,y:g.start.y},rotation:v,seatCount:b,seatSpacing:w,...p?{directSourceRowId:p}:{},...x?{directReviewedSuffix:x}:{}}),c+=b}return{skip:null,rows:l,seats:c}}function as(e,t,n){j(e,n.categoryKey);let o=C(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=n.categoryKeyForSection?.(h)??n.categoryKey;j(e,p),r.set(h,p)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&s){let h=Ao(o.objects,i,a.id).filter(p=>F(L(p),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:h.map(p=>p.id)}]}}let l=o.objects.filter(h=>_o(h,i,a?.id)),c=rs(l,t,a?.id),d=[],g=o.objects.filter(h=>_o(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],y=[],m=new Set,w=0,v=os(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=is(h,o.objects,i,t.seatPitch,v.ordinaryFor(h.name),v.direct,a?.id);if(p.skip){f.push(p.skip);continue}let x=p.rows.map(S=>({type:"row",id:M(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&&c.has(S.directSourceRowId)?{overrides:structuredClone(c.get(S.directSourceRowId))}:{}}));o.objects.push(...x);for(let S of x)y.push(S.id);b.push({sectionId:h.sectionId,name:h.name,seats:p.seats,rows:x.length}),w+=p.seats}return{floorId:o.floorId,assetId:i,createdRowIds:y,removedRowIds:d,totalSeats:w,perSection:b,skipped:f}}function jo(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.objectIds)];if(!i.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=i.map(m=>o.objects.find(w=>(w.type==="table"||w.type==="booth")&&w.id===m)),r=i.filter((m,w)=>!a[w]);if(r.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:r});let s=a[0].type;if(a.some(m=>m.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[m,w,v]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(w)||w<1||w>v)throw new u("invalid_operation",`${m} must be a whole number from 1 to ${v}`);for(let[m,w]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(w)||w<30||w>2e3)throw new u("invalid_operation",`${m} must be from 30 to 2000 chart units`);let l=t.rows*t.columns;if(l<2)throw new u("invalid_operation","Choose at least two grid cells");let c=i.length*(l-1);if(c>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((m,w)=>m+(w.type==="table"?w.seatCount:1),0),b=(e.floors?.length?e.floors.flatMap(m=>m.objects):e.objects).reduce((m,w)=>m+(w.type==="row"||w.type==="table"?w.seatCount:w.type==="gaArea"?Math.max(0,Math.floor(w.capacity)):w.type==="booth"?1:0),0),f=d*(l-1),y=n.maxInventory??1e5;if(b+f>y)throw new u("invalid_operation",`Grid inventory would exceed the ${y} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:i,sourceCount:i.length,cells:l,createdCount:c,addedInventory:f,resultingInventory:b+f,provenanceRemovedCount:a.filter(m=>!!m.referenceInventorySource).length*(l-1)}}}function ss(e,t,n={}){return jo(e,t,n).preview}function cs(e,t,n={}){let{target:o,sources:i,preview:a}=jo(e,t,n),r=new Set,s=new Set((e.floors?.length?e.floors.flatMap(g=>g.objects):e.objects).flatMap(g=>"label"in g&&g.label?[g.label]:[])),l=[],c=(g,b)=>{let f=Math.max(2,b),y=w=>{let v=`-${w}`;return`${g.slice(0,Math.max(1,80-v.length))}${v}`},m=y(f);for(;s.has(m);)m=y(++f);return s.add(m),m},d=1;for(let g=0;g<t.rows;g++)for(let b=0;b<t.columns;b++)if(!(g===0&&b===0)){d+=1;for(let f of i){let y=structuredClone(f);y.id=M(e,y.type,t.idFactory,r),y.label=c(f.label,d),y.center={x:f.center.x+b*t.stepX,y:f.center.y+g*t.stepY},delete y.referenceInventorySource,l.push(y)}}return o.objects.push(...l),{...a,createdIds:l.map(g=>g.id)}}function ls(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=E(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var ds=new Set(Me.map(e=>e.key));function Ne(e){return`${e.rowId}:${e.index}`}function us(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 fs(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,Fe(e.glyph)||delete e.glyph;let n=Pe(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"&&Je(t,e)}function gs(e){return Object.keys(e).every(t=>t==="index")}function Lo(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(e,t),i=[],a=new Set,r=new Map;for(let s of n){let l=Ne(s);if(a.has(l))continue;a.add(l);let c=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!c)throw new u("object_not_found",`Unknown row or table for seat: ${l}`,{seatId:l,objectId:s.rowId});if(c.type==="table"&&(c.bookAsWhole||c.variableOccupancy))throw new u("invalid_operation",`Table "${c.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:l,tableId:c.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=c.seatCount)throw new u("invalid_operation",c.type==="row"?`Seat index is outside row bounds: ${l}`:`Chair index is outside table bounds: ${l}`,{seatId:l,objectId:s.rowId,index:s.index,seatCount:c.seatCount});i.push({rowId:s.rowId,index:s.index}),r.set(c.id,c)}return{floorId:o.floorId,refs:i,owners:r}}function Yt(e,t){let n=Lo(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&&!Fe(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=>!ds.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(c=>c.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,l=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(s&&l)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:Ne(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=ee(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&be(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let s=n.owners.get(a.rowId),l=JSON.stringify(s.overrides??[]),c=s.overrides??(s.overrides=[]),d=c.find(b=>b.index===a.index);d||(d={index:a.index},c.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(y=>y!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let y=ls(d.labelStyle,f);y?d.labelStyle=y:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),fs(d,s),gs(d)&&(s.overrides=c.filter(b=>b!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==l&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map(Ne)}}function bs(e,t){let n=Lo(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(l=>l.rowId===i).map(l=>l.index)),s=a.overrides.filter(l=>!r.has(l.index));s.length!==a.overrides.length&&(o=!0),a.overrides=s,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map(Ne)}}function hs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(p=>p.type==="row"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&j(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,p=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!p.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${p.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:s,labelRotation:l,labelStyleShape:c,displayLabel:d,displayType:g,...b}=t.patch,f=d===void 0?{}:{displayLabel:d},y=ge(f,"Row"),m=g===void 0?void 0:_t(g,"Row");if(r!==void 0&&be(r,"Row"),s!==void 0&&!["start","end","both","none"].includes(s))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(l!=null&&(!Number.isFinite(l)||l<-180||l>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(c!==void 0&&c!=="plain"&&c!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&Qe(b.labelPresentation,"Row");let w=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),v=!1;for(let h of i){let p=JSON.stringify(h),x=w(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(I=>I.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),S){let I=L(h);h.origin={x:h.origin.x+S.x-I.x,y:h.origin.y+S.y-I.y}}if(JSON.stringify(h)!==p&&(v=!0),w(h)!==x&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let I=JSON.stringify(h.labelPresentation??null),P=Ze(h.labelPresentation,r);P?h.labelPresentation=P:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(s!==void 0){let I=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(l!==void 0||c!==void 0){let I=JSON.stringify(h.labelPresentation??null),P=h.labelPresentation?structuredClone(h.labelPresentation):{};l===null?delete P.rotation:l!==void 0&&(P.rotation=l),c!==void 0&&(P.style=c),h.labelPresentation=P,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(m!==void 0){let I=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==I&&(v=!0)}if(d!==void 0){let I=h.displayLabel;y?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==I&&(v=!0)}}return{floorId:n.floorId,changed:v,rowIds:o}}var ps=3;function dt(e){return(e%360+360)%360}function ys(e){let t=e.rotation*J;return{x:Math.cos(t),y:Math.sin(t)}}function ms(e,t){let n=Math.abs(dt(e-t));return n>180&&(n=360-n),n}function me(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function ko(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 ws(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 Eo(e,t){let n=ko(e),o={x:-n.y,y:n.x},i=L(e[0]),a=e.map(l=>({row:l,coord:me(L(l),i,o)})).sort((l,c)=>l.coord-c.coord),r=a[0].coord,s=!1;return a.forEach((l,c)=>{let d=r+c*t-l.coord;Math.abs(d)>1e-6&&(ws(l.row,o.x*d,o.y*d),delete l.row.arcFanGeneration,delete l.row.rowBlockGeneration,s=!0)}),s}function xs(e,t){let n={x:-t.y,y:t.x},o=L(e[0]),i=e.map(r=>me(L(r),o,n)).sort((r,s)=>r-s);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function Ss(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=ue(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=dt(Math.atan2(a,i)/J)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function Is(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 vs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(I=>I.type==="row"&&I.id===S)),a=o.filter((S,I)=>!i[I]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(S=>S.path||S.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged. Straighten the rows first, then merge.",{rowIds:s.map(S=>S.id)});let l=r[0],c=r.find(S=>ms(S.rotation,l.rotation)>ps);if(c)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[l.id,c.id]});let d=ys(l),g={x:-d.y,y:d.x},b=Math.max(8,l.seatSpacing*.6),f=r.find(S=>Math.abs(me(S.origin,l.origin,g))>b);if(f){let S=Math.round(Math.abs(me(f.origin,l.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${S} units from the first.`,{rowIds:[l.id,f.id]})}let y=r.slice().sort((S,I)=>me(S.origin,l.origin,d)-me(I.origin,l.origin,d)),m=y.reduce((S,I)=>S+I.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let w=y[0],v=[],h=0;for(let S of y){if(S.overrides)for(let I of S.overrides)v.push({...structuredClone(I),index:I.index+h});h+=S.seatCount}w.seatCount=m,w.curve=0,delete w.path,v.length?w.overrides=v:delete w.overrides,delete w.arcFanGeneration,delete w.rowBlockGeneration;let p=y.slice(1).map(S=>S.id),x=new Set(p);for(let S=n.objects.length-1;S>=0;S--)x.has(n.objects[S].id)&&n.objects.splice(S,1);return{floorId:n.floorId,changed:!0,rowId:w.id,removedRowIds:p,seatCount:m}}function Cs(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. 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=ue(o),s=i>1?o.curve/(i-1):0,l=i-a,c={type:"row",id:M(e,"r",t.idFactory,new Set),label:Is(n.objects,o.label),origin:{...r[a]},rotation:dt(o.rotation-s*a),curve:s*(l-1),seatCount:l,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(c.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(c.seatLabelStart=o.seatLabelStart),o.commercial&&(c.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(c.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(c.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(c.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,c.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(c.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,c),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:c.id,firstSeatCount:a,secondSeatCount:l,newLabel:c.label}}function Os(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(s=>n.objects.find(l=>l.type==="row"&&l.id===s)),a=o.filter((s,l)=>!i[l]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=Eo(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function Rs(e,t){let n=C(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),l=s();for(let b of r)Ss(b);let c=ko(r),d=dt(Math.atan2(c.y,c.x)/J);for(let b of r)b.rotation=d;let g=xs(r,c);return Eo(r,g),{floorId:n.floorId,changed:s()!==l,rowIds:o,gap:g}}var ft=cr(require("polygon-clipping"),1),To=100,Fo=512,Qt=8192,Uo=64,No=1e7,T=1e-7;function Ho(e,t){return Math.abs(e.x-t.x)<=T&&Math.abs(e.y-t.y)<=T}function Vo(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ho(t[0],t[t.length-1]);)t.pop();return t}function De(e,t,n){let o=q(t,n,e);return Math.abs(o)>T?!1:e.x>=Math.min(t.x,n.x)-T&&e.x<=Math.max(t.x,n.x)+T&&e.y>=Math.min(t.y,n.y)-T&&e.y<=Math.max(t.y,n.y)+T}function qo(e,t,n,o){let i=q(e,t,n),a=q(e,t,o),r=q(n,o,e),s=q(n,o,t);return(i>T&&a<-T||i<-T&&a>T)&&(r>T&&s<-T||r<-T&&s>T)?!0:Math.abs(i)<=T&&De(n,e,t)||Math.abs(a)<=T&&De(o,e,t)||Math.abs(r)<=T&&De(e,n,o)||Math.abs(s)<=T&&De(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)&&qo(e[t],e[n],e[o],e[i]))return!0}}return!1}function Do(e,t){return e.some((n,o)=>t.some((i,a)=>qo(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function Zt(e,t){return!t.some((n,o)=>De(e,n,t[(o+1)%t.length]))&&F(e,t,void 0)}function gt(e,t,n){let o=Vo(e);if(o.length<3||o.length>Fo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>No||Math.abs(i.y)>No||Ho(i,o[(a+1)%o.length]))||Math.abs(ve(o))<=T||Ps(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Fo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function _s(e){let t=gt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Uo)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>gt(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((s,l)=>{let c=a[(l+1)%a.length];return[s,{x:(s.x+c.x)/2,y:(s.y+c.y)/2}]}).every(s=>Zt(s,t))||Do(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(Do(a,o[s])||Zt(a[0],o[s])||Zt(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function ut(e){return e.map(t=>[t.x,t.y])}function Go(e){return Vo(e.map(([t,n])=>({x:t,y:n})))}function Ko(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 As(e){return e.reduce((t,n)=>t+(Ko(n[0]??[])-n.slice(1).reduce((o,i)=>o+Ko(i),0)),0)}function Wt(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Wt).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Wt(t[n])}`).join(",")}}`}function $o(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 Bo(e){return Wt({categoryKey:e.categoryKey,displayLabel:$o(e,"displayLabel",80),displayType:$o(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function zo(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 Ms(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function Jo(e,t,n={}){let o=C(e,t.floorId),i=[...new Set(t.gaAreaIds)];if(i.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(i.length>To)throw new u("invalid_operation",`Join Areas supports at most ${To} areas at once`);let a=i.map(O=>o.objects.find(_=>_.type==="gaArea"&&_.id===O)),r=i.filter((O,_)=>!a[_]);if(r.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:r});let s=a;j(e,s[0].categoryKey);let l=Bo(s[0]),c=s.find(O=>Bo(O)!==l);if(c)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[s[0].id,c.id]});let d=ke(e).objectToSection,g=d.get(s[0].id)??"__ungrouped__",b=s.find(O=>(d.get(O.id)??"__ungrouped__")!==g);if(b)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,b.id],sectionIds:[g,d.get(b.id)??"__ungrouped__"]});let f=s.reduce((O,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>X)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return O+_.capacity},0);if(f>X)throw new u("invalid_operation",`Joined GA capacity would be ${f}, over the ${X}-unit area limit`,{capacity:f});let y=B(e).reduce((O,_)=>O+re(_),0),m=n.maxInventory??1e5;if(y>m)throw new u("invalid_operation",`Chart inventory exceeds the ${m}-unit publication limit`,{inventory:y});let w=s.map(_s),v=w.reduce((O,_)=>O+_.outer.length+_.holes.reduce((V,W)=>V+W.length,0),0);if(v>Qt)throw new u("invalid_operation",`Join Areas supports at most ${Qt} source vertices`,{vertexCount:v});let h;try{let O=w.map(W=>[ut(W.outer)]);if(h=ft.default.union(O[0],...O.slice(1)),h.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:h.length});let _=w.flatMap(W=>W.holes.map(yt=>[ut(yt)]));_.length&&(h=ft.default.difference(h,..._));let V=w.findIndex(W=>{let yt=[ut(W.outer),...W.holes.map(ut)];return As(ft.default.intersection(yt,h))<=T});if(V>=0)throw new u("invalid_operation",`GA area ${s[V].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[V].id})}catch(O){throw O instanceof u?O:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:O instanceof Error?O.message:"polygon_union_failed"})}if(h.length!==1||!h[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:h.length});let p=Go(h[0][0]),x=h[0].slice(1).map(Go),S=p.length+x.reduce((O,_)=>O+_.length,0);if(x.length>Uo||S>Qt)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:x.length,vertexCount:S});gt(p,"outline",s[0].id),x.forEach(O=>gt(O,"cutout",s[0].id));let I=new Map(o.objects.map((O,_)=>[O.id,_])),P=s.slice().sort((O,_)=>Ms(zo(O,I.get(O.id)??Number.MAX_SAFE_INTEGER),zo(_,I.get(_.id)??Number.MAX_SAFE_INTEGER))),N=P[0],G=structuredClone(e),K=C(G,o.floorId),$=K.objects.find(O=>O.type==="gaArea"&&O.id===N.id);$.points=structuredClone(p),x.length?$.holes=structuredClone(x):delete $.holes;let R=new Set(P.slice(1).map(O=>O.id));for(let O=K.objects.length-1;O>=0;O-=1)R.has(K.objects[O].id)&&K.objects.splice(O,1);let z=ke(G).objectToSection.get(N.id)??"__ungrouped__";if(z!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:N.id,beforeSectionId:g,afterSectionId:z});let A=[],Ie=new Set;for(let O of P){if(!Lt(O))throw new u("invalid_operation",`GA area ${O.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:O.id});let _=Z(O);if(_.length!==O.capacity||_.some(V=>Ie.has(V)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:O.id});_.forEach(V=>Ie.add(V)),A.push(...nt(O))}if(A.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let er=new Set(s.map(O=>O.id));for(let O of B(e).filter(_=>_.type==="gaArea"&&!er.has(_.id))){let _=Z(O).find(V=>Ie.has(V));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:O.id})}let tr=P.slice(1).map(O=>O.id);return{floorId:o.floorId,areaId:N.id,survivorLabel:N.label,removedAreaIds:tr,sourceAreaCount:P.length,capacity:f,inventorySegmentCount:A.length,outerVertexCount:p.length,holeCount:x.length,sectionId:g,points:p,...x.length?{holes:x}:{},segments:A}}function js(e,t,n={}){let{segments:o,...i}=Jo(e,t,n);return i}function Ls(e,t,n={}){let o=Jo(e,t,n),i=C(e,o.floorId),a=i.objects.find(c=>c.type==="gaArea"&&c.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes,a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments);let r=new Set(o.removedAreaIds);for(let c=i.objects.length-1;c>=0;c-=1)r.has(i.objects[c].id)&&i.objects.splice(c,1);let{segments:s,...l}=o;return{...l,changed:!0}}function ks(e,t){let n=C(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(c=>n.objects.find(d=>d.type==="shape"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.labelStyle!==void 0){let c=i.filter(d=>d.role!=="stage");if(c.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:c.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<fe||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${fe} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=E(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");if(r.labelStyle.direction!==void 0&&r.labelStyle.direction!==null&&!Fn.includes(r.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");for(let d of["bold","italic","underline"]){let g=r.labelStyle[d];if(g!=null&&typeof g!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=E(r.fill,"Shape fill")),r.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(r.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(r.stroke!==void 0&&r.stroke!==null){if(!Number.isFinite(r.stroke.width)||r.stroke.width<.5||r.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");r.stroke={color:E(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let c=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!c.length||c.length>20||c.some(d=>!d||d.length>100)||new Set(c).size!==c.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=c}if(r.lineCap!==void 0&&r.lineCap!==null&&!ao.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!so.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[c,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!co.includes(d))throw new u("invalid_operation",`Shape ${c} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let c=i.filter(d=>!Bt(r.kind??d.kind));if(c.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:c.map(d=>d.id)})}let l=!1;for(let c of i){let d=JSON.stringify(c);if(r.label===null?delete c.label:r.label!==void 0&&(c.label=r.label),r.labelStyle!==void 0){let g={...c.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),r.labelStyle.direction===null||r.labelStyle.direction==="horizontal"?delete g.direction:r.labelStyle.direction!==void 0&&(g.direction=r.labelStyle.direction),Object.keys(g).length?c.labelStyle=g:delete c.labelStyle}if(r.fill===null?delete c.fill:r.fill!==void 0&&(c.fill=r.fill),r.kind!==void 0&&(c.kind=r.kind,Bt(c.kind)||(delete c.lineCap,delete c.lineJoin,delete c.startEnding,delete c.endEnding)),r.stroke===null?delete c.stroke:r.stroke!==void 0&&(c.stroke={...r.stroke}),r.opacity===null?delete c.opacity:r.opacity!==void 0&&(c.opacity=r.opacity),r.heightM===null?delete c.heightM:r.heightM!==void 0&&(c.heightM=r.heightM),r.eventConfigurationIds===null?delete c.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(c.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete c.lineCap:r.lineCap!==void 0&&(c.lineCap=r.lineCap),r.lineJoin===null?delete c.lineJoin:r.lineJoin!==void 0&&(c.lineJoin=r.lineJoin),r.startEnding===null?delete c.startEnding:r.startEnding!==void 0&&(c.startEnding=r.startEnding),r.endEnding===null?delete c.endEnding:r.endEnding!==void 0&&(c.endEnding=r.endEnding),r.cornerRadius===null)delete c.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(c.width??1/0,c.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;c.cornerRadius=c.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(c)!==d&&(He(c),l=!0)}return{floorId:n.floorId,changed:l,shapeIds:o}}function Yo(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),s=Math.max(...o),l=Math.max(1,a-i),c=Math.max(1,s-r);return{cx:i+l/2,cy:r+c/2,width:l,height:c}}function Es(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let s=n.objects.find(c=>c.type==="shape"&&c.id===r.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let l=s.role==="stage"?Yo(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let c=s.points??[];if(c.length<3||c.some(w=>!Number.isFinite(w.x)||!Number.isFinite(w.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=c.map(w=>w.x),g=c.map(w=>w.y),b=Math.min(...d),f=Math.max(...d),y=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(y+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-y)}})();return{shape:s,update:r,box:l}}),a=!1;for(let{shape:r,update:s,box:l}of i)if(!(Math.abs(l.width-s.width)<1e-9&&Math.abs(l.height-s.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height;else{let c=s.width/l.width,d=s.height/l.height;r.points=(r.points??[]).map(g=>({x:l.cx+(g.x-l.cx)*c,y:l.cy+(g.y-l.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:s})=>({id:r.id,width:s.width,height:s.height}))}}function Ts(e,t){let n=C(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(s=>s.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(mn.map(s=>s.key)),a=t.updates.map(s=>{if(!i.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let l=n.objects.find(c=>c.type==="shape"&&c.id===s.stageId);if(!l)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(l.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:l,stageKind:s.stageKind,box:l.stageKind===s.stageKind?null:Yo(l)}}),r=!1;for(let s of a)s.box&&(s.shape.points=wn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",s.shape.stageKind=s.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Ns(e){return[...on(e)].map(([t,n])=>({key:t,...n}))}function Ds(e){if(!Array.isArray(e))return on(e);let t=new Map;for(let{key:n,target:o,evidence:i}of e)t.set(n,{target:o,evidence:i});return t}function on(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of k(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function bt(e){return Array.isArray(e)?e.map(bt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,bt(n)]))}function Gs(e,t){return JSON.stringify(bt(e))===JSON.stringify(bt(t))}function en(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Ks(e){return e?e.status==="retracted"?"retract":en(e)?"approve":"set":"clear"}function Qo(e,t){let n=Ds(e),o=on(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let s=n.get(r),l=o.get(r);if(s&&l&&Gs(s.evidence,l.evidence))continue;let c=l?.target??s?.target;c&&a.push({...c,operation:Ks(l?.evidence),...s?{before:s.evidence}:{},...l?{after:l.evidence}:{}})}return a}function $s(e,t){return Qo(e,t).some(n=>en(n.before)||en(n.after))}var Bs=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),zs=new Set(["generated","geometry-verified","configuration-verified"]),Us=new Set(["none","comparable-build-reference","actual-build-checked"]),Hs=new Set(["clear","partial","obstructed"]);function tn(e){return e.toISOString().slice(0,10)}function nn(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function xe(e,t,n){if(!nn(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function we(e,t,n){if(e!==void 0)return xe(e,t,n)}function ht(e,t,n){let o=n?[C(e,n)]:k(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function Zo(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Ge(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return Zo(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=ht(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=ht(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 pt(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=Zo(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=ht(e,t.objectId,t.floorId);return Yt(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=ht(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 Vs(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!nn(e.label,80)||!nn(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(!Hs.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>xe(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 Wo(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(!Bs.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!zs.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Us.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=we(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(g=>xe(g,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=we(e.assessedAt,40,"assessedAt")??tn(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=we(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:tn(new Date(r+365*24*60*60*1e3))),l=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(l)||l<r||l>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let c=we(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!c)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=we(e.sourceLabel,120,"sourceLabel");if(n!=="none"&&!d)throw new u("invalid_operation","Real-world evidence requires a buyer-safe source describing what was checked");if(n==="actual-build-checked"&&(e.modelLevel!=="configuration-verified"||!o))throw new u("invalid_operation","An actual-build check requires a configuration-verified model and an event configuration");return{schema:"seatlayer.seat-confidence/1",evidenceId:xe(e.evidenceId,120,"evidenceId"),modelVersion:xe(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...c?{approvedByRole:c}:{},...d?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:Vs(e.modeledTarget)}:{}}}function Se(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function qs(e,t){let n=Wo(t.evidence,t.now),o=JSON.stringify(Ge(e,t)??null),i=pt(e,t,n),a=JSON.stringify(Ge(e,t)??null);return Se(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function Js(e,t){let n=Ge(e,t);if(!n)return Se(t,{changed:!1});let o=pt(e,t,void 0);return Se(t,{changed:!0,...o,evidenceId:n.evidenceId})}function Xs(e,t){let n=Ge(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=xe(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=we(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:tn(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(r.basisSha256=s);let l=JSON.stringify(n),c=pt(e,t,r);return Se(t,{changed:l!==JSON.stringify(r),...c,evidenceId:r.evidenceId,status:"approved"})}function Ys(e,t){let n=Ge(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return Se(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=pt(e,t,o);return Se(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,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 cr=Object.create;var Ue=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var gr=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},fn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dr(t))!fr.call(e,i)&&i!==n&&Ue(e,i,{get:()=>t[i],enumerable:!(o=lr(t,i))||o.enumerable});return e};var br=(e,t,n)=>(n=e!=null?cr(ur(e)):{},fn(t||!e||!e.__esModule?Ue(n,"default",{value:e,enumerable:!0}):n,e)),hr=e=>fn(Ue({},"__esModule",{value:!0}),e);var ic={};gr(ic,{COLORBLIND_SAFE_PALETTE:()=>qt,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>Et,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Rt,MAX_BUYER_IMAGE_URL_LENGTH:()=>Nr,MAX_FLOOR_BASE_HEIGHT_M:()=>ot,addArcFanRows:()=>Ga,addBookableGridArray:()=>ps,addBoothArray:()=>qa,addChartCategory:()=>So,addChartFloor:()=>ui,addChartZone:()=>hi,addGAArea:()=>Ha,addRowBlock:()=>Ba,addTableArray:()=>Va,applyPolygonHole:()=>ea,applyReferenceScanRows:()=>gs,applySectionCornerSmoothing:()=>ca,applySectionEstimates:()=>la,applySectionOutlineShaping:()=>fo,applySectionRowFit:()=>Zi,approveConfidenceEvidence:()=>oc,arcFanInputForGroup:()=>Co,assignSectionInventoryCategory:()=>oa,automaticPlacementCenter:()=>Ta,clearConfidenceEvidence:()=>nc,compactChartDoc:()=>ei,compactRowOverrides:()=>Kn,compactTableOverrides:()=>$n,confidenceEvidenceChangeRequiresPublish:()=>Xs,confidenceEvidenceChanges:()=>ir,confidenceEvidenceIndex:()=>Hs,confirmReferenceCategoryOutputColor:()=>ma,convertGeneratedSectionToPolygon:()=>ra,countCoveredInventory:()=>ct,detectSeatLabelRun:()=>Dn,dropRedundantSeatOverrideFields:()=>Ze,familyCategoryLabel:()=>Io,gaAreaFootprint:()=>Po,groupRowsAsSegmented:()=>Xt,insertSeatingBlock:()=>qi,isSafeBuyerImageUrl:()=>Pn,joinGAAreas:()=>Ks,mergeRows:()=>js,mirrorFirstFloor:()=>ue,normalizeBuyerImageUrl:()=>re,normalizeDraftEvidence:()=>sr,parseSeatRefId:()=>ws,pickColorblindSafeCategoryColor:()=>xo,planCreationCategory:()=>vo,previewArcFanRows:()=>Jt,previewBookableGridArray:()=>hs,previewGeneratedSectionPolygonConversion:()=>lo,previewJoinGAAreas:()=>Gs,previewPolygonHole:()=>dt,previewRemovePolygonHole:()=>ao,previewRowCubicPath:()=>oo,previewSectionRowFit:()=>ro,reassignColorblindSafeCategoryColors:()=>ya,relabelChartRows:()=>Vi,removeChartCategory:()=>Aa,removeChartFloor:()=>bi,removeChartObjects:()=>Ui,removeChartZone:()=>yi,removePolygonHole:()=>ta,renameChartFloor:()=>fi,renameDirectSeatImportCategory:()=>ga,reorderChartCategories:()=>ba,replaceArcFanRows:()=>Ka,replaceRowBlock:()=>Ya,resetSeatOverrides:()=>Is,resizeShapes:()=>Bs,resolveCreationCategory:()=>Pa,retractConfidenceEvidence:()=>rc,roundBuyerCoordinates:()=>ni,seatRefId:()=>$e,seatSemanticsSignature:()=>At,sectionInventorySelectionSummary:()=>co,setConfidenceEvidence:()=>tc,setRowBlockSpacing:()=>ks,splitRow:()=>Ls,straightenAndSpaceRows:()=>Es,transformSectionBoundary:()=>ia,transformSectionBoundaryObject:()=>uo,ungroupSegmentedRow:()=>Ja,updateBooths:()=>Bi,updateCategoryDefinitions:()=>wo,updateChartFloorBaseHeight:()=>gi,updateChartTheme:()=>ka,updateChartZones:()=>pi,updateGAAreas:()=>zi,updateRowCubicPath:()=>Xi,updateRows:()=>vs,updateSeatOverrides:()=>nn,updateSectionExactPath:()=>aa,updateSectionMetadata:()=>Kt,updateSegmentedRow:()=>Xa,updateShapes:()=>$s,updateStageKinds:()=>zs,updateTables:()=>$i,updateTextObjects:()=>Hi,updateViewFromSeatFallback:()=>Ea});module.exports=hr(ic);var gn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function pr(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/gn(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let s of a.split(/\s+/)){let l=s.length;r&&r+1+l<=o?r+=1+l:(i+=Math.max(1,Math.ceil(l/o)),r=l%o)}}return Math.max(1,i)}function bn(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*gn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=pr(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var cc=Math.PI/180;function B(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function It(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function hn(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 He(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[hn(e,.5)];let o=Array.from({length:n+1},(l,c)=>hn(e,c/n)),i=new Float64Array(o.length);for(let l=1;l<o.length;l+=1){let c=o[l].x-o[l-1].x,d=o[l].y-o[l-1].y;i[l]=i[l-1]+Math.hypot(c,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],s=1;for(let l=0;l<t;l+=1){let c=a*l/(t-1);for(;s<i.length-1&&i[s]<c;)s+=1;let d=i[s-1],g=i[s],b=g===d?0:(c-d)/(g-d);r.push({x:o[s-1].x+(o[s].x-o[s-1].x)*b,y:o[s-1].y+(o[s].y-o[s-1].y)*b})}return r}function Re(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 Pe(e,t,n){return Math.max(t,Math.min(n,e))}function yr(e){return Pe(e,0,1)}function pn(e){let t=yr(e);return t*t*(3-2*t)}var ge=Math.PI*2;function be(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function mr(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ge;for(;o>=ge;)o-=ge}else{for(;o>0;)o-=ge;for(;o<=-ge;)o+=ge}return o}function Ve(e){if(e.version!==1||e.closed!==!0||!be(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||!be(n.end))return!1;if(n.kind==="line"){if(B(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!be(n.control1)||!be(n.control2)||B(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!be(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(B(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(B(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||B(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return B(t,e.start)<=1e-4}function wr(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 Ct(e,t=2){if(!Ve(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),l=mr(r,s,a.clockwise),c=Math.max(2,Math.ceil(Math.abs(l)*a.radius/n));for(let d=1;d<=c;d+=1){let g=r+l*d/c;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=B(i,a.control1)+B(a.control1,a.control2)+B(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let l=1;l<=s;l+=1)o.push(wr(i,a,l/s))}i=a.end}return B(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function wn(e,t,n){return Ot(e,i=>({x:i.x+t,y:i.y+n}))}function Ot(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 Rt=45,vt=150,xr=60;function Sr(e){let t=Rt/100;if(e<=t)return vt;let n=Math.min(1,(e-t)/(1-t));return vt-n*(vt-xr)}var yn=.5523;function mn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Ir(e){let t=[],n=[];for(e.forEach((o,i)=>{be(o)&&(t.length&&mn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&mn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var vr=.5,Cr=4/3;function Or(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,s=o/a,l=n*Cr;return{kind:"bezier",control1:{x:e.x+o/3+r*l,y:e.y+i/3+s*l},control2:{x:e.x+o*2/3+r*l,y:e.y+i*2/3+s*l},end:{...t}}}function xn(e,t){let{points:n,sourceIndex:o}=Ir(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let w=0;w<i;w+=1){let S=r[o[w]];s[w]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let l=s.some(w=>Math.abs(w)>1e-6);if(a<=0&&!l)return null;let c=t.wideAngleThresholdDeg??Sr(a),d=[];for(let w=0;w<i;w+=1)d[w]=B(n[w],n[(w+1)%i]);let g=new Array(i).fill(0);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],C=n[(w+1)%i],j={x:S.x-I.x,y:S.y-I.y},L={x:C.x-I.x,y:C.y-I.y},T=Math.hypot(j.x,j.y),G=Math.hypot(L.x,L.y);if(T<=1e-9||G<=1e-9)continue;let M=Math.min(1,Math.max(-1,(j.x*L.x+j.y*L.y)/(T*G))),z=Math.acos(M)*180/Math.PI;if(z<c)continue;let P=pn((z-c)/(180-c));g[w]=a*P*.5*Math.min(T,G)}for(let w=0;w<i;w+=1){let S=(w+1)%i,I=g[w]+g[S];if(I>d[w]&&I>1e-9){let C=d[w]/I;g[w]*=C,g[S]*=C}}let b=new Array(i),f=new Array(i);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],C=n[(w+1)%i];if(g[w]<=1e-6){b[w]={...I},f[w]={...I};continue}let j=B(I,S)||1,L=B(I,C)||1;b[w]={x:I.x+(S.x-I.x)/j*g[w],y:I.y+(S.y-I.y)/j*g[w]},f[w]={x:I.x+(C.x-I.x)/L*g[w],y:I.y+(C.y-I.y)/L*g[w]}}if(g.every(w=>w<=1e-6)&&!l)return null;let y=[],m={...f[0]},x=m,v=(w,S)=>{if(B(x,w)<=1e-9)return;let I=s[S];Math.abs(I)>1e-6?y.push(Or(x,w,I*vr*d[S])):y.push({kind:"line",end:{...w}}),x=w};for(let w=1;w<=i;w+=1){let S=w%i,I=n[S];v(b[S],(w-1)%i),g[S]>1e-6&&B(b[S],f[S])>1e-9&&(y.push({kind:"bezier",control1:It(b[S],I,yn),control2:It(f[S],I,yn),end:{...f[S]}}),x=f[S])}if(!y.length)return null;let h=y[y.length-1];B(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:y.push({kind:"line",end:{...m}}));let p={version:1,closed:!0,start:m,segments:y};return Ve(p)?p:null}var Sn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Rr="ABCDEFGHJKLMNPQRSTUVWXYZ",Pr="abcdefghijklmnopqrstuvwxyz";function In(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function Mr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?Rr:Sn;return In(o,i)}function Pt(e,t=!1){let n=t?Pr:Sn;return In(Math.max(0,Math.floor(e)-1),n)}var _r=[[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 vn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of _r)for(;t>=o;)n+=i,t-=o;return n}function Cn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:Mr(a,t)}})}function Ar(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 he(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,l=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(l/2),y=a==="updown"?t<f?n+2*t:n-1+2*(l-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${y}`}let c=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(l-1)*c:n,g=o==="center"?Ar(l)[t]:o==="rtl"?l-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=vn(d+g*i);break;case"letters-upper":b=Pt(d+g*i,!1);break;case"letters-lower":b=Pt(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function jr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function te(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${he(e,t)}`}function Me(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return he(e,t);if(!n)return`${e.displayLabel||e.label}-${he(e,t)}`;let i=jr(n),a=n.displayOffset+t;return`${n.displayLabel}-${he(i,a)}`}var On=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."},{key:"pitch-rugby",label:"Rugby pitch",blurb:"100 \xD7 70 m field of play with in-goal areas, 22 m and 10 m lines."},{key:"diamond-baseball",label:"Baseball field",blurb:"Diamond, infield, mound and foul lines out to 99 m poles."},{key:"court-basketball",label:"Basketball court",blurb:"28 \xD7 15 m court with keys and three-point lines."},{key:"court-tennis",label:"Tennis court",blurb:"23.77 \xD7 10.97 m doubles court with run-off and net."},{key:"ring-boxing",label:"Boxing ring",blurb:"Raised ring, 6.1 m inside the ropes, coloured corners."}];var Lr=Math.PI*2;function kr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function Rn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,s=Math.cos(r),l=Math.sin(r),c=i/2,d=a/2,g=[],b=(f,y)=>{g.push({x:f,y})};switch(t){case"rect":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"rounded":{let f=Math.min(i,a)*.18,y=5,m=(x,v,h)=>{for(let p=0;p<=y;p++){let w=h+p/y*(Math.PI/2);b(x+f*Math.cos(w),v+f*Math.sin(w))}};m(c-f,-d+f,-Math.PI/2),m(c-f,d-f,0),m(-c+f,d-f,Math.PI/2),m(-c+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-c,-d),b(c,-d);let y=24;for(let m=0;m<=y;m++){let x=m/y,v=c-x*i,h=d+f*(1-Math.pow(2*v/i,2));b(v,h)}break}case"thrust":{let f=i*.18,y=a*1.1;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"runway":{let f=i*.1,y=a*3;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"round":case"oval-cricket":{for(let y=0;y<40;y++){let m=y/40*Lr;b(c*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"diamond-baseball":{for(let f of Fr(c,d))b(f.x,f.y);break}case"rink-hockey":{for(let f of Er(c,d,c*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of Tr(c,d))b(f.x,f.y);break}}return g.map(f=>kr(f.x,f.y,s,l,n,o))}function Er(e,t,n,o){let i=[],r=(s,l,c)=>{for(let d=0;d<=8;d++){let g=c+d/8*(Math.PI/2);i.push({x:s+n*Math.cos(g),y:l+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 Tr(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 _e=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},i=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=i+70,r=[],s=Math.atan2(o.y-i,o.x),l=Math.atan2(o.y-i,-o.x);for(let c=0;c<=24;c++){let d=s+(l-s)*c/24;r.push({x:a*Math.cos(d),y:i+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:r}})();function Fr(e,t){let n=e/_e.half,o=t/_e.half;return[{x:-_e.backstop*n,y:t},{x:_e.backstop*n,y:t},..._e.fence.map(i=>({x:i.x*n,y:i.y*o}))]}var Nr=2e6,Dr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Gr=/[\s"'<>`\\]/;function Pn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Dr.test(e);if(Gr.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function re(e){let t=e.trim();return Pn(t)?t:null}function Ae(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Je=Math.PI/180,Kr=9,ie=16;function _t(e,t,n,o){let i=n*Je,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function Y(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return He(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let c=0;c<t;c++)r.push(_t(c*n,0,i,a));return r}let s=o/(t-1)*Je,l=n/(2*Math.sin(Math.abs(s)/2));for(let c=0;c<t;c++){let d=c*s,g=l*Math.sin(d),b=-l+l*Math.cos(d);r.push(_t(g,b,i,a))}return r}function An(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=An(e);return Y(e).map((o,i)=>{let a=n.get(i),r=Ae(a),s=te(e,i,a),l={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Me(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(l).some(c=>c!==void 0&&c!==!1&&c!=="")?l:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function X(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 Br(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 zr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let y=o.get(d),m=Ae(y),x=y?.label??`${e.label}-${d+1}`,v=e.displayLabel??e.label;return{index:d,label:x,displayLabel:y?.displayLabel??`${v}-${d+1}`,x:g+(y?.dx??0),y:b+(y?.dy??0),categoryKey:y?.categoryKey??e.categoryKey,skipped:!!y?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:y?.wheelchairSpaceType,commercial:y?.commercial,glyph:y?.glyph,viewUrl:y?.viewFromSeatUrl,viewMeta:y?.viewFromSeatUrl?y.viewFromSeatMeta:void 0,labelStyle:y?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+ie,g=e.rotation*Je,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let x=0;x<n;x++){let v=g+x/n*2*Math.PI;t.push(i(x,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let f=b*Je,y=(2*Math.PI-f)/2,m=g+y;for(let x=0;x<n;x++){let v=m+x/(n-1)*f;t.push(i(x,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let a=e.width??80,r=e.height??50,s=Br(e),l=["top","bottom","left","right"],c=0;for(let d of l){let g=s[d];for(let b=0;b<g;b++){let f,y;d==="top"?(f=-a/2+(b+.5)*a/g,y=-r/2-ie):d==="bottom"?(f=-a/2+(b+.5)*a/g,y=r/2+ie):d==="left"?(f=-a/2-ie,y=-r/2+(b+.5)*r/g):(f=a/2+ie,y=-r/2+(b+.5)*r/g);let m=_t(f,y,e.rotation,e.center);t.push(i(c++,m.x,m.y,d))}}return t}function ce(e){return zr(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 jn(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function Mn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,s=t[i].x,l=t[i].y;r>e.y!=l>e.y&&e.x<(s-a)*(e.y-r)/(l-r)+a&&(n=!n)}return n}function Ur(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.y-n.y)*(i.y-n.y),s=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=s+1e-7})}function ae(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function $(e,t,n){return Mn(e,t)&&!ae(n).some(o=>Mn(e,o)||Ur(e,o))}function Mt(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 F(e){switch(e.type){case"row":{let t=Y(e),n=An(e),o=0,i=0,a=0;for(let r=0;r<t.length;r++){let s=n.get(r);s?.skip||(o+=t[r].x+(s?.dx??0),i+=t[r].y+(s?.dy??0),a++)}return a?{x:o/a,y:i/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Mt(e.points);case"section":return Mt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Mt(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 _n(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Hr(e,t){if(e.type!=="gaArea"||!_n(e.points,t.outline))return!1;let n=ae(e.holes),o=ae(t.holes);return n.length===o.length&&n.every((i,a)=>_n(i,o[a]))}function Ln(e,t,n=e.filter(i=>i.type==="section"),o=F(t)){let i="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(i?n.find(r=>(r.logicalSectionId??r.id)===i&&(Hr(t,r)||$(o,r.outline,r.holes))):void 0)??n.find(r=>$(o,r.outline,r.holes))}function k(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function H(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var qe=40;function kn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,s=(c,d)=>{c<o&&(o=c),d<i&&(i=d),c>a&&(a=c),d>r&&(r=d)},l=c=>{if(Array.isArray(c))for(let d of c)!d||typeof d!="object"||s(d.x,d.y)};for(let c of H(e))if(c.type==="row"){let d=new Map((c.overrides??[]).map(g=>[g.index,g]));Y(c).forEach((g,b)=>{let f=d.get(b);f?.skip||s(g.x+(f?.dx??0),g.y+(f?.dy??0))})}else if(c.type==="gaArea")l(c.points);else if(c.type==="section")l(c.outline);else if(c.type==="decorImage")s(c.x,c.y),s(c.x+c.width,c.y+c.height);else if(c.type==="shape")c.points&&c.points.length?l(c.points):c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null&&(s(c.x,c.y),s(c.x+c.width,c.y+c.height));else if(c.type==="table"){let d=ie+Kr,g=c.shape==="round"?(c.radius??40)+d:Math.max((c.width??80)/2,(c.height??50)/2)+d;s(c.center.x-g,c.center.y-g),s(c.center.x+g,c.center.y+g)}else if(c.type==="booth"){let d=Math.max(c.width,c.height)/2;s(c.center.x-d,c.center.y-d),s(c.center.x+d,c.center.y+d)}else if(c.type==="text"){if(n)continue;let d=bn(c);s(c.position.x,c.position.y),s(c.position.x+d.width,c.position.y+d.height)}for(let c of[e.referenceImage,e.backgroundImage]){if(!c)continue;let{center:d,width:g}=c;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(g))continue;let b=g*3/4;s(d.x-g/2,d.y-b/2),s(d.x+g/2,d.y+b/2)}if(!isFinite(o)){let c=e.focalPoint??{x:0,y:0};return{x:c.x-200,y:c.y-200,width:400,height:400}}return{x:o-qe,y:i-qe,width:a-o+qe*2,height:r-i+qe*2}}function Xe(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 Vr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Nn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Le(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function At(e){let t=Le(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of Vr){let s=i?.[r];s!==void 0&&(a[r]=s)}n.push([te(e,o,i),Me(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function qr(e){return JSON.parse(JSON.stringify(e))}function Ye(e,t){let n=qr(e);return t(n)&&At(n)===At(e)?n:e}function Jr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Le(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(!Nn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Xr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Dn(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=Xr(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 Yr(e){if(e.seatCount<1)return!1;let t=Le(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(te(e,i,t.get(i)));let o=Dn(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 Qr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Le(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==he(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Ze(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Nn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===te(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===Me(e,t.index)&&delete t.displayLabel}function Gn(e){return Object.keys(e).every(t=>t==="index")}function Zr(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Ze(e,n);let t=e.overrides.filter(n=>!Gn(n));return t.length?e.overrides=t:delete e.overrides,!0}function Wr(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Le(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function Kn(e){if(e.type!=="row")return e;let t=Ye(e,Jr);return t=Ye(t,Yr),t=Ye(t,Qr),t=Ye(t,Zr),Wr(e,t)?t:e}function $n(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,Gn(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function En(e){return e.type==="row"?Kn(e):e.type==="table"?$n(e):e}function ei(e){let t=e.objects.map(En),n=e.floors?.map(o=>({...o,objects:o.objects.map(En)}));return{...e,objects:t,...n?{floors:n}:{}}}var Tn=2,ti=3,Fn=6;function je(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 Qe(e){return{...e,x:je(e.x,Tn),y:je(e.y,Tn)}}function ni(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Qe(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Qe)),Array.isArray(t.points)&&(t.points=t.points.map(Qe)),typeof t.rotation=="number"&&(t.rotation=je(t.rotation,Fn)),typeof t.seatSpacing=="number"&&(t.seatSpacing=je(t.seatSpacing,Fn));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Qe(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let s=je(r,ti);s===0?delete i[a]:i[a]=s}return i})),t}var oi=36,ri=160;function Bn(e,t=360){let n=Pe(Math.round(Number.isFinite(e)?e:1),1,40),o=Pe(Number.isFinite(t)?t:360,120,360);return Math.round(Pe(n*4*(360/o),oi,ri))}var zn=["horizontal","vertical","auto"];var ke=[{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"}],kc=new Map(ke.map(e=>[e.key,e]));var ii=[{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"}],Ec=new Map(ii.map(e=>[e.key,e]));var pe=8,jt=24,ai=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Tc=new Set(ai);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function O(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function E(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 si(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;let n=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=t.length-1;a>=0;a--){let r=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function ci(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 le(e){let t=[];for(let o of e)o.type==="row"?t.push(...X(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ce(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=ci(si(t),22);return n.length>=3?n:null}function We(e,t){let n=O(e,t),o=k(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Un=24,Hn=80;function Lt(e,t){let n=e.normalize("NFKC").trim();if(n.length>Un)throw new u("invalid_operation",`${t} displayed type must be at most ${Un} characters`);return n}function et(e,t){if(e.displayType===void 0)return!1;let n=Lt(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function ye(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Hn)throw new u("invalid_operation",`${t} displayed label must be at most ${Hn} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function N(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function Vn(e,t){if(!Number.isFinite(e)||e<pe||e>jt)throw new u("invalid_operation",`${t} label size must be from ${pe} to ${jt}`)}function me(e,t){e.size!==void 0&&e.size!==null&&Vn(e.size,t),e.color!==void 0&&e.color!==null&&N(e.color,`${t} label color`)}function tt(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&&Vn(n.size,t),n.color!==void 0&&N(n.color,`${t} label color`))}function nt(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=N(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function kt(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 Ee(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 ne=Math.PI/180,Z=Math.PI/180;function de(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 ue(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 li=0,ot=120,Et=4;function di(e){if(!Number.isFinite(e)||e<li||e>ot)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ui(e,t){let n=k(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.name??String(n.length+1)).normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(l=>l.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(ot,(e.floors.length-1)*Et),r=Math.min(ot,a+Et),s=A(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),ue(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:r}}function fi(e,t){let n=k(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function gi(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});di(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 bi(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 ue(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:k(e).length}}function hi(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:kt(e,t.label),color:N(t.color,"Zone color"),...t.focalPoint?{focalPoint:Ee(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function pi(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(l=>l.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((e.zones??[]).map(l=>[l.id,l])),i=n.filter(l=>!o.has(l));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(e),r=new Map((a.zones??[]).map(l=>[l.id,l]));for(let l of t.updates){if(!Object.keys(l.patch).length)throw new u("invalid_operation",`Zone ${l.zoneId} has no changes`);let d=r.get(l.zoneId);l.patch.label!==void 0&&(d.label=kt(a,l.patch.label,d.id)),l.patch.color!==void 0&&(d.color=N(l.patch.color,"Zone color")),l.patch.focalPoint!==void 0&&(d.focalPoint=Ee(l.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(l=>structuredClone(r.get(l)))}}function yi(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=k(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.zoneId,sectionIds:o.map(a=>a.id),requiresClearSectionAssignments:!0});let i=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,ue(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var rt=[{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 it(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 Tt="__sl_ga__";function Te(e){return e.startsWith(Tt)}var mi=Tt,W=1e5;function wi(e,t){return`${mi}${encodeURIComponent(e)}__${t+1}`}function Ft(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>W||(n+=i.count,n>W))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(s=>i.startIndex<s.end&&r>s.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===e.capacity}function at(e){let t=Math.min(W,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Ft(e)?e.inventorySegments.map(n=>({...n})):[]}function oe(e){return at(e).flatMap(t=>Array.from({length:t.count},(n,o)=>wi(t.sourceAreaId,t.startIndex+o)))}function Nt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=at(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,l)=>Math.max(s,l.startIndex+l.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var xi="__ungrouped__";function Si(e){return e.type==="row"?X(e).map(t=>t.label):e.type==="table"?ce(e).map(t=>t.label):e.type==="booth"?jn(e).map(t=>t.label):e.type==="gaArea"?oe(e):[]}function Ii(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function vi(e){return e.displayLabel||e.label||"Section"}function Ci(e){let t=new Map;for(let n of H(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:vi(n),zone:n.zone})}return t}function Oi(e,t){let n=H(e),o=n.filter(s=>s.type==="section"),i=new Map;for(let[s,l]of Ci(e))i.set(s,{id:s,label:l.label,zone:l.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:xi,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},r=new Map;for(let s of n){if(!Ii(s))continue;let l=Si(s);if(l.length===0)continue;let c;if(t)c=t.get(s.id);else{let g=Ln(n,s,o);c=g?g.logicalSectionId??g.id:void 0}let d=c?i.get(c):a;d.seatCount+=l.length,d.objectIds.push(s.id),d.seatLabels.push(...l),r.set(s.id,d.id)}return{sections:[...i.values()],ungrouped:a.objectIds.length?a:null,objectToSection:r}}function Fe(e){return Oi(e,null)}var fe={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 Ne(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 Ri(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 qn(e,t,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}function Pi(e,t,n,o,i){let a=n*2,r=[];for(let s=0;s<a;s++){let l=s%2===0,c=l?["wheelchair"]:["companion"];r.push(l?{index:s,accessibility:c,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:c})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Jn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[fe.balcony],sectionLabel:"Balcony",build:()=>[Ne("blk-b0","A",-45,18,24,"balcony",18),Ne("blk-b1","B",-15,20,24,"balcony",18),Ne("blk-b2","C",15,22,24,"balcony",18),Ne("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[fe.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>Ne(`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:[fe.standard],build:()=>[qn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[fe.premium],build:()=>Array.from({length:6},(e,t)=>Ri(`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:[fe.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:[fe.standard],build:()=>[qn("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:[fe.standard],build:()=>[Pi("blk-wc","A",4,40,"standard")]}];function V(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 Xn(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 Yn="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",Qn=[{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:Yn},{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:Yn},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}];var Mi=new Map(Qn.map(e=>[e.key,e]));function Zn(e){return typeof e=="string"&&Mi.has(e)}var al=Qn.map(e=>e.key);function Dt(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 Wn(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=ae(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=wn(e.outlinePath,t,n)),e.holes&&(e.holes=ae(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 _i(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function De(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function st(e,t,n){let o=De(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 Ai(e,t,n,o){let i=De(e,t,n),a=De(e,t,o),r=De(n,o,e),s=De(n,o,t);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)?!0:Math.abs(i)<=1e-7&&st(n,e,t)||Math.abs(a)<=1e-7&&st(o,e,t)||Math.abs(r)<=1e-7&&st(e,n,o)||Math.abs(s)<=1e-7&&st(t,n,o)}function ji(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 Li(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)&&Ai(e[t],e[n],e[o],e[i]))return!0}}return!1}function eo(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)=>_i(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(ji(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Li(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function $i(e,t){let n=O(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(p=>p.type==="table"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&E(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=N(r.fill,"Table surface color"));let s=r.seatCount!==void 0,l=r.seatCountsBySide!==void 0;if(l){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let h=["top","bottom","left","right"],p=Object.keys(r.seatCountsBySide);if(p.length!==h.length||p.some(S=>!h.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of h){let I=r.seatCountsBySide[S];if(!Number.isInteger(I)||I<0||I>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let w=h.reduce((S,I)=>S+r.seatCountsBySide[I],0);if(w<1||w>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==w)throw new u("invalid_operation",`seatCount must equal the ${w}-chair seatCountsBySide total`);r.seatCount=w,r.sides=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 c=(h,p,w,S)=>{if(p!==void 0&&(!Number.isFinite(p)||p<w||p>S))throw new u("invalid_operation",`${String(h)} must be from ${w} to ${S}`)};if(c("rotation",r.rotation,0,360),c("radius",r.radius,24,160),c("seatArc",r.seatArc,120,360),c("width",r.width,40,320),c("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let h=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(p=>!h.has(p)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=ye(r,"Table"),g=et(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!l&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let p=structuredClone(h);if(Object.assign(p,r),r.fill===null&&delete p.fill,p.shape==="round")delete p.seatCountsBySide,p.automaticRadius===!0?p.radius=Bn(p.seatCount,p.seatArc):delete p.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${p.label}" is rectangular and cannot use automatic radius`,{tableId:p.id});delete p.automaticRadius}if(p.overrides&&r.seatCount!==void 0&&(p.overrides=p.overrides.filter(w=>w.index<p.seatCount),p.overrides.length||delete p.overrides),r.bookAsWhole===!1&&delete p.bookAsWhole,r.variableOccupancy===!1&&(delete p.variableOccupancy,delete p.minOccupancy,delete p.maxOccupancy),p.bookAsWhole||delete p.bookAsWhole,p.variableOccupancy||delete p.variableOccupancy,p.bookAsWhole&&p.variableOccupancy)throw new u("invalid_operation",`Table "${p.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:p.id});if((p.bookAsWhole||p.variableOccupancy)&&p.overrides?.length)throw new u("invalid_operation",`Table "${p.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:p.id,overriddenChairIndices:p.overrides.map(w=>w.index)});if(p.bookAsWhole)delete p.minOccupancy,delete p.maxOccupancy;else if(p.variableOccupancy){if(!Number.isInteger(p.minOccupancy)||!Number.isInteger(p.maxOccupancy)||p.minOccupancy<1||p.maxOccupancy<p.minOccupancy||p.maxOccupancy>p.seatCount)throw new u("invalid_operation",`Table "${p.label}" needs whole-number minimum and maximum guests from 1 to its ${p.seatCount}-chair capacity`,{tableId:p.id,seatCount:p.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:p.id});delete p.minOccupancy,delete p.maxOccupancy}if(g&&delete p.displayType,d&&delete p.displayLabel,p.shape==="rect"){if(p.width??=80,p.height??=50,p.seatCountsBySide){let w=["top","bottom","left","right"],S=w.reduce((I,C)=>I+p.seatCountsBySide[C],0);if(S!==p.seatCount)throw new u("invalid_operation",`Table "${p.label}" side counts total ${S}, but seatCount is ${p.seatCount}`,{tableId:p.id,seatCount:p.seatCount,seatCountsBySide:p.seatCountsBySide});p.sides=w.filter(I=>p.seatCountsBySide[I]>0)}}else p.radius??=40;if((p.bookAsWhole||p.variableOccupancy)&&Te(p.label))throw new u("invalid_operation",`Grouped table label "${p.label}" uses SeatLayer's reserved GA namespace`,{tableId:p.id});return p}),f=new Map(b.map(h=>[h.id,h])),y=new Set(o),m=new Map;for(let h of k(e))for(let p of h.objects){let w=p.type==="table"?f.get(p.id)??p:p,S=[];w.type==="row"?S=X(w).map(I=>I.label):w.type==="table"?S=w.bookAsWhole||w.variableOccupancy?[w.label]:ce(w).map(I=>I.label):w.type==="booth"?S=[w.label]:w.type==="gaArea"&&(S=oe(w));for(let I of S){let C=m.get(I);if(C&&(y.has(C)||y.has(w.id)))throw new u("invalid_operation",`Inventory label "${I}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:I,conflictingObjectIds:[C,w.id]});m.set(I,C??w.id)}}let x=!1,v=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,p]of i.entries()){let w=b[h],S=JSON.stringify(p);for(let I of v)I in w||delete p[I];Object.assign(p,w),JSON.stringify(p)!==S&&(x=!0)}return{floorId:n.floorId,changed:x,tableIds:o}}function Bi(e,t){let n=O(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(y=>y.type==="booth"&&y.id===f)),a=o.filter((f,y)=>!i[y]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&E(e,r.categoryKey);let s=(f,y,m,x)=>{if(y!==void 0&&(!Number.isFinite(y)||y<m||y>x))throw new u("invalid_operation",`${f} must be from ${m} to ${x}`)};s("width",r.width,30,400),s("height",r.height,30,400),s("rotation",r.rotation,0,360);let l=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=eo(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let c=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=ye(r,"Booth"),g=et(r,"Booth"),b=!1;for(let f of i){let y=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,l?delete f.points:c&&(f.points=c),JSON.stringify(f)!==y&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function zi(e,t){let n=O(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let 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&&E(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>W))throw new u("invalid_operation",`capacity must be an integer from 1 to ${W}`);if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=ye(r,"GA area"),l=et(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&&Nt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let c=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:Nt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),s&&delete d.displayLabel,l&&delete d.displayType,JSON.stringify(d)!==g&&(c=!0)}return{floorId:n.floorId,changed:c,gaAreaIds:o}}function ct(e,t){if(t.length<3)return 0;let n=i=>$(i,t,void 0),o=0;for(let i of e)n(F(i))&&(i.type==="row"?o+=X(i).length:i.type==="table"?o+=ce(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=de(i)));return o}function Ui(e,t){let n=O(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(l=>l.id===s)),i=t.objectIds.filter((s,l)=>!o[l]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)r.has(n.objects[s].id)&&n.objects.splice(s,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,l)=>s+de(l),0),remainingObjectCount:n.objects.length}}function Hi(e,t){let n=O(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(c=>n.objects.find(d=>d.type==="text"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=N(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=N(r.background.color,"Text background color");let{padding:c=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(c)||c<0||c>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(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(c=>Object.prototype.hasOwnProperty.call(r,c))&&i.some(c=>c.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!Zn(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(c=>c.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let l=!1;for(let c of i){let d=JSON.stringify(c);r.iconKey!==void 0&&(c.iconKey=r.iconKey),r.text!==void 0&&(c.text=r.text),r.fontSize!==void 0&&(c.fontSize=r.fontSize),r.fontFamily===null?delete c.fontFamily:r.fontFamily!==void 0&&(c.fontFamily=r.fontFamily),r.rotation!==void 0&&(c.rotation=r.rotation),r.color===null?delete c.color:r.color!==void 0&&(c.color=r.color),r.bold!==void 0&&(r.bold?c.bold=!0:delete c.bold),r.italic!==void 0&&(r.italic?c.italic=!0:delete c.italic),r.width===null?delete c.width:r.width!==void 0&&(c.width=r.width),r.align!==void 0&&(r.align==="left"?delete c.align:c.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete c.lineHeight:c.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete c.letterSpacing:c.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?c.underline=!0:delete c.underline),r.opacity!==void 0&&(r.opacity===1?delete c.opacity:c.opacity=r.opacity),r.background===null?delete c.background:r.background!==void 0&&(c.background=r.background),r.labelImportance===null?delete c.labelImportance:r.labelImportance!==void 0&&(c.labelImportance=r.labelImportance),JSON.stringify(c)!==d&&(Xe(c),l=!0)}return{floorId:n.floorId,changed:l,textIds:o}}function Vi(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),s=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,l=Cn(r.map(b=>({label:s(b)})),t.options),c=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=c===void 0||c===""||c==="Row"?t.displayType===void 0?void 0:null:c,g=!1;return r.forEach((b,f)=>{let y=l[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(b)!==y&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=y:b.displayLabel=y),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:s(b),...b.displayType?{displayType:b.displayType}:{}}))}}function qi(e,t){let n=Jn.find(c=>c.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=O(e,t.floorId),i=new Set,a=n.build().map(c=>structuredClone(c));for(let c of a)c.id=A(e,c.type,t.idFactory,i),Wn(c,t.center.x,t.center.y);for(let c of n.categories)e.categories.some(d=>d.key===c.key)||e.categories.push({...c});let r=a.filter(c=>c.type==="row");if(r.length){let c=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Xn(d.label);g!=null&&(c=Math.max(c,g+1))}for(let d of r)d.label=V(c++)}let s=new Set(o.objects.flatMap(c=>"label"in c&&c.label?[c.label]:[]));for(let c of a){if((c.type==="table"||c.type==="booth")&&s.has(c.label)){let d=/^(.*?)(\d+)$/.exec(c.label),g=d?d[1]:`${c.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(s.has(`${g}${b}`));c.label=`${g}${b}`}"label"in c&&c.label&&s.add(c.label)}o.objects.push(...a);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let c=le(a);if(c){let d={type:"section",id:A(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:c};o.objects.push(d),l=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(c=>c.id),...l?[l]:[]],sectionId:l}}function 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=He(t,97),i=o.slice(1).reduce((a,r,s)=>a+Math.hypot(r.x-o[s].x,r.y-o[s].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:i}}function oo(e,t){let n=O(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=Ji(t.path),a=X(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=X(r),l=a.map((d,g)=>Math.hypot(d.x-s[g].x,d.y-s[g].y)),c=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:l.length?l.reduce((d,g)=>d+g,0)/l.length:0,maxSeatMovement:l.length?Math.max(...l):0,convertingFromParametric:!o.path,changed:c,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Xi(e,t){let n=oo(e,t);if(!n.changed)return n;let i=O(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 Yi(e,t){let n=e.map((o,i)=>[...o,t[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let s=n[r][o];for(let l=o;l<4;l++)n[r][l]-=s*n[o][l]}}return[n[0][3],n[1][3],n[2][3]]}function Qi(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*r;for(let l=0;l<3;l++)t[s][l]+=a[s]*a[l]}}let o=Yi(t,n);return o?{x:o[0],y:o[1]}:null}function to(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function ro(e,t){let n=O(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=k(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Qi(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(f=>f.type==="row"&&$(F(f),o.outline,o.holes)),l=s.filter(f=>!!f.path).map(f=>f.id),c=[],d=[],g=i/100;for(let f of s){if(f.path)continue;if(f.seatCount<2){c.push(f.id);continue}let y=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(y<=f.seatSpacing/2+1e-6){c.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*y))/ne,x=X(f),v=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/ne,p=(f.curve!==0?Math.sign(f.curve):x.length>1&&Math.sign(to(Math.atan2(x[1].x-r.x,x[1].y-r.y)/ne-v))||1)*m*(f.seatCount-1);if(Math.abs(p)>320){c.push(f.id);continue}let w=-v,S=f.curve+(p-f.curve)*g,I=f.rotation+to(w-f.rotation)*g,C={...f,curve:S,rotation:I},L=X(C).map((T,G)=>Math.hypot(T.x-x[G].x,T.y-x[G].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:p,resultCurve:S,fromRotation:f.rotation,resultRotation:I,rmsMovement:Math.sqrt(L.reduce((T,G)=>T+G**2,0)/L.length),maxMovement:Math.max(...L)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:l,skippedInvalidRowIds:c,averageMovement:b.length?b.reduce((f,y)=>f+y,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function Zi(e,t){let n=ro(e,t),o=O(e,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let s=o.objects.find(l=>l.type==="row"&&l.id===r.rowId);(s.curve!==r.resultCurve||s.rotation!==r.resultRotation)&&(s.curve=r.resultCurve,s.rotation=r.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function io(e,t,n,o){let i=Q(e,t,n),a=Q(e,t,o),r=Q(n,o,e),s=Q(n,o,t);return i*a<-1e-9&&r*s<-1e-9}function no(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>io(n,i,a,t[(r+1)%t.length]))})}function Wi(e){if(e.length<3||e.length>256||Math.abs(Re(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)&&io(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function lt(e,t,n){let o=O(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 dt(e,t){let{target:n,object:o,outer:i}=lt(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Wi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(c=>!$(c,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(no(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=t.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||t.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let c=0;c<r.length;c++){if(c===t.holeIndex)continue;let d=r[c];if(no(a,d)||$(a[0],d,void 0)||$(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let l=n.objects.filter(c=>c.id!==o.id&&c.type!=="section"&&$(F(c),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:l.map(c=>c.id),excludedInventoryUnits:ct(n.objects.filter(c=>c.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function ea(e,t){let n=dt(e,t),{object:o}=lt(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 ao(e,t){let{target:n,object:o}=lt(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(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:ct(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function ta(e,t){let n=ao(e,t),{object:o}=lt(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function na(e){let t=re(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function so(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.find(s=>s.type==="section"&&s.id===r)),i=n.filter((r,s)=>!o[s]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function co(e,t){let n=O(e,t.floorId),o=so(n.objects,t.sectionIds),i=Fe(We(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),s=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),l=new Set,c=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of s){let y=r.get(f);if(y)if(y.type==="row"||y.type==="table")for(let m of it(y).keys())l.add(m);else(y.type==="booth"||y.type==="gaArea")&&l.add(y.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(y=>{let m=r.get(y);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:g,...g&&l.size===1?{categoryKey:[...l][0]}:!g&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?l.size!==1:!s.length&&d.size>1,viewApplicable:b}}function oa(e,t){E(e,t.categoryKey);let n=co(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=O(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,s=new Set(n.logicalSectionIds);for(let l of o.objects)l.type!=="section"||!s.has(l.logicalSectionId??l.id)||l.editor?.defaultCategoryKey!==t.categoryKey&&(l.editor={...l.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let l of o.objects){if(!i.has(l.id)||l.type!=="row"&&l.type!=="table"&&l.type!=="booth"&&l.type!=="gaArea"||(l.categoryKey!==t.categoryKey&&(l.categoryKey=t.categoryKey,a=!0),l.type!=="row"&&l.type!=="table"||!l.overrides?.length))continue;let c=l.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});c.length?l.overrides=c:delete l.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Kt(e,t){let n=O(e,t.floorId),o=so(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(f=>!r.has(f));if(s.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${s.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=na(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&&tt(a.labelPresentation,"Section"),a.labelStyle!==void 0&&me(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=N(a.color,"Section color"));let l=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,c=new Set(o.logicalSectionIds),d=l?n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let y=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let m=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)!==y&&(b=!0,g.add(f.id))}for(let f of d){let y=JSON.stringify(f),m=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let x=nt(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)!==y&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function lo(e,t){let n=O(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&$(F(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+de(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function ra(e,t){let n=lo(e,t),i=O(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function uo(e,t){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let s=F(e);o=l=>({x:s.x+(l.x-s.x)*t.factor,y:s.y+(l.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let l=t.degrees*Math.PI/180,c=Math.cos(l),d=Math.sin(l),g=F(e);o=b=>{let f=b.x-g.x,y=b.y-g.y;return{x:g.x+f*c-y*d,y:g.y+f*d+y*c}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=Ot(e.outlinePath,o,i,a)),e.holes&&(e.holes=ae(e.holes).map(s=>s.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function ia(e,t){let n=O(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,...uo(o,t.transform)}}function aa(e,t){let n=O(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Ve(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=Ct(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function sa(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function ca(e,t){return fo(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function fo(e,t){let n=O(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(s=>!Number.isFinite(s)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let l=n.objects.find(h=>h.type==="section"&&h.id===s);if(!l||!sa(l))continue;let d=structuredClone(l);a.set(l.id,{section:l,snapshot:d});let g=JSON.stringify(l),b=(l.sourceOutline??l.outline).map(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??l.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?l.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),x=m?.some(h=>Math.abs(h)>.5)===!0,v=f>.5||x?xn(b,{cornerSmoothing:f,...x?{edgeCurvature:m}:{}}):null;v?(l.sourceOutline=b,l.outlinePath=v,l.outline=Ct(v),f>.5?l.cornerSmoothing=f:delete l.cornerSmoothing,x?l.edgeCurvature=[...m]:delete l.edgeCurvature):(l.outline=b,delete l.outlinePath,delete l.sourceOutline,delete l.cornerSmoothing,delete l.edgeCurvature);for(let h=0;h<(l.holes?.length??0);h+=1)dt(e,{floorId:n.floorId,objectId:l.id,points:l.holes[h],holeIndex:h});JSON.stringify(l)!==g&&(r=!0,i.add(l.id))}}catch(s){for(let{section:l,snapshot:c}of a.values()){let d=l;for(let g of Object.keys(d))delete d[g];Object.assign(l,structuredClone(c))}throw s}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}function la(e,t,n={}){let o=!1;for(let i of t){let a=Kt(e,{floorId:i.floorId,sectionIds:[i.sectionId],patch:{height:i.height,rake:i.rake,surfaceKind:i.surfaceKind}});o||=a.changed}if(n.stage){let i=O(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);i&&i.role!=="stage"&&(i.role="stage",o=!0),i&&n.stage.stageKind&&!i.stageKind&&(i.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:i,floorId:a,role:r}of n.roles??[]){let s=O(e,a).objects.find(l=>l.type==="shape"&&l.id===i);s&&!s.role&&(s.role=r,o=!0)}for(let{floorId:i,point:a}of n.focal??[]){let r=Ee(a,"focalPoint"),s=i?e.floors?.find(c=>c.id===i):void 0,l=s?s.focalPoint:e.focalPoint;l?.x===r.x&&l?.y===r.y||(s?s.focalPoint=r:e.focalPoint=r,o=!0)}return e.floors?.length&&ue(e),{changed:o}}var $t=.15,Bt=1.6;var da=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Ut(e){let t=da.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 Ht(e,t){let n=a=>{let r=Ut(a);if(!r)return null;let s=h=>{let p=h/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4},l=s(r[0]),c=s(r[1]),d=s(r[2]),g=(.4124*l+.3576*c+.1805*d)/.95047,b=.2126*l+.7152*c+.0722*d,f=(.0193*l+.1192*c+.9505*d)/1.08883,y=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=y(g),x=y(b),v=y(f);return[116*x-16,500*(m-x),200*(x-v)]},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 zt(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function go(e){return .2126*zt(e[0])+.7152*zt(e[1])+.0722*zt(e[2])}function ut(e,t){let n=Ut(e),o=Ut(t);if(!n||!o)return null;let i=go(n),a=go(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var bo=["butt","round","square"],ho=["miter","round","bevel"],po=["none","arrow"];function Vt(e){return e==="line"||e==="polyline"}var yo=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Jl=yo.map(e=>e.key),ua=new Map(yo.map(e=>[e.key,e]));function Ge(e){return typeof e=="string"&&ua.has(e)}var fa=new Set(["companion","child","senior","student","membership","custom"]);function we(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=r.toLocaleLowerCase("en"),l=n.get(s);if(l)throw new u("duplicate_category_label",`Categories ${l} and ${a} share the same label`,{categoryKeys:[l,a],label:r});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.referenceDirectSeatImport!==void 0){let c=i.referenceDirectSeatImport;if(c.assetId!==c.assetId.trim()||c.assetId.length>160||!c.assetId||c.familyId!==c.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(c.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.seatGlyph!=null&&!Ge(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let c=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),y=f.toLocaleLowerCase("en");if(!b||b.length>160||c.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(y))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!fa.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(v=>v.normalize("NFKC").trim()),x=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(v=>!v||v.length>160)||new Set(m).size!==m.length)||x&&(!x.length||x.some(v=>!ke.some(h=>h.key===v))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...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})}c.add(b),d.add(y)}}}return o}function wo(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let s=o.find(g=>g.key===r.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let l=structuredClone(r.patch),{tiers:c,...d}=l;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(s,d),s.notForSale===!1&&delete s.notForSale,Object.prototype.hasOwnProperty.call(l,"tiers")&&(c==null?delete s.tiers:s.tiers=c?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete s.referenceDirectSeatImport}let i=we(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function ga(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=we(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 ba(e,t){let n=t.categoryKeys.map(l=>l.trim()),o=e.categories.map(l=>l.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(l=>!n.includes(l)),r=n.filter(l=>!i.has(l));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((l,c)=>l===o[c]))return{changed:!1,categoryKeys:o,categories:e.categories};let s=new Map(e.categories.map(l=>[l.key,l]));return e.categories=we(n.map((l,c)=>{let d=structuredClone(s.get(l));return l!==o[c]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var qt=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function mo(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 ha(e,t){let n=mo(e),o=mo(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var pa=3600;function xo(e,t,n=qt){return n.find(i=>e.every(a=>ha(i,a)>=pa))??n[t%n.length]}function ya(e,t){let n=t?.palette??qt;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return wo(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 ma(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(e.categories),a=i.find(l=>l.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=we(i),s=JSON.stringify(r)!==JSON.stringify(e.categories);return s&&(e.categories=r),{changed:s,category:e.categories.find(l=>l.key===t.categoryKey),categories:e.categories}}function So(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let l=t.idFactory("cat").trim();if(l&&!n.has(l)){o=l;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=we([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var wa=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],xa={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function Sa(e,t){let n=xa[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var Ia=26;function va(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,s,l]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],c=n-o/2,d=g=>Math.round((g+c)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(s)}${d(l)}`}function Ca(e,t,n){let o=r=>e.every(s=>{let l=Ht(r,s);return l==null||l>=Ia}),i=r=>{let s=ut(r,"#12151d"),l=ut(r,"#ffffff");return(s??0)>=3||(l??0)>=3},a=t.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let s of[.52,.44,.6]){let l=va(r,.62,s);if(o(l)&&i(l))return l}return n}function Io(e,t){let n=rt.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function Oa(e){let t=new Map;for(let n of k(e))for(let o of n.objects){let i=rt.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of it(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=t.get(r)??new Set;s.add(i.objectType),t.set(r,s)}}return t}function Ra(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 vo(e,t,n){let o=Oa(e),i=c=>{let d=o.get(c);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(c=>c.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let c=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(c)return{kind:"existing",categoryKey:c.key,label:c.label}}let r=rt.find(c=>c.objectType===n),s=a?Io(a.label,n):n==="gaArea"?"General Admission":r.creationWord,l=e.categories.find(c=>c.label.toLowerCase()===s.toLowerCase()&&i(c.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:Ra(e,s)}}function Pa(e,t,n,o){let i=vo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return Ma(e,n,a,i.label,o)}function Ma(e,t,n,o,i){let a=i.palette??wa,r=e.categories.map(d=>d.color),s=i.suggestColor?.(r.map(d=>d.toLowerCase()))??xo(r,e.categories.length),l=Ca(r,Sa(t,a),s),c=So(e,{label:o,color:l,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=c.categories,c.category.key}function _a(e,t){let n=new Set;for(let o of k(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function Aa(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=_a(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=we(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var ja=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],La=["seat","deck","shell","fascia"];function ka(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 ja){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=N(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<$t||n.seatScale>Bt)throw new u("invalid_operation",`Theme seatScale must be from ${$t} to ${Bt}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=re(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let s of La){let l=n.venue3d[s];l===null?delete a[s]:l!==void 0&&(a[s]=N(l,`3D venue ${s}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Ea(e,t){let n=t.url===null?null:re(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(g=>g.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let l=(s.viewFromSeatUrl??void 0)===o,c=o?t.metadata===null?void 0:t.metadata??(l?s.viewFromSeatMeta:void 0):void 0,d=!l||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(c??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=c,{changed:d,scope:"floor",floorId:t.floorId,url:s.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function Ta(e,t){let n=We(e,t.floorId),o=kn(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 ft(e,t){E(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let s={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(s.left,s.center,s.right)||Object.values(s).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let c=O(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:t.rowLabelStart??c,seatLabelStart:t.seatLabelStart??1}}function Fa(e,t,n){let o=n*ne;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Na(e,t,n,o){let i=Math.abs(o-n)*ne,a=[["left",.25],["center",.5],["right",.75]].flatMap(([c,d])=>{let g=e.aisleGaps[c];if(!g)return[];let b=g/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((c,d)=>c[0]-d[0]),r=[];for(let c of a){let d=r[r.length-1];d&&c[0]<=d[1]?d[1]=Math.max(d[1],c[1]):r.push([...c])}let s=[],l=0;for(let c of r)c[0]-l>1e-6&&s.push([l,c[0]]),l=Math.max(l,c[1]);return 1-l>1e-6&&s.push([l,1]),s.filter(([c,d])=>t*i*(d-c)>=e.seatPitch*.75)}function Da(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((l,c)=>l+c,0),a=e.map(l=>o*l/i),r=a.map(l=>2+Math.floor(l)),s=t-r.reduce((l,c)=>l+c,0);return a.map((l,c)=>({index:c,fraction:l-Math.floor(l)})).sort((l,c)=>c.fraction-l.fraction||l.index-c.index).forEach(({index:l})=>{s-- >0&&r[l]++}),r}function gt(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,l=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,c=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(c-l)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(c-l)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=Na(e,r,l,c);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([y,m])=>r*Math.abs(c-l)*ne*(m-y)),b=e.fit==="fixed-count"?Da(g,e.seatsPerRow):g.map(y=>Math.max(2,Math.round(y/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([y,m],x)=>{let v=l+(c-l)*y,h=l+(c-l)*m;e.facing==="outward"&&([v,h]=[h,v]);let p=b[x];if(p>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let w=Math.abs(h-v)*ne/(p-1),S=2*r*Math.sin(w/2),I={type:"row",id:n(i,x),label:V(e.rowLabelStart+i),origin:Fa(e.center,r,v),rotation:-v,curve:h-v,seatCount:p,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(I),f+=p})}return o}function Jt(e,t){let n=ft(e,t),o=O(e,t.floorId),i=gt(n,"preview-arc-fan",(l,c)=>`preview-fan-${l}-${c}`),a=i.map(l=>l.seatSpacing),r=Math.max(...a.map(l=>Math.abs(l-n.seatPitch))),s=[];return r>n.seatPitch*.12&&s.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((l,c)=>l+c.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(l=>l>0).length,warnings:s}}function Ga(e,t){let n=ft(e,t),o=O(e,t.floorId),i=new Set,a=A(e,"fan",t.idFactory,i),r=gt(n,a,()=>A(e,"r",t.idFactory,i)),s=Jt(e,t),l=null,c=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(c){if(c.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=le(r);g&&(l=A(e,"sec",t.idFactory,i),d={type:"section",id:l,label:c,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:l,groupId:a,logicalRowCount:s.logicalRowCount,rowSegmentCount:s.rowSegmentCount,totalSeats:s.totalSeats,innerRadius:s.innerRadius,outerRadius:s.outerRadius,minSeatSpacing:s.minSeatSpacing,maxSeatSpacing:s.maxSeatSpacing,maxPitchDeviation:s.maxPitchDeviation,aisleCount:s.aisleCount,warnings:s.warnings}}function Co(e,t){let n=O(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},l=ft(e,s),c=new Set(gt(l,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(c.size!==d.size||[...c].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return s}function Ka(e,t){Co(e,{floorId:t.floorId,groupId:t.groupId});let n=ft(e,t),o=O(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),s=new Set,l=gt(n,t.groupId,(m,x)=>r.get(`${m}:${x}`)??A(e,"r",t.idFactory,s)),c=Jt(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=le(l);m&&(g={type:"section",id:a?.id??A(e,"sec",t.idFactory,s),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,x)=>b.has(m.id)?x:1/0)),y=o.objects.filter(m=>!b.has(m.id));return y.splice(Number.isFinite(f)?f:y.length,0,...l,...g?[g]:[]),o.objects.splice(0,o.objects.length,...y),{floorId:o.floorId,rowIds:l.map(m=>m.id),sectionId:g?.id??null,groupId:t.groupId,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function $a(e){let t=new Set(H(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(V(n));)n+=1;let o=V(n);return t.add(o),n+=1,o}}function Oo(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 Ba(e,t){if(E(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=O(e,t.floorId),a=new Set,r=$a(e),s=Dt(t.rotation??0),l=t.curve??0,c=t.style,d=c?A(e,"rowblock",t.idFactory,a):void 0,g=c?Oo({style:c,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:l}):void 0,b={x:Math.cos(s*Z),y:Math.sin(s*Z)},f={x:-b.y,y:b.x},y=Array.from({length:t.rowCount},(v,h)=>{let p=c==="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*p,y:t.origin.y+f.y*h*n+b.y*p},rotation:s,curve:l,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return c&&d&&g&&(w.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:c,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:l,signature:g}),w});i.objects.push(...y);let m=null,x=t.sectionLabel?.trim();if(x){let v=le(y);if(v){let h={type:"section",id:A(e,"sec",t.idFactory,a),label:x,outline:v};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:y.map(v=>v.id),sectionId:m,createdIds:[...y.map(v=>v.id),...m?[m]:[]]}}function Ro(e,t){let n=new Set(H(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 za(e,t){let n=new Set(H(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 Ua=456;function Po(e){let t=Math.sqrt(Math.max(1,e)*Ua);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ha(e,t){if(E(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=O(e,t.floorId),o=new Set,{width:i,height:a}=Po(t.capacity),r=za(e,(t.label??"General Admission").trim()||"General Admission"),s={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(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function Va(e,t){if(E(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=O(e,t.floorId),a=new Set,r=Ro(e,"T"),s=[];for(let l=0;l<t.tableRows;l+=1)for(let c=0;c<t.tableColumns;c+=1)s.push({type:"table",id:A(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.tableColumns-1)/2)*n,y:t.center.y+(l-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...s),{floorId:i.floorId,tableIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function qa(e,t){if(E(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=O(e,t.floorId),a=new Set,r=Ro(e,"B"),s=[];for(let l=0;l<t.boothRows;l+=1)for(let c=0;c<t.boothColumns;c+=1)s.push({type:"booth",id:A(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.boothColumns-1)/2)*n,y:t.center.y+(l-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function Xt(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(b=>b.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(b=>b.id)});let l=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!l||l.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let c=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=t.idFactory("rowgroup");if(f&&!c.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:l,...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 Ja(e,t){let n=O(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),i=t.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((s,l)=>s.segmentedRow.componentIndex-l.segmentedRow.componentIndex).map(s=>s.id);for(let s of a)delete s.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function Xa(e,t){let n=O(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.groupId).sort((r,s)=>r.segmentedRow.componentIndex-s.segmentedRow.componentIndex);if(o.length<2)throw new u("object_not_found","The segmented row is incomplete or missing on the selected floor");if(t.boundaries&&(t.boundaries.length!==o.length-1||t.boundaries.some(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=t.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,s)=>{let l=r.segmentedRow,c=l.viewFromSeatUrl;i!==void 0&&(l.displayLabel=i),t.boundaries&&s>0&&(l.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(l.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete l.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(l.viewFromSeatUrl=t.viewFromSeatUrl),!l.viewFromSeatUrl||t.viewFromSeatMeta===null?delete l.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?l.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&l.viewFromSeatUrl!==c&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ya(e,t){if(typeof t.groupId!="string"||!t.groupId)throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let n=O(e,t.floorId),o=n.objects.filter(M=>M.type==="row"&&M.rowBlockGeneration?.groupId===t.groupId).sort((M,z)=>M.rowBlockGeneration.rowIndex-z.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((M,z)=>{let P=M.rowBlockGeneration;return P.kind!=="row-block-v1"||P.rowIndex!==z||P.signature!==i.signature||JSON.stringify(P)!==JSON.stringify({...i,rowIndex:z})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,s=t.rowCount??i.rowCount,l=t.seatsPerRow??i.seatsPerRow,c=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?Dt(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.origin}:{...i.origin};if(!Number.isInteger(s)||s<1||s>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(l)||l<1||l>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![c,d].every(M=>Number.isFinite(M)&&M>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let y=Oo({style:r,origin:f,rotation:b,rowCount:s,seatsPerRow:l,rowGap:c,seatSpacing:d,curve:g}),m={x:Math.cos(b*Z),y:Math.sin(b*Z)},x={x:-m.y,y:m.x},v=new Map(o.map(M=>[M.rowBlockGeneration.rowIndex,M])),h=new Set,p=new Set(n.objects.filter(M=>M.type==="row").filter(M=>!o.includes(M)).map(M=>M.label)),w=n.objects.filter(M=>M.type==="row").length,S=()=>{for(;p.has(V(w));)w+=1;let M=V(w);return p.add(M),w+=1,M},I=[],C=[];for(let M=0;M<s;M+=1){let z=r==="intertwined"&&M%2===1?d/2:0,P=v.get(M);P||(P={type:"row",id:A(e,"r",t.idFactory,h),label:S(),origin:{...f},rotation:b,curve:g,seatCount:l,seatSpacing:d,categoryKey:o[0].categoryKey},C.push(P.id)),P.origin={x:f.x+x.x*M*c+m.x*z,y:f.y+x.y*M*c+m.y*z},P.rotation=b,P.curve=g,P.seatCount=l,P.seatSpacing=d,delete P.path,delete P.arcFanGeneration,P.overrides&&(P.overrides=P.overrides.filter(q=>q.index<l),P.overrides.length||delete P.overrides),P.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:M,rowCount:s,seatsPerRow:l,origin:{...f},rotation:b,rowGap:c,seatSpacing:d,curve:g,signature:y},I.push(P)}let j=o.slice(s).map(M=>M.id),L=Math.min(...o.map(M=>n.objects.indexOf(M))),T=new Set(o.map(M=>M.id)),G=n.objects.filter(M=>!T.has(M.id));return G.splice(L,0,...I),n.objects.splice(0,n.objects.length,...G),{floorId:n.floorId,groupId:t.groupId,rowIds:I.map(M=>M.id),createdRowIds:C,removedRowIds:j,changed:a!==JSON.stringify(I)||C.length>0||j.length>0}}function Mo(e){let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t/Math.max(1,e.length-1)}function Qa(e){let t=e.length,n=e.reduce((v,h)=>v+h.x,0)/t,o=e.reduce((v,h)=>v+h.y,0)/t,i=0,a=0,r=0,s=0,l=0,c=0,d=0;for(let v of e){let h=v.x-n,p=v.y-o;i+=h*h,a+=p*p,r+=h*p,s+=h*h*h,l+=p*p*p,c+=h*p*p,d+=p*h*h}let g=i*a-r*r;if(Math.abs(g)<1e-9)return null;let b=(s+c)/2,f=(l+d)/2,y=(b*a-f*r)/g,m=(f*i-b*r)/g,x=Math.sqrt(y*y+m*m+(i+a)/t);return Number.isFinite(x)?{center:{x:y+n,y:m+o},radius:x}:null}function Ke(e){let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),i=e.length;return{origin:{...t},rotation:o>0?Math.atan2(n.y-t.y,n.x-t.x)*180/Math.PI:0,curve:0,seatSpacing:i>1&&o>0?o/(i-1):Mo(e),seatCount:i,ordered:e}}function Za(e){if(e.length<3)return Ke(e);let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),i=Mo(e);if(o<=0||i<=0)return Ke(e);let a=0;for(let b of e){let f=Math.abs((n.x-t.x)*(t.y-b.y)-(t.x-b.x)*(n.y-t.y))/o;a=Math.max(a,f)}if(a<i*.2)return Ke(e);let r=Qa(e);if(!r||r.radius<=i/2)return Ke(e);let s=b=>{let f=b[0],y=b[1],m=f.x-r.center.x,v=-(f.y-r.center.y),h=m;v*(y.x-f.x)+h*(y.y-f.y)<0&&(v=-v,h=-h);let p=Math.hypot(v,h)||1;v/=p,h/=p;let w=(r.center.x-f.x)*h+(r.center.y-f.y)*-v;return{tx:v,ty:h,centreSide:w}},l=e,c=s(l);c.centreSide<0&&(l=[...e].reverse(),c=s(l));let g=2*Math.asin(Math.min(1,i/(2*r.radius)))*(l.length-1)*180/Math.PI;return!Number.isFinite(g)||g>=359?Ke(e):{origin:{...l[0]},rotation:Math.atan2(c.ty,c.tx)*180/Math.PI,curve:g,seatSpacing:i,seatCount:l.length,ordered:l}}function bt(e,t){let n=Za(e);if(e.length<6)return[n];let o=t(n),i=-1,a=0;if(n.ordered.forEach((s,l)=>{let c=o[l]?Math.hypot(s.x-o[l].x,s.y-o[l].y):1/0;c>a&&(a=c,i=l)}),a<=n.seatSpacing/3)return[n];let r=Math.min(n.ordered.length-3,Math.max(3,i));return[...bt(n.ordered.slice(0,r),t),...bt(n.ordered.slice(r),t)]}function Yt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Qt(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Zt(e){return Qt(Yt(e),40)}function _o(e,t=39){return Qt(Yt(e),Math.max(1,t))}function xe(e,t=80){return Qt(Yt(e),Math.max(1,t))}function Ao(e){return xe(e).toLocaleLowerCase("en")}function Wt(e){return Ao(e)}function jo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Wa(e){let t=jo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(te(e,o,i))}return n}function es(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=jo(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 ts(e){return e.type==="row"?[e.label,...Wa(e)]:e.type==="table"?[e.label,...es(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...oe(e)]:[]}function Lo(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of ts(o)){let a=Wt(i);a&&n.add(a)}return n}function ns(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Wt(e)];for(let i=0;i<t;i+=1)o.push(Wt(te(n,i)));return o.filter(Boolean)}function ko(e,t,n){let o=ns(t,n);if(!o.length||o.some(i=>e.has(i)||Te(i)))return!1;for(let i of o)e.add(i);return!0}var os=1e-6,rs=160,is=.001,as=1e-5;function Se(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>rs)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 Eo(e){return typeof e=="string"&&_o(e)||void 0}function To(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(en(e.origin)&&en(t.start)&&en(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=is+Math.max(1,i)*as;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<=os)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,l=Math.abs(((e.rotation-s)%360+540)%360-180),c=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return l<=c}function en(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var ss=300;function cs(e){let t=new Set(H(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(V(n));)n+=1;let i=V(n);return n+=1,t.add(i),i};return i=>{let a=Zt(i),r=0;return()=>{for(;a&&r<4096;r+=1){let s=`${a}-${V(r)}`;if(!t.has(s))return t.add(s),r+=1,s}return o()}}}function ls(e){let t=Lo(H(e));return(n,o)=>{let i=xe(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,s=r?`${xe(i,80-r.length)}${r}`:i;if(s&&ko(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function ds(e){return{ordinaryFor:cs(e),direct:ls(e)}}function tn(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Fo(e,t,n){return e.type==="table"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function us(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[s,l]of r.rows.entries()){let c=Se(`${r.sourceGroupId}:${s}`),d=c&&Se(l.directSourceRowId)===c?c:void 0;d&&o.set(d,o.has(d)?null:l)}let i=new Map;for(let r of e){let s=Se(r.referenceScan?.directSourceRowId);if(!s){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let l=i.get(s)??[];l.push(r),i.set(s,l)}let a=new Map;for(let[r,s]of i){let l=s.filter(b=>b.overrides?.length);if(!l.length)continue;let c=o.get(r),d=l[0],g=d.overrides;if(s.length!==1||l.length!==1||!g||!c||!To(d,c))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:s.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function No(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!tn(o,t,n)&&!Fo(o,t,n))}function fs(e,t,n,o,i,a,r){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=No(t,n,r).filter(g=>$(F(g),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let l=[],c=0;for(let[d,g]of e.rows.entries()){let b=Math.min(ss,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,y=g.end.y-g.start.y,m=Math.hypot(f,y),x=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let v=m>0?Math.atan2(y,f)*180/Math.PI:0,h={x:g.start.x,y:g.start.y},p=0,w=x,S,I=g.seats?.length===b&&g.seats.every(P=>Number.isFinite(P.x)&&Number.isFinite(P.y))?g.seats:null;if(I&&g.table&&b>=3){let P=g.table.center,q=I.reduce((K,J)=>K+Math.hypot(J.x-P.x,J.y-P.y),0)/b,ee=I.map(K=>Math.atan2(K.y-P.y,K.x-P.x)).sort((K,J)=>K-J),se=0,R=0;ee.forEach((K,J)=>{let un=J+1<ee.length?ee[J+1]:ee[0]+Math.PI*2;un-K>se&&(se=un-K,R=(J+1)%ee.length)});let _=se>1.6*(Math.PI*2/b),U=_?(Math.PI*2-se)*180/Math.PI:void 0;S={center:{...P},radius:Math.max(1,q-ie),...U!==void 0?{seatArc:U}:{}},v=_?(ee[R]-se/2)*180/Math.PI:ee[0]*180/Math.PI,h={...P}}let C=[];if(I&&!S&&b>=3){C=bt(I,q=>Y({origin:q.origin,rotation:q.rotation,curve:q.curve,seatCount:q.seatCount,seatSpacing:q.seatSpacing}));let P=C[0];h=P.origin,v=P.rotation,p=P.curve,w=P.seatSpacing}if(!Number.isFinite(w)||w<=0)continue;let j=e.sourceGroupId?Se(`${e.sourceGroupId}:${d}`):void 0,L=j&&Se(g.directSourceRowId)===j?j:void 0,T=L?Eo(g.directReviewedSuffix):void 0,G=e.sourceGroupId&&g.rowLabel?xe(g.rowLabel):"",M=e.sourceGroupId&&g.rowDisplayLabel?xe(g.rowDisplayLabel):"",z=!!e.sourceGroupId&&g.rowDisplayLabel==="";l.push({label:G?a(G,b):i(),displayLabel:M||(z?"":String(d+1)),origin:h,rotation:v,curve:p,seatCount:C[0]?.seatCount??b,seatSpacing:w,...S?{table:S}:{},...I&&!S?{measured:!0}:{},...L?{directSourceRowId:L}:{},...T?{directReviewedSuffix:T}:{}});for(let P of C.slice(1))l.push({label:i(),displayLabel:String(d+1),origin:P.origin,rotation:P.rotation,curve:P.curve,seatCount:P.seatCount,seatSpacing:P.seatSpacing,measured:!0});c+=b}return{skip:null,rows:l,seats:c}}function gs(e,t,n){E(e,n.categoryKey);let o=O(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=n.categoryKeyForSection?.(h)??n.categoryKey;E(e,p),r.set(h,p)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&s){let h=No(o.objects,i,a.id).filter(p=>$(F(p),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:h.map(p=>p.id)}]}}let l=o.objects.filter(h=>tn(h,i,a?.id)),c=us(l,t,a?.id),d=[],g=o.objects.filter(h=>tn(h,i,a?.id)||Fo(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],y=[],m=new Set,x=0,v=ds(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=fs(h,o.objects,i,t.seatPitch,v.ordinaryFor(h.name),v.direct,a?.id);if(p.skip){f.push(p.skip);continue}let w=[],S=[],I=0;for(let C of p.rows){let j={assetId:i,...h.sectionId?{sectionId:h.sectionId}:{}},L=r.get(h)??n.categoryKey;if(C.table){I+=1,w.push({type:"table",id:A(e,"t",n.idFactory,m),referenceScan:j,label:C.label,displayLabel:String(I),center:C.table.center,shape:"round",radius:C.table.radius,...C.table.seatArc!==void 0?{seatArc:C.table.seatArc}:{},rotation:C.rotation,seatCount:C.seatCount,categoryKey:L});continue}let T={type:"row",id:A(e,"r",n.idFactory,m),referenceScan:{...j,...C.directSourceRowId?{directSourceRowId:C.directSourceRowId}:{},...C.directReviewedSuffix?{directReviewedSuffix:C.directReviewedSuffix}:{}},label:C.label,...C.displayLabel!==void 0?{displayLabel:C.displayLabel}:{},origin:C.origin,rotation:C.rotation,curve:C.curve,seatCount:C.seatCount,seatSpacing:C.seatSpacing,categoryKey:L,...C.directSourceRowId&&c.has(C.directSourceRowId)?{overrides:structuredClone(c.get(C.directSourceRowId))}:{}};w.push(T),C.measured&&S.push(T)}if(o.objects.push(...w),S.length&&!h.sourceGroupId){let C=k(e).find(j=>j.id===o.floorId);bs(e,S,C?.focalPoint??e.focalPoint,o.floorId,n.idFactory)}for(let C of w)y.push(C.id);b.push({sectionId:h.sectionId,name:h.name,seats:p.seats,rows:w.length}),x+=p.seats}return{floorId:o.floorId,assetId:i,createdRowIds:y,removedRowIds:d,totalSeats:x,perSection:b,skipped:f}}function bs(e,t,n,o,i){let a=t.map(f=>Y(f)),r=a.flat(),s=n??{x:r.reduce((f,y)=>f+y.x,0)/r.length,y:Math.min(...r.map(f=>f.y))-1},l=t.map((f,y)=>{let m=a[y],x=m.map((h,p)=>{let w=m[Math.max(0,p-1)],S=m[Math.min(m.length-1,p+1)],I=Math.hypot(S.x-w.x,S.y-w.y);return I<=0?Math.hypot(h.x-s.x,h.y-s.y):Math.abs((h.x-s.x)*(-(S.y-w.y)/I)+(h.y-s.y)*((S.x-w.x)/I))}).sort((h,p)=>h-p),v=m.reduce((h,p)=>h+p.x,0)/m.length;return{row:f,depth:x[Math.floor(x.length/2)],along:v}}).sort((f,y)=>f.depth-y.depth||f.along-y.along),c=l.slice(1).map((f,y)=>f.depth-l[y].depth).filter(f=>f>1e-6).sort((f,y)=>f-y),d=c.length?c[Math.floor(c.length*.75)]:1/0,g=[],b=-1/0;for(let f of l)(!g.length||f.depth-b>d*.45)&&(g.push([]),b=f.depth),g[g.length-1].push(f.row);g.forEach((f,y)=>{let m=V(y);f.sort((x,v)=>{let h=Y(x),p=Y(v);return h.reduce((w,S)=>w+S.x,0)/h.length-p.reduce((w,S)=>w+S.x,0)/p.length});for(let x of f)x.displayLabel=m;f.length>=2&&f.length<=64&&Xt(e,{floorId:o,rowIds:f.map(x=>x.id),boundaries:f.slice(1).map(()=>"break"),displayLabel:m,idFactory:i})})}function Go(e,t,n={}){let o=O(e,t.floorId),i=[...new Set(t.objectIds)];if(!i.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=i.map(m=>o.objects.find(x=>(x.type==="table"||x.type==="booth")&&x.id===m)),r=i.filter((m,x)=>!a[x]);if(r.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:r});let s=a[0].type;if(a.some(m=>m.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[m,x,v]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(x)||x<1||x>v)throw new u("invalid_operation",`${m} must be a whole number from 1 to ${v}`);for(let[m,x]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(x)||x<30||x>2e3)throw new u("invalid_operation",`${m} must be from 30 to 2000 chart units`);let l=t.rows*t.columns;if(l<2)throw new u("invalid_operation","Choose at least two grid cells");let c=i.length*(l-1);if(c>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((m,x)=>m+(x.type==="table"?x.seatCount:1),0),b=(e.floors?.length?e.floors.flatMap(m=>m.objects):e.objects).reduce((m,x)=>m+(x.type==="row"||x.type==="table"?x.seatCount:x.type==="gaArea"?Math.max(0,Math.floor(x.capacity)):x.type==="booth"?1:0),0),f=d*(l-1),y=n.maxInventory??1e5;if(b+f>y)throw new u("invalid_operation",`Grid inventory would exceed the ${y} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:i,sourceCount:i.length,cells:l,createdCount:c,addedInventory:f,resultingInventory:b+f,provenanceRemovedCount:a.filter(m=>!!m.referenceInventorySource).length*(l-1)}}}function hs(e,t,n={}){return Go(e,t,n).preview}function ps(e,t,n={}){let{target:o,sources:i,preview:a}=Go(e,t,n),r=new Set,s=new Set((e.floors?.length?e.floors.flatMap(g=>g.objects):e.objects).flatMap(g=>"label"in g&&g.label?[g.label]:[])),l=[],c=(g,b)=>{let f=Math.max(2,b),y=x=>{let v=`-${x}`;return`${g.slice(0,Math.max(1,80-v.length))}${v}`},m=y(f);for(;s.has(m);)m=y(++f);return s.add(m),m},d=1;for(let g=0;g<t.rows;g++)for(let b=0;b<t.columns;b++)if(!(g===0&&b===0)){d+=1;for(let f of i){let y=structuredClone(f);y.id=A(e,y.type,t.idFactory,r),y.label=c(f.label,d),y.center={x:f.center.x+b*t.stepX,y:f.center.y+g*t.stepY},delete y.referenceInventorySource,l.push(y)}}return o.objects.push(...l),{...a,createdIds:l.map(g=>g.id)}}function ys(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=N(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var ms=new Set(ke.map(e=>e.key));function $e(e){return`${e.rowId}:${e.index}`}function ws(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 xs(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,Ge(e.glyph)||delete e.glyph;let n=Ae(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"&&Ze(t,e)}function Ss(e){return Object.keys(e).every(t=>t==="index")}function Ko(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=O(e,t),i=[],a=new Set,r=new Map;for(let s of n){let l=$e(s);if(a.has(l))continue;a.add(l);let c=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!c)throw new u("object_not_found",`Unknown row or table for seat: ${l}`,{seatId:l,objectId:s.rowId});if(c.type==="table"&&(c.bookAsWhole||c.variableOccupancy))throw new u("invalid_operation",`Table "${c.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:l,tableId:c.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=c.seatCount)throw new u("invalid_operation",c.type==="row"?`Seat index is outside row bounds: ${l}`:`Chair index is outside table bounds: ${l}`,{seatId:l,objectId:s.rowId,index:s.index,seatCount:c.seatCount});i.push({rowId:s.rowId,index:s.index}),r.set(c.id,c)}return{floorId:o.floorId,refs:i,owners:r}}function nn(e,t){let n=Ko(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&&E(e,t.patch.categoryKey),t.patch.glyph!=null&&!Ge(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=>!ms.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(c=>c.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,l=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(s&&l)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:$e(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=re(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&&me(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let s=n.owners.get(a.rowId),l=JSON.stringify(s.overrides??[]),c=s.overrides??(s.overrides=[]),d=c.find(b=>b.index===a.index);d||(d={index:a.index},c.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(y=>y!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let y=ys(d.labelStyle,f);y?d.labelStyle=y:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),xs(d,s),Ss(d)&&(s.overrides=c.filter(b=>b!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==l&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map($e)}}function Is(e,t){let n=Ko(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(l=>l.rowId===i).map(l=>l.index)),s=a.overrides.filter(l=>!r.has(l.index));s.length!==a.overrides.length&&(o=!0),a.overrides=s,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map($e)}}function vs(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(p=>p.type==="row"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&E(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,p=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!p.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${p.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:s,labelRotation:l,labelStyleShape:c,displayLabel:d,displayType:g,...b}=t.patch,f=d===void 0?{}:{displayLabel:d},y=ye(f,"Row"),m=g===void 0?void 0:Lt(g,"Row");if(r!==void 0&&me(r,"Row"),s!==void 0&&!["start","end","both","none"].includes(s))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(l!=null&&(!Number.isFinite(l)||l<-180||l>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(c!==void 0&&c!=="plain"&&c!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&tt(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}),v=!1;for(let h of i){let p=JSON.stringify(h),w=x(h),S=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?F(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(I=>I.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),S){let I=F(h);h.origin={x:h.origin.x+S.x-I.x,y:h.origin.y+S.y-I.y}}if(JSON.stringify(h)!==p&&(v=!0),x(h)!==w&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=nt(h.labelPresentation,r);C?h.labelPresentation=C:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(s!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=h.labelPresentation?structuredClone(h.labelPresentation):{};C.positionPreset=s,C.visible=s!=="none",delete C.position,h.labelPresentation=C,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(l!==void 0||c!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=h.labelPresentation?structuredClone(h.labelPresentation):{};l===null?delete C.rotation:l!==void 0&&(C.rotation=l),c!==void 0&&(C.style=c),h.labelPresentation=C,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(m!==void 0){let I=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==I&&(v=!0)}if(d!==void 0){let I=h.displayLabel;y?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==I&&(v=!0)}}return{floorId:n.floorId,changed:v,rowIds:o}}var Cs=3;function ht(e){return(e%360+360)%360}function Os(e){let t=e.rotation*Z;return{x:Math.cos(t),y:Math.sin(t)}}function Rs(e,t){let n=Math.abs(ht(e-t));return n>180&&(n=360-n),n}function Ie(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function $o(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*Z;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 Ps(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 Bo(e,t){let n=$o(e),o={x:-n.y,y:n.x},i=F(e[0]),a=e.map(l=>({row:l,coord:Ie(F(l),i,o)})).sort((l,c)=>l.coord-c.coord),r=a[0].coord,s=!1;return a.forEach((l,c)=>{let d=r+c*t-l.coord;Math.abs(d)>1e-6&&(Ps(l.row,o.x*d,o.y*d),delete l.row.arcFanGeneration,delete l.row.rowBlockGeneration,s=!0)}),s}function Ms(e,t){let n={x:-t.y,y:t.x},o=F(e[0]),i=e.map(r=>Ie(F(r),o,n)).sort((r,s)=>r-s);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function _s(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Y(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=ht(Math.atan2(a,i)/Z)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function As(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 js(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(I=>I.type==="row"&&I.id===S)),a=o.filter((S,I)=>!i[I]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(S=>S.path||S.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged. Straighten the rows first, then merge.",{rowIds:s.map(S=>S.id)});let l=r[0],c=r.find(S=>Rs(S.rotation,l.rotation)>Cs);if(c)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[l.id,c.id]});let d=Os(l),g={x:-d.y,y:d.x},b=Math.max(8,l.seatSpacing*.6),f=r.find(S=>Math.abs(Ie(S.origin,l.origin,g))>b);if(f){let S=Math.round(Math.abs(Ie(f.origin,l.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${S} units from the first.`,{rowIds:[l.id,f.id]})}let y=r.slice().sort((S,I)=>Ie(S.origin,l.origin,d)-Ie(I.origin,l.origin,d)),m=y.reduce((S,I)=>S+I.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=y[0],v=[],h=0;for(let S of y){if(S.overrides)for(let I of S.overrides)v.push({...structuredClone(I),index:I.index+h});h+=S.seatCount}x.seatCount=m,x.curve=0,delete x.path,v.length?x.overrides=v:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let p=y.slice(1).map(S=>S.id),w=new Set(p);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:p,seatCount:m}}function Ls(e,t){let n=O(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. 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=Y(o),s=i>1?o.curve/(i-1):0,l=i-a,c={type:"row",id:A(e,"r",t.idFactory,new Set),label:As(n.objects,o.label),origin:{...r[a]},rotation:ht(o.rotation-s*a),curve:s*(l-1),seatCount:l,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(c.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(c.seatLabelStart=o.seatLabelStart),o.commercial&&(c.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(c.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(c.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(c.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,c.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(c.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,c),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:c.id,firstSeatCount:a,secondSeatCount:l,newLabel:c.label}}function ks(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(s=>n.objects.find(l=>l.type==="row"&&l.id===s)),a=o.filter((s,l)=>!i[l]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=Bo(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function Es(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),l=s();for(let b of r)_s(b);let c=$o(r),d=ht(Math.atan2(c.y,c.x)/Z);for(let b of r)b.rotation=d;let g=Ms(r,c);return Bo(r,g),{floorId:n.floorId,changed:s()!==l,rowIds:o,gap:g}}var yt=br(require("polygon-clipping"),1),zo=100,Uo=512,on=8192,Zo=64,Ho=1e7,D=1e-7;function Wo(e,t){return Math.abs(e.x-t.x)<=D&&Math.abs(e.y-t.y)<=D}function er(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Wo(t[0],t[t.length-1]);)t.pop();return t}function Be(e,t,n){let o=Q(t,n,e);return Math.abs(o)>D?!1:e.x>=Math.min(t.x,n.x)-D&&e.x<=Math.max(t.x,n.x)+D&&e.y>=Math.min(t.y,n.y)-D&&e.y<=Math.max(t.y,n.y)+D}function tr(e,t,n,o){let i=Q(e,t,n),a=Q(e,t,o),r=Q(n,o,e),s=Q(n,o,t);return(i>D&&a<-D||i<-D&&a>D)&&(r>D&&s<-D||r<-D&&s>D)?!0:Math.abs(i)<=D&&Be(n,e,t)||Math.abs(a)<=D&&Be(o,e,t)||Math.abs(r)<=D&&Be(e,n,o)||Math.abs(s)<=D&&Be(t,n,o)}function Ts(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)&&tr(e[t],e[n],e[o],e[i]))return!0}}return!1}function Vo(e,t){return e.some((n,o)=>t.some((i,a)=>tr(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function rn(e,t){return!t.some((n,o)=>Be(e,n,t[(o+1)%t.length]))&&$(e,t,void 0)}function mt(e,t,n){let o=er(e);if(o.length<3||o.length>Uo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>Ho||Math.abs(i.y)>Ho||Wo(i,o[(a+1)%o.length]))||Math.abs(Re(o))<=D||Ts(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Uo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Fs(e){let t=mt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Zo)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>mt(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((s,l)=>{let c=a[(l+1)%a.length];return[s,{x:(s.x+c.x)/2,y:(s.y+c.y)/2}]}).every(s=>rn(s,t))||Vo(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(Vo(a,o[s])||rn(a[0],o[s])||rn(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function pt(e){return e.map(t=>[t.x,t.y])}function qo(e){return er(e.map(([t,n])=>({x:t,y:n})))}function Jo(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 Ns(e){return e.reduce((t,n)=>t+(Jo(n[0]??[])-n.slice(1).reduce((o,i)=>o+Jo(i),0)),0)}function an(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(an).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${an(t[n])}`).join(",")}}`}function Xo(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 Yo(e){return an({categoryKey:e.categoryKey,displayLabel:Xo(e,"displayLabel",80),displayType:Xo(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function Qo(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 Ds(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function nr(e,t,n={}){let o=O(e,t.floorId),i=[...new Set(t.gaAreaIds)];if(i.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(i.length>zo)throw new u("invalid_operation",`Join Areas supports at most ${zo} areas at once`);let a=i.map(R=>o.objects.find(_=>_.type==="gaArea"&&_.id===R)),r=i.filter((R,_)=>!a[_]);if(r.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:r});let s=a;E(e,s[0].categoryKey);let l=Yo(s[0]),c=s.find(R=>Yo(R)!==l);if(c)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[s[0].id,c.id]});let d=Fe(e).objectToSection,g=d.get(s[0].id)??"__ungrouped__",b=s.find(R=>(d.get(R.id)??"__ungrouped__")!==g);if(b)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,b.id],sectionIds:[g,d.get(b.id)??"__ungrouped__"]});let f=s.reduce((R,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>W)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return R+_.capacity},0);if(f>W)throw new u("invalid_operation",`Joined GA capacity would be ${f}, over the ${W}-unit area limit`,{capacity:f});let y=H(e).reduce((R,_)=>R+de(_),0),m=n.maxInventory??1e5;if(y>m)throw new u("invalid_operation",`Chart inventory exceeds the ${m}-unit publication limit`,{inventory:y});let x=s.map(Fs),v=x.reduce((R,_)=>R+_.outer.length+_.holes.reduce((U,K)=>U+K.length,0),0);if(v>on)throw new u("invalid_operation",`Join Areas supports at most ${on} source vertices`,{vertexCount:v});let h;try{let R=x.map(K=>[pt(K.outer)]);if(h=yt.default.union(R[0],...R.slice(1)),h.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:h.length});let _=x.flatMap(K=>K.holes.map(J=>[pt(J)]));_.length&&(h=yt.default.difference(h,..._));let U=x.findIndex(K=>{let J=[pt(K.outer),...K.holes.map(pt)];return Ns(yt.default.intersection(J,h))<=D});if(U>=0)throw new u("invalid_operation",`GA area ${s[U].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[U].id})}catch(R){throw R instanceof u?R:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:R instanceof Error?R.message:"polygon_union_failed"})}if(h.length!==1||!h[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:h.length});let p=qo(h[0][0]),w=h[0].slice(1).map(qo),S=p.length+w.reduce((R,_)=>R+_.length,0);if(w.length>Zo||S>on)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:w.length,vertexCount:S});mt(p,"outline",s[0].id),w.forEach(R=>mt(R,"cutout",s[0].id));let I=new Map(o.objects.map((R,_)=>[R.id,_])),C=s.slice().sort((R,_)=>Ds(Qo(R,I.get(R.id)??Number.MAX_SAFE_INTEGER),Qo(_,I.get(_.id)??Number.MAX_SAFE_INTEGER))),j=C[0],L=structuredClone(e),T=O(L,o.floorId),G=T.objects.find(R=>R.type==="gaArea"&&R.id===j.id);G.points=structuredClone(p),w.length?G.holes=structuredClone(w):delete G.holes;let M=new Set(C.slice(1).map(R=>R.id));for(let R=T.objects.length-1;R>=0;R-=1)M.has(T.objects[R].id)&&T.objects.splice(R,1);let z=Fe(L).objectToSection.get(j.id)??"__ungrouped__";if(z!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:j.id,beforeSectionId:g,afterSectionId:z});let P=[],q=new Set;for(let R of C){if(!Ft(R))throw new u("invalid_operation",`GA area ${R.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:R.id});let _=oe(R);if(_.length!==R.capacity||_.some(U=>q.has(U)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:R.id});_.forEach(U=>q.add(U)),P.push(...at(R))}if(P.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let ee=new Set(s.map(R=>R.id));for(let R of H(e).filter(_=>_.type==="gaArea"&&!ee.has(_.id))){let _=oe(R).find(U=>q.has(U));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:R.id})}let se=C.slice(1).map(R=>R.id);return{floorId:o.floorId,areaId:j.id,survivorLabel:j.label,removedAreaIds:se,sourceAreaCount:C.length,capacity:f,inventorySegmentCount:P.length,outerVertexCount:p.length,holeCount:w.length,sectionId:g,points:p,...w.length?{holes:w}:{},segments:P}}function Gs(e,t,n={}){let{segments:o,...i}=nr(e,t,n);return i}function Ks(e,t,n={}){let o=nr(e,t,n),i=O(e,o.floorId),a=i.objects.find(c=>c.type==="gaArea"&&c.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes,a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments);let r=new Set(o.removedAreaIds);for(let c=i.objects.length-1;c>=0;c-=1)r.has(i.objects[c].id)&&i.objects.splice(c,1);let{segments:s,...l}=o;return{...l,changed:!0}}function $s(e,t){let n=O(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(c=>n.objects.find(d=>d.type==="shape"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.labelStyle!==void 0){let c=i.filter(d=>d.role!=="stage");if(c.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:c.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<pe||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${pe} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=N(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");if(r.labelStyle.direction!==void 0&&r.labelStyle.direction!==null&&!zn.includes(r.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");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=N(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:N(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let c=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!c.length||c.length>20||c.some(d=>!d||d.length>100)||new Set(c).size!==c.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=c}if(r.lineCap!==void 0&&r.lineCap!==null&&!bo.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!ho.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[c,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!po.includes(d))throw new u("invalid_operation",`Shape ${c} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let c=i.filter(d=>!Vt(r.kind??d.kind));if(c.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:c.map(d=>d.id)})}let l=!1;for(let c of i){let d=JSON.stringify(c);if(r.label===null?delete c.label:r.label!==void 0&&(c.label=r.label),r.labelStyle!==void 0){let g={...c.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),r.labelStyle.direction===null||r.labelStyle.direction==="horizontal"?delete g.direction:r.labelStyle.direction!==void 0&&(g.direction=r.labelStyle.direction),Object.keys(g).length?c.labelStyle=g:delete c.labelStyle}if(r.fill===null?delete c.fill:r.fill!==void 0&&(c.fill=r.fill),r.kind!==void 0&&(c.kind=r.kind,Vt(c.kind)||(delete c.lineCap,delete c.lineJoin,delete c.startEnding,delete c.endEnding)),r.stroke===null?delete c.stroke:r.stroke!==void 0&&(c.stroke={...r.stroke}),r.opacity===null?delete c.opacity:r.opacity!==void 0&&(c.opacity=r.opacity),r.heightM===null?delete c.heightM:r.heightM!==void 0&&(c.heightM=r.heightM),r.eventConfigurationIds===null?delete c.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(c.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete c.lineCap:r.lineCap!==void 0&&(c.lineCap=r.lineCap),r.lineJoin===null?delete c.lineJoin:r.lineJoin!==void 0&&(c.lineJoin=r.lineJoin),r.startEnding===null?delete c.startEnding:r.startEnding!==void 0&&(c.startEnding=r.startEnding),r.endEnding===null?delete c.endEnding:r.endEnding!==void 0&&(c.endEnding=r.endEnding),r.cornerRadius===null)delete c.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(c.width??1/0,c.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;c.cornerRadius=c.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(c)!==d&&(Xe(c),l=!0)}return{floorId:n.floorId,changed:l,shapeIds:o}}function rr(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),s=Math.max(...o),l=Math.max(1,a-i),c=Math.max(1,s-r);return{cx:i+l/2,cy:r+c/2,width:l,height:c}}function Bs(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let s=n.objects.find(c=>c.type==="shape"&&c.id===r.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let l=s.role==="stage"?rr(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let c=s.points??[];if(c.length<3||c.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=c.map(x=>x.x),g=c.map(x=>x.y),b=Math.min(...d),f=Math.max(...d),y=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(y+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-y)}})();return{shape:s,update:r,box:l}}),a=!1;for(let{shape:r,update:s,box:l}of i)if(!(Math.abs(l.width-s.width)<1e-9&&Math.abs(l.height-s.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height;else{let c=s.width/l.width,d=s.height/l.height;r.points=(r.points??[]).map(g=>({x:l.cx+(g.x-l.cx)*c,y:l.cy+(g.y-l.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:s})=>({id:r.id,width:s.width,height:s.height}))}}function zs(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(s=>s.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(On.map(s=>s.key)),a=t.updates.map(s=>{if(!i.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let l=n.objects.find(c=>c.type==="shape"&&c.id===s.stageId);if(!l)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(l.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:l,stageKind:s.stageKind,box:l.stageKind===s.stageKind?null:rr(l)}}),r=!1;for(let s of a)s.box&&(s.shape.points=Rn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",s.shape.stageKind=s.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Hs(e){return[...dn(e)].map(([t,n])=>({key:t,...n}))}function Vs(e){if(!Array.isArray(e))return dn(e);let t=new Map;for(let{key:n,target:o,evidence:i}of e)t.set(n,{target:o,evidence:i});return t}function dn(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of k(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function wt(e){return Array.isArray(e)?e.map(wt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,wt(n)]))}function qs(e,t){return JSON.stringify(wt(e))===JSON.stringify(wt(t))}function sn(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Js(e){return e?e.status==="retracted"?"retract":sn(e)?"approve":"set":"clear"}function ir(e,t){let n=Vs(e),o=dn(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let s=n.get(r),l=o.get(r);if(s&&l&&qs(s.evidence,l.evidence))continue;let c=l?.target??s?.target;c&&a.push({...c,operation:Js(l?.evidence),...s?{before:s.evidence}:{},...l?{after:l.evidence}:{}})}return a}function Xs(e,t){return ir(e,t).some(n=>sn(n.before)||sn(n.after))}var Ys=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Qs=new Set(["generated","geometry-verified","configuration-verified"]),Zs=new Set(["none","comparable-build-reference","actual-build-checked"]),Ws=new Set(["clear","partial","obstructed"]);function cn(e){return e.toISOString().slice(0,10)}function ln(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function Ce(e,t,n){if(!ln(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function ve(e,t,n){if(e!==void 0)return Ce(e,t,n)}function xt(e,t,n){let o=n?[O(e,n)]:k(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function ar(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function ze(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return ar(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=xt(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=xt(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 St(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=ar(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=xt(e,t.objectId,t.floorId);return nn(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=xt(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 ec(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!ln(e.label,80)||!ln(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(!Ws.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>Ce(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 sr(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(!Ys.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Qs.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Zs.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=ve(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(g=>Ce(g,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=ve(e.assessedAt,40,"assessedAt")??cn(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=ve(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:cn(new Date(r+365*24*60*60*1e3))),l=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(l)||l<r||l>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let c=ve(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!c)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=ve(e.sourceLabel,120,"sourceLabel");if(n!=="none"&&!d)throw new u("invalid_operation","Real-world evidence requires a buyer-safe source describing what was checked");if(n==="actual-build-checked"&&(e.modelLevel!=="configuration-verified"||!o))throw new u("invalid_operation","An actual-build check requires a configuration-verified model and an event configuration");return{schema:"seatlayer.seat-confidence/1",evidenceId:Ce(e.evidenceId,120,"evidenceId"),modelVersion:Ce(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...c?{approvedByRole:c}:{},...d?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:ec(e.modeledTarget)}:{}}}function Oe(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 tc(e,t){let n=sr(t.evidence,t.now),o=JSON.stringify(ze(e,t)??null),i=St(e,t,n),a=JSON.stringify(ze(e,t)??null);return Oe(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function nc(e,t){let n=ze(e,t);if(!n)return Oe(t,{changed:!1});let o=St(e,t,void 0);return Oe(t,{changed:!0,...o,evidenceId:n.evidenceId})}function oc(e,t){let n=ze(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=Ce(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=ve(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:cn(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(r.basisSha256=s);let l=JSON.stringify(n),c=St(e,t,r);return Oe(t,{changed:l!==JSON.stringify(r),...c,evidenceId:r.evidenceId,status:"approved"})}function rc(e,t){let n=ze(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 Oe(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=St(e,t,o);return Oe(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,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,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});
|