`}function gt(t){return t==null||t===""||t==="public"}function Ft(t,e){var i,s,n;const o=(t!=null?t:"").trim();return(((i=(s=(n=/\p{L}/u.exec(o))===null||n===void 0?void 0:n[0])!==null&&s!==void 0?s:o[0])!==null&&i!==void 0?i:"")||e).toUpperCase().slice(0,1)}function no(t,e){var i;const s=new Set([...e].map(o=>Ft(o,"")).filter(Boolean)),n=Ft(t,"");return{letter:ho.includes(n)&&!s.has(n)?n:(i=[...ho].find(o=>!s.has(o)))!==null&&i!==void 0?i:n||"X",color:Ni[s.size%Ni.length]}}function El(t,e=0){return gt(t.id)?{letter:Ft(t.marker,"P"),color:t.color||"#f4b740"}:{letter:Ft(t.marker||t.name,"?"),color:t.color||Ni[e%Ni.length]}}function Il(t,e,i){var s,n,o;const a=new Map;for(const d of t){var r;const u=oo(e.get(d));a.set(u,((r=a.get(u))!==null&&r!==void 0?r:0)+1)}const l=[{id:Ue,name:(s=i==null||(n=i.publicSale)===null||n===void 0?void 0:n.name)!==null&&s!==void 0?s:ze},...((o=i==null?void 0:i.channels)!==null&&o!==void 0?o:[]).map(d=>({id:d.id,name:d.name}))],c=[];for(const d of l){const u=a.get(d.id);u&&c.push({channelId:d.id,name:d.name,count:u}),a.delete(d.id)}for(const[d,u]of a)c.push({channelId:d,name:gt(d)?ze:"Another channel",count:u});return c}function oo(t){return gt(t)?Ue:t}function ao(t){return{count:t.length,labels:t.slice(0,uo),truncated:t.length>uo}}function Ml(t){const{labels:e,allocation:i,statusOf:s,nameOf:n}=t,o=oo(t.targetChannelId),a=new Set;let r=0,l=0;const c=new Map,d=[],u=[],h=[];for(const v of e){var p;if(a.has(v))continue;a.add(v);const m=s(v);if(!m){h.push(v);continue}const g=oo(i.get(v));if(g===o){l+=1;continue}if(m==="held"){d.push(v);continue}if(m==="booked"){u.push(v);continue}g==="public"?r+=1:c.set(g,((p=c.get(g))!==null&&p!==void 0?p:0)+1)}const f=[...c.entries()].map(([v,m])=>({channelId:v,name:n(v),count:m}));return{changedFromPublic:{count:r},movedFromOtherChannel:{count:f.reduce((v,m)=>v+m.count,0),channels:f},alreadyInTarget:{count:l},skippedHeld:ao(d),skippedBooked:ao(u),notFound:ao(h)}}function Os(t){return t.changedFromPublic.count+t.movedFromOtherChannel.count}function _l(t){return t.movedFromOtherChannel.count>0}function Pl(t,e){const i=[];t.changedFromPublic.count&&i.push({kind:"add",icon:"+",count:t.changedFromPublic.count,text:`${t.changedFromPublic.count.toLocaleString()} from ${ze}`});for(const n of t.movedFromOtherChannel.channels){var s;i.push({kind:"move",icon:"⇄",count:n.count,text:`${n.count.toLocaleString()} moved out of ${(s=n.name)!==null&&s!==void 0?s:"another channel"}`,why:"needs this confirmation"})}return t.alreadyInTarget.count&&i.push({kind:"same",icon:"=",count:t.alreadyInTarget.count,text:`${t.alreadyInTarget.count.toLocaleString()} already in ${e}`,why:"unchanged"}),t.skippedHeld.count&&i.push({kind:"skip",icon:"⏸",count:t.skippedHeld.count,text:`${t.skippedHeld.count.toLocaleString()} in a buyer's checkout`,why:"can't move while held",peek:Fs(t.skippedHeld)}),t.skippedBooked.count&&i.push({kind:"skip",icon:"🔒",count:t.skippedBooked.count,text:`${t.skippedBooked.count.toLocaleString()} already sold`,why:"sales are never rewritten",peek:Fs(t.skippedBooked)}),t.notFound.count&&i.push({kind:"skip",icon:"?",count:t.notFound.count,text:`${t.notFound.count.toLocaleString()} not on this map`,why:"these seats are no longer part of the event",peek:Fs(t.notFound)}),i}function Fs(t){if(!t.labels.length)return;const e=t.labels.slice(0,4).join(", ");return t.truncated||t.labels.length>4?`${e}…`:e}function Rl(t){var e;const i=(e=t==null?void 0:t.retryAfterMs)!==null&&e!==void 0?e:t!=null&&t.latestHoldExpiresAt?Math.max(0,t.latestHoldExpiresAt-Date.now()):0;if(!i)return"in a moment";const s=Math.ceil(i/6e4);return s<=1?"in about a minute":`in about ${s} minutes`}function $l(t){var e;if(!t||!t.intent)return"—";const i=t.intent==="server"?"Website integration":t.intent==="hosted_link"?"Buyer link":t.intent==="internal"?"Your staff sell these":"Protected reserve",s=t.hasActiveGrants?"in use now":t.lastMintAt?`last used ${new Date(t.lastMintAt).toLocaleDateString()}`:null,n=(e=t.detail)!==null&&e!==void 0?e:s;return n?`${i} · ${n}`:i}function Bt(t){return t==="internal"?"Sell through your own staff":t==="server"?"Integrate a website or app":t==="hosted_link"?"Sell with a buyer link":"Keep as protected reserve"}function Ol(t){switch(t){case"internal":return"Only your own box office can sell these seats, through your secret key. Buyer links and website integrations are refused.";case"server":return"Your website's backend mints each buyer a short-lived session for these seats. Buyer links are refused; the code lives on the Embed page.";case"hosted_link":return"SeatLayer makes a link you send to a named group. They open it and buy only these seats. No other route can sell them.";default:return"Nobody can buy these seats. Every way of letting a buyer in — a buyer link, your website, even your own staff — is refused while this is the route. The seats stay out of public sale."}}function dm(t){return t==="hosted_link"?"hosted_link":t==="server"?"server":t==="staff"?"internal":null}function Bs(t){const e=ro(t==null?void 0:t.accessIntent),i=dm(t==null?void 0:t.route),s=`This channel is set to "${Bt(e)}"`;return i?`${s}, so it cannot do that. Switch it to "${Bt(i)}" first.`:`${s}, so it cannot do that. Choose a different route for this channel first.`}function ro(t){return t==="internal"||t==="server"||t==="hosted_link"||t==="none"?t:"none"}function zs(t,e,i){return`${t.toLocaleString()} ${t===1?e:i}`}function Fl(t){var e,i;const s=Math.max(0,(e=t==null?void 0:t.liveAccessLinks)!==null&&e!==void 0?e:0),n=Math.max(0,(i=t==null?void 0:t.activeSessions)!==null&&i!==void 0?i:0),o=ro(t==null?void 0:t.from),a=ro(t==null?void 0:t.to),r=`${[s?zs(s,"buyer link is live","buyer links are live"):null,n?zs(n,"buyer is in a checkout","buyers are in a checkout"):null].filter(Boolean).join(", and ")||"Buyers are inside this channel"} on "${Bt(o)}". Moving it to "${Bt(a)}" changes what happens to them.`,l=[];return s&&l.push(`${zs(s,"buyer link closes","buyer links close")} immediately. Anyone who has not opened it yet never will — send a new link if you still need one.`),n&&l.push(`${zs(n,"buyer who is already in a checkout keeps","buyers who are already in a checkout keep")} their seats and can finish paying. Nobody is thrown out. No new buyers come in this way, so the old route empties on its own within 12 hours.`),{headline:r,consequences:l}}function Bl(t){var e;switch((e=t.status)!==null&&e!==void 0?e:t.state){case"active":return{text:"Active",kind:"active"};case"expired":return{text:"Expired",kind:"archived"};case"exhausted":return{text:"All used",kind:"paused"};case"rotated":return{text:"Replaced",kind:"archived"};default:return{text:"Revoked",kind:"archived"}}}function lo(t){return t.state==="active"&&t.status==="active"}function hm(t){return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit"}):"—"}function co(t){return[{k:"Expires",v:hm(t.expiresAt)},{k:"Redemptions",v:`${t.redemptions.toLocaleString()} of ${t.maxRedemptions.toLocaleString()} used`},{k:"Seats per buyer",v:`${t.maxQuantity.toLocaleString()} seat${t.maxQuantity===1?"":"s"} maximum`},{k:"Covers",v:t.includePublic?"This channel's allocation and Public sale seats":"This channel's allocation only"}]}function Hi(t){var e;const i=t==null||(e=t.serverMessage)===null||e===void 0?void 0:e.trim();switch(t==null?void 0:t.code){case"invalid_expiry":case"invalid_max_redemptions":case"invalid_max_quantity":case"invalid_session_ttl":case"invalid_label":return i||"That setting is outside what a hosted link allows. Adjust it and try again.";case"too_many_access_links":return i||"This channel already has as many live links as it can hold. Revoke one before creating another.";case"access_link_not_active":return"That link is no longer active, so it cannot be rotated or revoked.";case"channel_unavailable":return"This channel is paused or archived, so it cannot let new buyers in. Resume it first.";case"channel_access_intent_forbids":return Bs(t==null?void 0:t.details);case"end_active_sessions_required":return"Choose what happens to the buyers who already came in through this link.";case"not_found":return"That link is no longer here. Refresh and try again.";default:return(t==null?void 0:t.status)===403?"Hosted access links need channel-management permission.":i||"That did not go through. Try again."}}function um(t){var e;return((e=t==null?void 0:t.channels)!==null&&e!==void 0?e:[]).map(i=>{var s,n,o;return{kind:"skip",icon:"⚠",count:i.count,text:`${i.count.toLocaleString()} would leave ${(s=i.name)!==null&&s!==void 0?s:"a channel"}`,why:"the new chart no longer has these seats",peek:!((n=i.labels)===null||n===void 0)&&n.length?Fs({count:i.count,labels:i.labels,truncated:(o=i.truncated)!==null&&o!==void 0?o:!1}):void 0}})}function zl(t){return t==="builtin"?"Built-in":t==="active"?"Active":t==="paused"?"Paused":"Archived"}var Ue,ze,Ni,pm,ho,uo,Ds,po=rt((()=>{Ue="public",ze="Public sale",Ni=["#a78bfa","#2dd4bf","#fb923c","#60a5fa","#f472b6","#a3e635","#f87171","#38bdf8","#c084fc","#facc15"],pm="#f4b740",ho="ABCDEFGHJKLMNPQRSTUVWXYZ",uo=12,Ds={maxRedemptions:100,maxQuantity:4}}));function fo(t){return t.map((e,i)=>`
-
There is nothing more to set up on this screen. Your own server mints a short-lived buyer
- access session for this channel with the SeatLayer server SDK and hands it to the widget. A channel name
- on its own never grants access.
${e&&!this.showArchived?`No open channels — every seat is on public sale. ${e.toLocaleString()} archived channel${e===1?" is":"s are"} hidden below.`:"No private channels yet — every seat is on public sale."}
ℹ
- This channel is no longer on this event. It was archived or removed while you had it open.
- ${this.showArchived?"":"Archived channels are hidden — use “Show archived” on the list to see it."}
`;const a=this.caps.manage?`
-
Lifecycle
-
-
-
-
-
-
Archive returns the allocation to a destination you choose. Nothing is ever deleted silently.
- ${l?`${l.toLocaleString()} custom price${l===1?"":"s"} override the event price for this channel.`:"This channel uses the event prices."}
-
-
-
Only buyers admitted to this channel see and pay these prices. Existing holds keep the price already promised.
`:"";return`
- ${n}
-
Channel · ${H(o.name)}
-
${this.channelRowHtml(o)}
- ${c}
- ${r}
- ${a}`}distributeHtml(t){var e,i,s;const n=(e=(i=t.access)===null||i===void 0?void 0:i.intent)!==null&&e!==void 0?e:"none",o=((s=t.access)===null||s===void 0?void 0:s.hasActiveGrants)===!0,a=this.linksState!=="unsupported",r=this.links.some(lo),l=n==="none"?"Protected reserve — no route can sell these seats. Every buyer path is refused.":n==="internal"?"Your staff sell these seats. No buyer-facing route is open.":o?n==="server"?"Your website is letting buyers in. Only they can buy these seats.":"A buyer link is live. Only people with that link can buy these seats.":n==="server"?"Set up for your website — no buyer has come through yet. Seats stay reserved.":"Set up for buyer links — no buyer has come through yet. Seats stay reserved.",c=(d,u,h,p)=>{const f=d===n;return`
A link is shown once, when you create it. SeatLayer keeps only a fingerprint of it, so it
- can never be shown again — if a link is lost, rotate it and send the fresh one.
⏸
- This private sale is not available. ${H(((a=this.previewProjection.unavailable)!==null&&a!==void 0?a:[]).map(w=>{var C;return`${(C=this.nameOf(w.channelId))!==null&&C!==void 0?C:"This channel"} is ${w.state}`}).join("; ")||"The audience cannot buy right now")}.
- A buyer arriving with this access sees this message, not these seats.
✓${y.toLocaleString()} ${y===1?"seat is":"seats are"} available now.
- This is the exact buyer-visible allocation.${((u=this.previewProjection)===null||u===void 0?void 0:u.includePublic)===!1?" Public sale seats are not included in this access.":""}
`:"";return`
-
Preview buyer access
-
-
-
-
- ${gt(p)?"":`
- `}
-
This is the same projection the buyer SDK receives for this audience — not a local
- approximation. It is read-only: clicks open seat details, and no holds are created.
${(A.length-z.length).toLocaleString()} more row${A.length-z.length===1?"":"s"}. Search to narrow the list.
`)}),f.innerHTML=S.join("")||(y?`
No sections or rows match “${H(y)}”.
`:`
This chart has no rows with selectable seats.
- Use Drag box or the seat list instead.
`),g.textContent=y?`Showing ${E.toLocaleString()} of ${T.toLocaleString()} matching rows. Section checkboxes still select every row in that section.`:"Showing section groups. Expand one or search to see rows.",f.querySelectorAll("[data-ch-scope-group]").forEach(L=>L.addEventListener("click",()=>{var I,M;const x=(I=(M=a[Number(L.dataset.chScopeGroup)])===null||M===void 0?void 0:M[1])!==null&&I!==void 0?I:[],A=x.every(P=>c.has(P.id));for(const P of x)A?c.delete(P.id):c.add(P.id);C(),w()})),f.querySelectorAll("[data-ch-scope-toggle]").forEach(L=>L.addEventListener("click",()=>{const I=Number(L.dataset.chScopeToggle);d.has(I)?d.delete(I):d.add(I),C()})),f.querySelectorAll("[data-ch-scope-id]").forEach(L=>L.addEventListener("click",()=>{const I=L.dataset.chScopeId;c.has(I)?c.delete(I):c.add(I),C(),w()}))};v.addEventListener("input",()=>{y=v.value.trim().toLocaleLowerCase(),C(),w()}),h.addEventListener("click",()=>{const S=[...k()];!c.size||S.length>Me||(this.closeDialog(),this.host.selectByLabels(S))}),C(),w()});return}const o=[...s.entries()].map(([a,r])=>`
-
A named allocation only the right audience can buy from. You'll pick the seats next.
-
-
-
-
Shown to your team and in reports — never to buyers.
-
-
-
-
- ${H(o.letter)}
- Letter comes from the name; colour is chosen automatically from the next available palette. Buyers never see either.
-
-
-
-
-
-
A stable ID for your own system and webhooks.
-
-
${H((s=t.error)!==null&&s!==void 0?s:"")}
-
-
-
-
-
`,a=>{const r=a.querySelector("#slm-ch-name"),l=a.querySelector("[data-ch-marker]");r.addEventListener("input",()=>{const c=no(r.value,n);l.textContent=c.letter,l.style.background=c.color}),a.querySelectorAll("[data-ch-create]").forEach(c=>{c.addEventListener("click",()=>{var d,u,h;const p=c.dataset.chCreate==="allocate";this.createChannel(r.value,(d=l.textContent)!==null&&d!==void 0?d:"",l.style.background,(u=(h=a.querySelector("#slm-ch-ref"))===null||h===void 0?void 0:h.value)!==null&&u!==void 0?u:"",p)})})})}async createChannel(t,e,i,s,n){const o=t.trim();if(!o){this.showDialogError("Give the channel a name your team will recognise.");return}try{const a=await this.host.api.createChannel(this.host.eventKey,{name:o,marker:Ft(e,"")||null,color:i||null,externalRef:s.trim()||null});this.closeDialog(),await this.refresh(),this.targetChannelId=a.channel.id,this.detailChannelId=n?null:a.channel.id,this.announce(`Channel ${o} created with 0 seats allocated.`),this.host.toast(n?`${o} created. Select seats on the map to allocate them.`:`${o} created.`,"ok"),this.paintRail()}catch(a){const r=a instanceof he?a.code:void 0;this.showDialogError(r==="channel_name_taken"?"That name is already used on this event. Pick another.":"Couldn't create the channel. Try again."),this.host.onError(a)}}showDialogError(t){var e;const i=(e=this.scrimEl)===null||e===void 0?void 0:e.querySelector("[data-ch-error]");i&&(i.textContent=t,i.hidden=!1)}renderReviewDialog(t){var e,i,s;const{labels:n,buckets:o}=this.currentPlan(),a=t.applied,r=a?a.buckets:o,l=(e=this.nameOf((i=a==null?void 0:a.targetChannelId)!==null&&i!==void 0?i:this.targetChannelId))!==null&&e!==void 0?e:ze,c=Pl(r,l),d=a?a.applied:Os(o),u=!a&&n.length>0&&d===0,h=!a&&n.length>Me,p=fo(c),f=a?'':`
-
-
-
`,v=!a&&_l(o)?'
Applying moves inventory out of another private channel. That is the line marked above.
':"",m=u?`
ℹNothing in this selection can move right now —
- every seat is in a buyer's checkout, already sold, or already in ${H(l)}.
`:"",g=h?`
ℹChoose fewer seats.
- One Apply can cover at most ${Me.toLocaleString()} seats.
`:"";this.renderScrim(`
-
${a?`Moved ${a.applied.toLocaleString()} seat${a.applied===1?"":"s"} to ${H(l)}`:`Move ${n.length.toLocaleString()} selected seat${n.length===1?"":"s"} to ${H(l)}`}
-
${a?"These are the exact counts the server applied.":"Every selected seat is in exactly one line below."}
- ${m}
- ${g}
- ${p||'
Nothing selected.
'}
- ${v}
-
${H((s=t.error)!==null&&s!==void 0?s:"")}
- ${f}`,b=>{var y;(y=b.querySelector("[data-ch-apply]"))===null||y===void 0||y.addEventListener("click",()=>{this.apply()})}),a&&this.announce(`Applied ${a.applied} change${a.applied===1?"":"s"} to ${l}.`)}async apply(){if(!this.dialog||!this.caps.manage)return;const{labels:t}=this.currentPlan();if(t.length){if(t.length>Me){this.showDialogError(`Choose at most ${Me.toLocaleString()} seats for one Apply.`);return}this.dialog={...this.dialog,busy:!0,error:null},this.renderDialog();try{const e=await this.host.api.applyChannelAssignment(this.host.eventKey,{targetChannelId:gt(this.targetChannelId)?null:this.targetChannelId,labels:t,assignmentVersion:this.assignmentVersion});this.assignmentVersion=e.assignmentVersion,this.conflict=!1,await this.refresh({quiet:!0}),this.closeDialog({restoreFocus:!1}),this.host.clearSelection(),this.showApplied(e)}catch(e){if(e instanceof he&&e.status===409&&e.code==="channel_assignment_conflict"){this.conflict=!0,this.closeDialog(),this.shakeStaged(),this.paintRail(),this.announce("Assignments changed while you were editing. Nothing was applied and your selection is kept.");return}if(e instanceof he&&e.status===403){this.caps={view:this.caps.view,manage:!1},this.closeDialog(),this.paintRail(),this.host.toast("Changing channels needs channel-management permission.","err");return}this.dialog={kind:"review",busy:!1,error:"Couldn't apply those changes. Try again."},this.renderDialog(),this.host.onError(e)}}}showApplied(t){var e,i;const s=(e=this.nameOf(t.targetChannelId))!==null&&e!==void 0?e:ze,n=t.buckets.skippedHeld.count+t.buckets.skippedBooked.count+t.buckets.notFound.count;this.setStaged(`✓
- Assigned ${t.applied.toLocaleString()} seat${t.applied===1?"":"s"} to ${H(s)}
- ${n?` · ${n.toLocaleString()} skipped`:""}
-
- `,"done"),(i=this.stagedEl)===null||i===void 0||(i=i.querySelector("[data-ch-applied-details]"))===null||i===void 0||i.addEventListener("click",()=>{this.openDialog({kind:"review",applied:t})}),this.announce(`Assigned ${t.applied} seat${t.applied===1?"":"s"} to ${s}${n?`; ${n} skipped`:""}.`),this.stagedDoneTimer&&clearTimeout(this.stagedDoneTimer),this.stagedDoneTimer=setTimeout(()=>this.setStaged(null),5e3)}shakeStaged(){const t=this.stagedEl;!t||!t.classList.contains("on")||(t.classList.remove("shake"),t.offsetWidth,t.classList.add("shake"))}renderMenuDialog(t){var e;const i=(e=this.list)===null||e===void 0?void 0:e.channels.find(n=>n.id===t.channelId);if(!i||!this.caps.manage){this.closeDialog();return}const s=i.state==="paused";this.renderScrim(`
-
${H(i.name)}
-
Open the channel to allocate seats and hand out buyer access.
- These are the rest of its actions.
-
-
-
-
-
-
-
Pausing stops new buyer access; checkouts already running can finish.
- Archiving closes the channel for good and returns its free seats to a destination you choose.
- Nothing is ever deleted silently.
`,n=>{var o;(o=n.querySelector("[data-ch-rename]"))===null||o===void 0||o.addEventListener("click",()=>{var a,r;const l=(a=(r=n.querySelector("#slm-ch-newname"))===null||r===void 0?void 0:r.value)!==null&&a!==void 0?a:"";if(!l.trim()){this.showDialogError("A channel needs a name.");return}this.host.api.renameChannel(this.host.eventKey,s.id,l.trim()).then(()=>(this.closeDialog(),this.refresh())).catch(c=>{this.showDialogError(c instanceof he&&c.code==="channel_name_taken"?"That name is already used on this event.":"Couldn't rename the channel."),this.host.onError(c)})})})}renderPricingDialog(t){var e,i,s;const n=(e=this.list)===null||e===void 0?void 0:e.channels.find(l=>l.id===t.channelId),o=this.host.api.updateChannelPricing;if(!n||!o||!this.caps.manage){this.closeDialog();return}const a=new Map(((i=n.priceOverrides)!==null&&i!==void 0?i:[]).map(l=>{var c;return[`${l.categoryKey}\0${(c=l.tierId)!==null&&c!==void 0?c:""}`,l.price]})),r=this.host.categories().flatMap(l=>{var c;return(!((c=l.tiers)===null||c===void 0)&&c.length?l.tiers:[null]).map(d=>{var u,h,p;const f=(u=d==null?void 0:d.id)!==null&&u!==void 0?u:null,v=`${l.key}\0${f!=null?f:""}`,m=(h=(p=d==null?void 0:d.price)!==null&&p!==void 0?p:l.price)!==null&&h!==void 0?h:0,g=a.get(v),b=d?`${l.label} · ${d.name}`:l.label;return``})}).join("");this.renderScrim(`
-
Prices for ${H(n.name)}
-
Set only the prices that differ for this audience. Leave a field blank to use the event price.
-
${r||'
This event has no priced categories.
'}
-
${H((s=t.error)!==null&&s!==void 0?s:"")}
-
-
-
-
`,l=>{var c;(c=l.querySelector("[data-ch-price-save]"))===null||c===void 0||c.addEventListener("click",()=>{const d=[];for(const u of l.querySelectorAll("[data-ch-price-category]")){const h=u.value.trim();if(!h)continue;const p=Number(h);if(!Number.isFinite(p)||p<0||p>1e6){u.focus(),this.showDialogError("Enter a price from 0 to 1,000,000, or leave the field blank.");return}d.push({categoryKey:u.dataset.chPriceCategory,tierId:u.dataset.chPriceTier||null,price:p})}this.saveChannelPricing(n,d)})})}async saveChannelPricing(t,e){const i=this.host.api.updateChannelPricing;if(!(!i||!this.dialog||this.dialog.kind!=="pricing")){this.dialog={...this.dialog,busy:!0,error:null},this.renderDialog();try{var s;await i.call(this.host.api,this.host.eventKey,t.id,e,(s=t.pricingVersion)!==null&&s!==void 0?s:0),this.closeDialog(),await this.refresh(),this.host.toast(e.length?`Custom prices saved for ${t.name}.`:`${t.name} now uses event prices.`,"ok")}catch(n){if(n instanceof he&&n.code==="channel_pricing_conflict"){await this.refresh({quiet:!0}),this.dialog={kind:"pricing",channelId:t.id,error:"Prices changed in another window. Latest values are shown — review and save again."},this.renderDialog();return}this.dialog={kind:"pricing",channelId:t.id,error:n instanceof he&&n.serverMessage?n.serverMessage:"Couldn't save these prices. Try again."},this.renderDialog(),this.host.onError(n)}}}async chooseWebsiteIntegration(){this.detailChannelId&&await this.setAccessIntent("server")}async setAccessIntent(t,e={}){const i=this.detailChannelId;if(!i||!this.caps.manage)return!1;try{const s=await this.host.api.setChannelAccessIntent(this.host.eventKey,i,t,e);return await this.refresh(),this.host.toast(this.intentSavedCopy(t,s==null?void 0:s.intentSwitch),"ok"),!0}catch(s){return s instanceof he&&s.code==="channel_intent_switch_blocked"?(this.openDialog({kind:"intentSwitch",channelId:i,intentTo:t,switchBlocked:s.details}),!1):s instanceof he&&s.code==="channel_access_intent_forbids"?(this.host.toast(Bs(s.details),"err"),!1):(this.host.toast("Couldn't change how this channel reaches buyers.","err"),this.host.onError(s),!1)}}intentSavedCopy(t,e){const i=t==="server"?"Set to your website or app. The embed code is on the Embed page.":t==="internal"?"Only your own staff can sell this channel now.":t==="hosted_link"?"Set to buyer links. Create one to let buyers in.":"Kept as a protected reserve. No route can sell these seats.";return e?`${i}${e.closedLinks?` ${e.closedLinks.toLocaleString()} buyer link${e.closedLinks===1?"":"s"} closed.`:""}${e.keptSessions?` ${e.keptSessions.toLocaleString()} buyer${e.keptSessions===1?"":"s"} already in a checkout can still finish.`:""}`:i}async togglePause(t=this.detailChannelId){var e;const i=(e=this.list)===null||e===void 0?void 0:e.channels.find(n=>n.id===t);if(!i||!this.caps.manage)return;const s=i.state!=="paused";try{await this.host.api.setChannelPaused(this.host.eventKey,i.id,s),await this.refresh(),this.host.toast(s?`${i.name} paused. Existing checkouts can finish; no new buyer access is issued.`:`${i.name} resumed.`,"ok")}catch(n){this.host.toast("Couldn't change that channel.","err"),this.host.onError(n)}}renderArchiveDialog(t){var e,i,s,n,o;const a=(e=this.list)===null||e===void 0?void 0:e.channels.find(u=>u.id===t.channelId);if(!a){this.closeDialog();return}const r=(i=t.archiveBlocked)!==null&&i!==void 0?i:null,l=!r&&a.counts.held>0,c=this.assignableChannels().filter(u=>u.id!==a.id),d=r?`
⏳
- ${((s=(n=r.heldUnits)!==null&&n!==void 0?n:r.activeHolds)!==null&&s!==void 0?s:0).toLocaleString()} seats are in a buyer's checkout right now.
- Archive is unavailable while seats are held — try again ${H(Rl(r))}.
`:l?`
⏳
- ${a.counts.held.toLocaleString()} seats are in a buyer's checkout right now.
- Archive is refused while any seat is held — you can try, and we'll tell you when to come back.
`:"";this.renderScrim(`
-
Archive ${H(a.name)}
-
The channel closes for good. Its seats move to a destination you choose;
- sales history keeps its attribution.
- ${d}
-
-
-
-
-
${a.counts.booked.toLocaleString()} sold seats keep "${H(a.name)}" on their sale
- record. If one is cancelled later it returns to the destination above. Any buyer access for this channel
- stops working.
-
${H((o=t.error)!==null&&o!==void 0?o:"")}
-
-
-
-
`,u=>{var h;(h=u.querySelector("[data-ch-archive]"))===null||h===void 0||h.addEventListener("click",()=>{var p,f;const v=(p=(f=u.querySelector("#slm-ch-dest"))===null||f===void 0?void 0:f.value)!==null&&p!==void 0?p:"";this.archive(a.id,v||null)})})}async archive(t,e){try{await this.host.api.archiveChannel(this.host.eventKey,t,e),this.closeDialog(),this.detailChannelId=null,await this.refresh(),this.host.toast("Channel archived. Its remaining seats moved to the destination you chose.","ok")}catch(s){if(s instanceof he&&s.status===409&&s.code==="channel_archive_blocked_by_holds"){var i;this.dialog={kind:"archive",channelId:t,archiveBlocked:(i=s.details)!==null&&i!==void 0?i:{}},this.renderDialog();return}this.showDialogError("Couldn't archive that channel. Try again."),this.host.onError(s)}}renderSeatListDialog(){const t=new Set(this.host.selectionLabels()),e=new Map;let i=0;for(const l of this.host.seats()){var s,n,o,a;if(i+=1,i>this.seatListLimit)break;const c=this.host.sectionOfLabel(l.label),d=(s=c==null?void 0:c.id)!==null&&s!==void 0?s:"",u=(n=e.get(d))!==null&&n!==void 0?n:{label:(o=c==null?void 0:c.label)!==null&&o!==void 0?o:"Other seats",seats:[]};u.seats.push({label:l.label,status:(a=this.host.statusOf(l.label))!==null&&a!==void 0?a:"free"}),e.set(d,u)}const r=[...e.entries()].map(([l,c])=>`
-
Anyone who opens the link can buy from this channel's allocation — and only from it.
- You'll see the link once, right after you create it.
-
-
-
-
So you can tell your links apart later. Buyers never see it.
-
-
-
-
-
-
-
-
-
-
-
-
-
Each buyer who opens the link uses one.
-
-
-
-
-
-
-
${H((i=t.error)!==null&&i!==void 0?i:"")}
-
-
-
-
`,n=>{var o;const a=n.querySelector("[data-ch-lk-expiry]"),r=n.querySelector("[data-ch-lk-when-field]"),l=n.querySelector("#slm-ch-lk-when");a.addEventListener("change",()=>{const c=a.value==="custom";r.hidden=!c,c&&!l.value&&(l.value=fm(Date.now()+7*864e5))}),(o=n.querySelector("[data-ch-lk-create]"))===null||o===void 0||o.addEventListener("click",()=>{var c,d,u;const h=Dl(n,"#slm-ch-lk-redemptions"),p=Dl(n,"#slm-ch-lk-quantity");if(h==null||p==null){this.showDialogError("Those two settings need to be whole numbers.");return}let f;if(a.value==="custom"&&(f=Date.parse(l.value),!Number.isFinite(f))){this.showDialogError("Pick the date and time the link should stop working.");return}this.createLink(s.id,{label:((c=n.querySelector("#slm-ch-lk-label"))===null||c===void 0?void 0:c.value.trim())||null,includePublic:(d=(u=n.querySelector("#slm-ch-lk-public"))===null||u===void 0?void 0:u.checked)!==null&&d!==void 0?d:!1,...f===void 0?{}:{expiresAt:f},maxRedemptions:h,maxQuantity:p})})})}async createLink(t,e){await this.ensureHostedLinkRoute(t,e)&&await this.mintLink(t,e)}async mintLink(t,e){try{const i=await this.host.api.createAccessLink(this.host.eventKey,t,e);this.revealLink(i,{channelId:t}),await this.reloadAfterLinkChange(t)}catch(i){this.showDialogError(Hi(i instanceof he?i:void 0)),i instanceof he||this.host.onError(i)}}async ensureHostedLinkRoute(t,e){var i,s,n;const o=(i=this.list)===null||i===void 0?void 0:i.channels.find(a=>a.id===t);if(((s=o==null||(n=o.access)===null||n===void 0?void 0:n.intent)!==null&&s!==void 0?s:"none")==="hosted_link")return!0;try{return await this.host.api.setChannelAccessIntent(this.host.eventKey,t,"hosted_link"),await this.refresh(),!0}catch(a){return a instanceof he&&a.code==="channel_intent_switch_blocked"?(this.openDialog({kind:"intentSwitch",channelId:t,intentTo:"hosted_link",switchBlocked:a.details,pendingLink:e}),!1):(this.showDialogError(a instanceof he&&a.code==="channel_access_intent_forbids"?Bs(a.details):"Couldn't set this channel up for buyer links. Try again."),a instanceof he||this.host.onError(a),!1)}}revealLink(t,e){const i=t.url;this.dialog=null;const s=e.rotated?`
⚠
- The old link has stopped working. ${t.endedSessions?`${t.endedSessions.toLocaleString()} buyer${t.endedSessions===1?"":"s"} lost access immediately.`:"Buyers who already came in can finish; every new visit needs this link."}
`:"",n=co(t.link).map(o=>`
${H(o.k)}
- ${H(o.v)}
`).join("");this.renderScrim(`
-
Copy this link now
-
This is the only time SeatLayer can show it. We keep just a fingerprint, so it cannot be
- shown again — if it is lost, rotate the link for a fresh one.
- ${s}
-
${H(i)}
-
-
-
-
⚠
- Anyone who opens this link can buy from this allocation. Send it only to the people it is meant
- for — forwarding it hands on the same access, and SeatLayer cannot tell the difference.
-
What this link allows
- ${n}
-
-
-
`,o=>{const a=o.querySelector("[data-ch-lk-copy]");a==null||a.addEventListener("click",()=>{const r=()=>{a.textContent="Copied",this.announce("Buyer link copied.")},l=typeof navigator=="undefined"?null:navigator.clipboard;if(l!=null&&l.writeText){l.writeText(i).then(r,()=>Hl(o));return}Hl(o)})}),this.announce("Your buyer link is ready and is shown once.")}renderLinkRotateDialog(t){var e,i;const s=this.linkById(t.linkId);if(!s||!this.caps.manage){this.closeDialog();return}const n=(e=s.activeSessions)!==null&&e!==void 0?e:0,o=n?`
⚠
- ${n.toLocaleString()} buyer${n===1?"":"s"} got in with the current link
- and still ${n===1?"has":"have"} active access.
`:"";this.renderScrim(`
-
Rotate the ${H(s.label||"buyer")} link?
-
The current link stops opening immediately and cannot be restored. You will get a new
- link to copy — shown once.
- ${o}
-
-
-
Choose one — SeatLayer will not decide this for you.
It stops opening immediately and cannot be restored — there is no undo, and no way to
- bring the same URL back. Seats already bought through it keep their sale.
- ${n?``:""}
-
${H((i=t.error)!==null&&i!==void 0?i:"")}
-
-
-
-
`,o=>{var a;(a=o.querySelector("[data-ch-lk-revoke]"))===null||a===void 0||a.addEventListener("click",()=>{var r,l;const c=(r=(l=o.querySelector("[data-ch-lk-endsessions]"))===null||l===void 0?void 0:l.checked)!==null&&r!==void 0?r:!1;this.revokeLink(t.channelId,s.id,c)})})}async revokeLink(t,e,i){try{const s=await this.host.api.revokeAccessLink(this.host.eventKey,t,e,i);this.closeDialog(),await this.reloadAfterLinkChange(t),this.host.toast(s.endedSessions?`Link revoked. ${s.endedSessions.toLocaleString()} buyer${s.endedSessions===1?"":"s"} lost access.`:"Link revoked. It no longer opens for anyone.","ok")}catch(s){this.showDialogError(Hi(s instanceof he?s:void 0)),s instanceof he||this.host.onError(s)}}applySheetClasses(){const t=this.host.root,e=this.host.isCompact();t.classList.toggle("ch-sheet",e&&this.active);for(const i of["collapsed","medium","full"])t.classList.toggle(`detent-${i}`,e&&this.active&&this.detent===i);this.host.setMapInert(e&&this.active&&this.detent==="full")}cycleDetent(){const t=["collapsed","medium","full"];this.detent=t[(t.indexOf(this.detent)+1)%t.length],this.applySheetClasses()}handleBack(){return this.scrimEl?(this.closeDialog(),!0):this.host.isCompact()&&this.detent==="full"?(this.detent="medium",this.applySheetClasses(),!0):!1}}}));to();var Sm="https://api.seatlayer.io",Hs=80,Cm=16,Zl=4,Ql=[{key:"watch",label:"Watch",tools:[{mode:"view",label:"Monitor",shortcut:"M",title:"Live board — inventory, activity and booking momentum. Read-only."},{mode:"inspect",label:"Inspect",shortcut:"I",title:"Click one seat to read its live status and booking context. Read-only."}]},{key:"manage",label:"Manage",tools:[{mode:"block",label:"Block",shortcut:"B",title:"Take seats off sale for this event, or put them back."},{mode:"sections",label:"Sections",shortcut:"S",title:"Open, close or hide sections for this event, on a schedule or on demand."},{mode:"categories",label:"Categories",shortcut:"G",title:"Move seats to a different price category for this event only."},{mode:"tables",label:"Tables",shortcut:"T",title:"Sell each table per chair or as one whole-table booking."},{mode:"channels",label:"Channels",shortcut:"C",title:"Allocate inventory to sales channels and share their links."}]},{key:"host",label:"Host tools",tools:[{mode:"select",label:"Select",shortcut:"X",title:"Select seats for your own back-office operation. The selection is handed to your app; nothing changes here."},{mode:"filterSections",label:"Filter",shortcut:"L",title:"Filter the map to one section for your own reporting."}]}],Tm=Object.fromEntries(Ql.flatMap(t=>t.tools.map(e=>[e.shortcut.toLowerCase(),e.mode]))),Lm=class{constructor(t){var e,i,s,n,o,a,r,l,c;this.els={},this.renderer=null,this.doc=null,this.inventoryModelVersion=1,this.selectableObjectLabels=new Set,this.lastSelectionLabels=new Set,this.selectionWasValid=null,this.initialSelectionApplied=!1,this.labelToId=new Map,this.labelToSeat=new Map,this.allIds=[],this.gaUnitLabelSet=new Set,this.status=new Map,this.counts={held:0,booked:0,blocked:0},this.modelVersion=0,this.currency="USD",this.authoritativeCurrency=null,this.authoritativeGrossRevenue=0,this.revenueStatus="loading",this.revenueRequest=0,this.controlRoomSnapshot=null,this.serverBaseline=null,this.livePresence=null,this.liveGross=null,this.paintHandle=null,this.trendWindowMinutes=15,this.heatEnabled=!1,this.lastKpiValues=new Map,this.activeKpiDeltas=new Map,this.ws=null,this.reconnectTimer=null,this.attempt=0,this.closed=!1,this.connectionStatus="reconnecting",this.lastMessageAt=null,this.ready=!1,this.feed=[],this.feedTimer=null,this.toastTimer=null,this.liveEventTimer=null,this.kpiCleanupTimer=null,this.followLiveTimer=null,this.followSeatTimer=null,this.releaseAt=null,this.layoutObserver=null,this.tokenExpiresAt=null,this.tokenRefreshTimer=null,this.tokenRefreshInFlight=!1,this.sectionByObject=new Map,this.sectionLabelById=new Map,this.sectionsBase=null,this.filteredSectionLabel=null,this.availabilityRules={},this.effectiveHidden=new Set,this.effectiveClosed=new Set,this.availabilitySaving=!1,this.lastSyncedAt=null,this.blockedQuery="",this.blockedSection="",this.blockedResultLimit=100,this.unblockAllConfirmTimer=null,this.channels=null,this.channelCaps={view:!1,manage:!1},this.categoryCanManage=!1,this.tableCanManage=!1,this.tableBookingSaving=!1,this.channelCapabilityResolution=0,this.channelsLoading=null,this.onFullscreenChange=()=>{var d;this.paintFullscreenButton(),this.updateContainerLayout(),(d=this.renderer)===null||d===void 0||d.forceDraw()},this.onKeyDown=d=>{if(d.metaKey||d.ctrlKey||d.altKey)return;const u=d.target;if(u!=null&&u.matches('input,select,textarea,[contenteditable="true"]'))return;const h=d.key.toLowerCase(),p=Tm[h];if(p){if(!this.toolAvailable(p))return;this.setMode(p)}else if(h==="f")this.toggleFullscreen();else if(h==="escape"){var f;if(!(!((f=this.channels)===null||f===void 0)&&f.handleBack()))return}else return;d.preventDefault()},this.onRailClick=d=>{const u=d.target,h=u==null?void 0:u.closest("[data-section-focus]");if(h!=null&&h.dataset.sectionFocus){this.locateSection(h.dataset.sectionFocus);return}const p=u==null?void 0:u.closest("[data-feed-id]");p!=null&&p.dataset.feedId&&this.locateActivity(p.dataset.feedId)},this.sectionOptions=[],Cl(t.token),this.assertSelectionOptions(t.maxSelectedObjects,t.numberOfPlacesToSelect),this.opts=t,this.key=t.eventKey,this.mode=(e=t.mode)!==null&&e!==void 0?e:"view",this.selectableObjectLabels=new Set((i=t.selectableObjects)!==null&&i!==void 0?i:[]),this.categoryCanManage=new Set((s=t.capabilities)!==null&&s!==void 0?s:[]).has("event:categories:manage"),this.tableCanManage=new Set((n=t.capabilities)!==null&&n!==void 0?n:[]).has("event:tables:manage"),this.keepLive=(o=t.keepLiveWhileHidden)!==null&&o!==void 0?o:!0,this.followLive=(a=t.followLive)!==null&&a!==void 0?a:!1,this.currency=(r=t.currency)!==null&&r!==void 0?r:"USD",this.tokenExpiresAt=(l=t.tokenExpiresAt)!==null&&l!==void 0?l:null,this.api=new eo((c=t.apiBase)!==null&&c!==void 0?c:Sm,t.token),this.organizerAssetUrls=new em(this.key,(d,u)=>this.withAuthRetry(()=>this.api.asset(d,u))),this.host=rm(t.container)}assertSelectionOptions(t,e){const i=s=>s===void 0||Number.isInteger(s)&&s>0;if(!i(t))throw new TypeError("maxSelectedObjects must be a positive integer");if(!i(e))throw new TypeError("numberOfPlacesToSelect must be a positive integer");if(t!==void 0&&e!==void 0&&tthis.api.chart(this.key));this.inventoryModelVersion=o.event.inventoryModelVersion===2?2:1,this.doc=await this.organizerAssetUrls.prepareRendererChart(o.doc),this.authoritativeCurrency=(t=o.event.currency)!==null&&t!==void 0?t:null,this.currency=(e=(i=this.authoritativeCurrency)!==null&&i!==void 0?i:this.opts.currency)!==null&&e!==void 0?e:this.currency,this.buildUnitUniverse(this.doc),this.buildRenderer(),this.buildSectionOptions(),this.settleMode();const[,a]=await Promise.all([this.resnapshot(),this.refreshControlRoom().catch(r=>{var l,c;return(l=(c=this.opts).onError)===null||l===void 0?void 0:l.call(c,r)}),this.refreshAvailability()]);a!=null&&a.activity?this.seedFeed(a.activity):this.api.log(this.key,{limit:24}).then(r=>this.seedFeed(r.entries)).catch(()=>{}),this.connect(),this.startFeedClock(),this.ready=!0,await this.resolveChannelCapabilities(),this.setMode(this.mode),this.applyInitialSelection(),this.scheduleTokenRefresh(),(s=(n=this.opts).onReady)===null||s===void 0||s.call(n)}catch(o){this.fail(o)}return this}setMode(t){var e,i,s,n,o;this.toolAvailable(t)||(t="view"),t==="channels"&&!this.channels&&this.ensureChannels();const a=t!==this.mode,r=this.mode==="channels",l=this.mode==="filterSections";if(this.mode=t,!this.renderer&&this.doc?this.buildRenderer():this.updateRendererInteraction(),a){var c;(c=this.renderer)===null||c===void 0||c.clearSelection(),this.syncSelection()}r&&t!=="channels"&&((e=this.channels)===null||e===void 0||e.leave()),this.paintModeTabs(),this.paintRail(),this.applySectionCanvasTreatment(),l&&t!=="filterSections"&&((i=this.renderer)===null||i===void 0||i.zoomToFit()),t==="channels"&&((s=this.channels)===null||s===void 0||s.enter()),t==="select"&&this.applyInitialSelection(),a&&((n=(o=this.opts).onModeChange)===null||n===void 0||n.call(o,t))}async resolveChannelCapabilities(){var t;const e=++this.channelCapabilityResolution,i=this.opts.capabilities;let s;if(i){const o=new Set(i);s={view:o.has("event:channels:view"),manage:o.has("event:channels:view")&&o.has("event:channels:manage")}}else s={view:!1,manage:!1};if(!s.view&&!i)try{await this.api.channels(this.key),s={view:!0,manage:!1}}catch{s={view:!1,manage:!1}}if(e===this.channelCapabilityResolution){if(this.channelCaps=s,!this.channelCaps.view){var n;(n=this.channels)===null||n===void 0||n.destroy(),this.channels=null,this.mode==="channels"?this.setMode("view"):this.paintModeTabs();return}(t=this.channels)===null||t===void 0||t.setCapabilities(this.channelCaps),this.paintModeTabs()}}ensureChannels(){if(this.channelsLoading)return this.channelsLoading;if(this.channels)return Promise.resolve();const t=(async()=>{try{const s=await Promise.resolve().then(()=>(Xl(),xm));if(this.closed||!this.channelCaps.view||(this.channels||(sm(s.CHANNELS_CSS),this.channels=new s.ChannelsMode(this.buildChannelsHost(),this.channelCaps),this.channels.onInteractionChange=()=>this.updateRendererInteraction()),this.mode!=="channels"))return;this.updateRendererInteraction(),this.paintRail(),this.channels.enter()}catch(s){var e,i;if(this.closed)return;this.channelsLoading=null,this.mode==="channels"&&this.paintRail(),(e=(i=this.opts).onError)===null||e===void 0||e.call(i,s)}})();return this.channelsLoading=t,t}buildChannelsHost(){return{eventKey:this.key,api:this.api,rail:this.els.rail,mapLayer:this.root.querySelector(".slm-map"),root:this.root,seats:()=>[...this.labelToSeat.values()].map(t=>({id:t.id,label:t.label,x:t.x,y:t.y})),statusOf:t=>{var e;return(e=this.status.get(t))!==null&&e!==void 0?e:this.labelToSeat.has(t)?"free":void 0},selectionLabels:()=>this.selectionLabels(),selectByLabels:t=>{this.selectByLabels(t)},clearSelection:()=>this.clearSelection(),selectSection:t=>{this.selectSection(t)},sections:()=>this.sectionOptions,labelsInSection:t=>{var e,i;return(e=(i=this.renderer)===null||i===void 0?void 0:i.getSelectableInSection(t).map(s=>s.label))!==null&&e!==void 0?e:[]},rows:()=>{var t,e;const i=new Map(((t=(e=this.doc)===null||e===void 0?void 0:e.objects)!==null&&t!==void 0?t:[]).map(h=>[h.id,h])),s=new Map;for(const h of this.labelToSeat.values()){var n,o,a,r,l,c,d,u;const p=i.get(h.rowId);if(!p||p.type!=="row"&&p.type!=="table")continue;const f=(n=h.logicalRowId)!==null&&n!==void 0?n:h.rowId,v=(o=this.sectionByObject.get(h.rowId))!==null&&o!==void 0?o:ct,m=(a=s.get(f))!==null&&a!==void 0?a:{id:f,label:p.type==="row"?(r=(l=(c=p.segmentedRow)===null||c===void 0?void 0:c.displayLabel)!==null&&l!==void 0?l:p.displayLabel)!==null&&r!==void 0?r:p.label:(d=p.displayLabel)!==null&&d!==void 0?d:p.label,sectionId:v,sectionLabel:(u=this.sectionLabelById.get(v))!==null&&u!==void 0?u:"Other seats",labels:[]};m.labels.push(h.label),s.set(f,m)}return[...s.values()].sort((h,p)=>h.sectionLabel.localeCompare(p.sectionLabel,void 0,{numeric:!0,sensitivity:"base"})||h.label.localeCompare(p.label,void 0,{numeric:!0,sensitivity:"base"}))},categories:()=>{var t,e;return((t=(e=this.doc)===null||e===void 0?void 0:e.categories)!==null&&t!==void 0?t:[]).map(i=>{var s,n;return{key:i.key,label:(s=i.label)!==null&&s!==void 0?s:i.key,color:i.color,price:i.price,tiers:(n=i.tiers)===null||n===void 0?void 0:n.map(o=>({id:o.id,name:o.name,price:o.price}))}})},labelsInCategory:t=>[...this.labelToSeat.entries()].filter(([,e])=>e.categoryKey===t).map(([e])=>e),sectionOfLabel:t=>{var e,i;const s=this.labelToSeat.get(t);if(!s)return null;const n=(e=this.sectionByObject.get(s.rowId))!==null&&e!==void 0?e:ct;return{id:n,label:(i=this.sectionLabelById.get(n))!==null&&i!==void 0?i:"Other seats"}},worldToScreen:t=>{var e,i;return(e=(i=this.renderer)===null||i===void 0?void 0:i.worldToScreen(t))!==null&&e!==void 0?e:null},seatPixelSize:()=>this.seatPixelSize(),isSeatDetail:()=>{var t,e;return((t=this.renderer)===null||t===void 0||(e=t.getRung)===null||e===void 0?void 0:e.call(t))==="seats"},showSectionOverview:()=>{var t,e,i;(t=this.renderer)===null||t===void 0||t.clearSectionFocus(),(e=this.renderer)===null||e===void 0||(i=e.setRung)===null||i===void 0||i.call(e,"sections")},focusSection:t=>{var e;return(e=this.renderer)===null||e===void 0?void 0:e.focusSection(t)},isCompact:()=>{var t;return!!(!((t=this.root)===null||t===void 0)&&t.classList.contains("compact"))},setMapInert:t=>{this.mapHost.toggleAttribute("inert",t),this.mapHost.setAttribute("aria-hidden",String(t))},toast:(t,e)=>this.toast(t,e),onError:t=>{var e,i;return(e=(i=this.opts).onError)===null||e===void 0?void 0:e.call(i,t)}}}seatPixelSize(){var t,e,i,s;const n=(t=this.renderer)===null||t===void 0||(e=t.getVisibleWorldRect)===null||e===void 0?void 0:e.call(t),o=(i=(s=this.mapHost)===null||s===void 0?void 0:s.clientWidth)!==null&&i!==void 0?i:0;return!(n!=null&&n.width)||!o?6:Math.max(3,o/n.width*18)}setHeatOverlay(t){this.heatEnabled=t,this.applyHeatOverlay(),this.paintHeatButton()}setFollowLive(t){var e,i;const s=this.followLive!==t;this.followLive=t,t||(this.followLiveTimer&&clearTimeout(this.followLiveTimer),this.followSeatTimer&&clearTimeout(this.followSeatTimer),this.followLiveTimer=null,this.followSeatTimer=null),this.paintFollowLiveButton(),s&&((e=(i=this.opts).onFollowLiveChange)===null||e===void 0||e.call(i,t))}setKeepLiveWhileHidden(t){this.keepLive=t!=null?t:!0,this.opts.keepLiveWhileHidden=t}setCurrency(t){this.opts.currency=t,!this.authoritativeCurrency&&(this.currency=t!=null?t:"USD",this.ready&&this.recomputeTallies())}setTheme(t){if(this.opts.theme=t,!!this.root)for(const[e,i]of Object.entries(Tl(t)))this.root.style.setProperty(e,i)}setCapabilities(t){this.opts.capabilities=t,this.categoryCanManage=new Set(t!=null?t:[]).has("event:categories:manage"),this.tableCanManage=new Set(t!=null?t:[]).has("event:tables:manage"),!this.categoryCanManage&&this.mode==="categories"||!this.tableCanManage&&this.mode==="tables"?this.setMode("view"):this.paintModeTabs(),this.ready&&this.resolveChannelCapabilities()}setTokenRefresh(t){this.opts.onTokenRefresh=t,this.scheduleTokenRefresh()}setTrendWindow(t){const e=Number.isFinite(t)?Math.floor(t):15;return this.trendWindowMinutes=Math.max(5,Math.min(60,e)),this.paintTrendWindow(),this.refreshControlRoom()}async enterFullscreen(){var t;!(!((t=this.root)===null||t===void 0)&&t.requestFullscreen)||this.isFullscreen()||(await this.root.requestFullscreen(),this.root.focus({preventScroll:!0}))}async exitFullscreen(){typeof document=="undefined"||!this.isFullscreen()||await document.exitFullscreen()}isFullscreen(){return typeof document!="undefined"&&document.fullscreenElement===this.root}toggleFullscreen(){(this.isFullscreen()?this.exitFullscreen():this.enterFullscreen()).catch(t=>{var e,i;return(e=(i=this.opts).onError)===null||e===void 0?void 0:e.call(i,t)})}setToken(t,e){Cl(t),this.api.setToken(t),this.opts.token=t,this.opts.tokenExpiresAt=e,this.tokenExpiresAt=e!=null?e:null,this.scheduleTokenRefresh(),this.ready&&this.resolveChannelCapabilities()}scheduleTokenRefresh(){this.tokenRefreshTimer&&clearTimeout(this.tokenRefreshTimer),this.tokenRefreshTimer=null;const t=this.opts.onTokenRefresh,e=this.tokenExpiresAt;if(this.closed||!t||!e||!Number.isFinite(e))return;const i=e-Date.now(),s=Math.min(12e4,Math.max(3e4,i*.2)),n=Math.max(0,i-s);this.tokenRefreshTimer=setTimeout(()=>{this.tokenRefreshTimer=null,this.rotateToken()},n)}async rotateToken(){if(!(this.closed||this.tokenRefreshInFlight||!this.opts.onTokenRefresh)){this.tokenRefreshInFlight=!0;try{const i=await this.opts.onTokenRefresh();if(!(i!=null&&i.token)||!Number.isFinite(i.expiresAt))throw new Error("invalid_token_refresh_result");this.setToken(i.token,i.expiresAt)}catch(i){var t,e;(t=(e=this.opts).onError)===null||t===void 0||t.call(e,i),this.closed||(this.tokenRefreshTimer=setTimeout(()=>{this.tokenRefreshTimer=null,this.rotateToken()},3e4))}finally{this.tokenRefreshInFlight=!1}}}async block(t,e={}){var i,s;const n=(t!=null?t:this.selectionLabels()).filter(l=>this.status.get(l)==="free");if(!n.length)return;const o=(i=(s=e.releaseAt)!==null&&s!==void 0?s:this.releaseAt)!==null&&i!==void 0?i:void 0;this.setSeatsLocal(n,"blocked");try{await this.api.block(this.key,n,{...e,releaseAt:o}),this.clearSelection(),this.done("block",n,o?`Blocked ${n.length} — auto-release ${new Date(o).toLocaleString()}.`:`Blocked ${n.length} seat${n.length===1?"":"s"}.`)}catch(l){var a,r;this.setSeatsLocal(n,"free"),this.toastErr(l instanceof he&&l.status===409?"Some seats were just taken. Try again.":"Couldn't block those seats."),(a=(r=this.opts).onError)===null||a===void 0||a.call(r,l)}}async unblock(t){const e=(t!=null?t:this.selectionLabels()).filter(n=>this.status.get(n)==="blocked");if(e.length){this.setSeatsLocal(e,"free");try{await this.api.unblock(this.key,e),this.clearSelection(),this.done("unblock",e,`Unblocked ${e.length} seat${e.length===1?"":"s"}.`)}catch(n){var i,s;this.setSeatsLocal(e,"blocked"),this.toastErr("Couldn't unblock those seats."),(i=(s=this.opts).onError)===null||i===void 0||i.call(s,n)}}}async unblockAll(){const t=[...this.status.entries()].filter(([,s])=>s==="blocked").map(([s])=>s);if(t.length){this.setSeatsLocal(t,"free");try{const s=await this.api.unblockAll(this.key);this.clearSelection(),this.done("unblockAll",t,`Unblocked ${s.freed} seat${s.freed===1?"":"s"}.`)}catch(s){var e,i;await this.resnapshot(),this.toastErr("Couldn't mark everything for sale."),(e=(i=this.opts).onError)===null||e===void 0||e.call(i,s)}}}async cancelBooking(t,e){const i=t.filter(o=>this.status.get(o)==="booked");if(!(!i.length||!e)){this.setSeatsLocal(i,"free");try{await this.api.unbook(this.key,i,e),this.clearSelection(),this.done("cancelBooking",i,`Released ${i.length} booked unit${i.length===1?"":"s"}.`)}catch(o){var s,n;this.setSeatsLocal(i,"booked"),this.toastErr("Couldn't release that booked inventory. Check the booking reference."),(s=(n=this.opts).onError)===null||s===void 0||s.call(n,o)}}}async setCategory(t,e){var i;const s=(i=this.doc)===null||i===void 0?void 0:i.categories.find(d=>d.key===t),n=[...new Set(e!=null?e:this.selectionLabels())].filter(d=>this.labelToSeat.has(d));if(!(!s||!n.length))try{var o,a,r;const d=await this.withAuthRetry(()=>this.api.setCategory(this.key,n,t)),u={};for(const h of d.labels){const p=this.labelToSeat.get(h),f=this.labelToId.get(h);p&&(p.categoryKey=t),f&&(u[f]=t)}(o=this.renderer)===null||o===void 0||(a=o.setSeatCategories)===null||a===void 0||a.call(o,u),this.clearSelection(),this.done("setCategory",d.labels,`Assigned ${d.labels.length.toLocaleString()} object${d.labels.length===1?"":"s"} to ${(r=s.label)!==null&&r!==void 0?r:s.key}.`)}catch(d){var l,c;this.toastErr("Couldn't update those event categories."),(l=(c=this.opts).onError)===null||l===void 0||l.call(c,d)}}async setTableBooking(t,e,i={}){const s=[...new Set(t)].filter(Boolean);if(!(!s.length||this.tableBookingSaving)){if(this.inventoryModelVersion!==2){this.toastErr("Table booking controls require inventory model 2 for this event.");return}this.tableBookingSaving=!0,this.mode==="tables"&&this.renderTablesRail();try{const a=await this.withAuthRetry(()=>this.api.setTableBooking(this.key,s,e,i));await this.reloadEventChart(),this.done("setTableBooking",a.tableIds,`Updated ${a.tableIds.length.toLocaleString()} table${a.tableIds.length===1?"":"s"} to ${e==="individual"?"per-chair":e==="whole"?"whole-table":"flexible-group"} booking.`)}catch(a){var n,o;const r=a instanceof he&&a.code==="table_inventory_in_use";this.toastErr(r?"Release held, booked, or blocked table inventory before changing its booking mode.":"Couldn't update table booking. No table mode was changed."),(n=(o=this.opts).onError)===null||n===void 0||n.call(o,a)}finally{this.tableBookingSaving=!1,this.mode==="tables"&&this.renderTablesRail()}}}async reloadEventChart(){var t;const e=await this.withAuthRetry(()=>this.api.chart(this.key));this.inventoryModelVersion=e.event.inventoryModelVersion===2?2:1;const i=await this.organizerAssetUrls.prepareRendererChart(e.doc);(t=this.renderer)===null||t===void 0||t.destroy(),this.renderer=null,this.doc=i,this.labelToId.clear(),this.labelToSeat.clear(),this.allIds=[],this.gaUnitLabelSet.clear(),this.status.clear(),this.counts={held:0,booked:0,blocked:0},this.serverBaseline=null,this.lastSelectionLabels.clear(),this.buildUnitUniverse(i),this.buildRenderer(),this.buildSectionOptions(),this.settleMode(),await Promise.all([this.resnapshot(),this.refreshAvailability()]),this.paintRail()}selectAll(){var t,e;if(this.mode==="select")return this.selectByLabels([...this.labelToSeat.values()].filter(s=>this.canSelectObject(s)).map(s=>s.label));const i=(t=(e=this.renderer)===null||e===void 0?void 0:e.selectAllSelectable())!==null&&t!==void 0?t:[];return this.syncSelection(),i}selectSection(t){if(!this.renderer)return[];const e=this.renderer.getSelectableInSection(t);return this.renderer.selectByLabels(e.map(i=>i.label)),this.syncSelection(),this.renderer.getSelection()}setFilteredSection(t){var e,i;const s=t.trim(),n=this.filterableSections().filter(r=>r.label===s);if(!n.length)throw new Error(`Unknown event section: ${t}`);const o=s!==this.filteredSectionLabel;this.filteredSectionLabel=s,this.mode==="filterSections"&&(this.applyFilteredSectionCanvas(n),this.renderFilterSectionsRail());const a=n.map(({id:r,label:l,seatCount:c,zone:d})=>({id:r,label:l,seatCount:c,...d?{zone:d}:{}}));return o&&((e=(i=this.opts).onFilteredSectionChange)===null||e===void 0||e.call(i,a)),a}clearFilteredSection(){var t,e,i,s,n;const o=this.filteredSectionLabel!==null;this.filteredSectionLabel=null,(t=this.renderer)===null||t===void 0||t.setDimmedSections(null),(e=this.renderer)===null||e===void 0||e.clearSectionFocus(),(i=this.renderer)===null||i===void 0||i.zoomToFit(),this.mode==="filterSections"&&this.renderFilterSectionsRail(),o&&((s=(n=this.opts).onFilteredSectionChange)===null||s===void 0||s.call(n,[]))}getFilteredSections(){return this.filteredSectionLabel?this.filterableSections().filter(t=>t.label===this.filteredSectionLabel).map(({id:t,label:e,seatCount:i,zone:s})=>({id:t,label:e,seatCount:i,...s?{zone:s}:{}})):[]}selectByLabels(t){var e;let i=t;if(this.mode==="select"){var s,n;const o=new Set(this.selectionLabels()),a=this.selectionCap(),r=[...new Set(t)].filter(c=>!o.has(c)).map(c=>this.labelToSeat.get(c)).filter(c=>!!c&&this.canSelectObject(c)),l=Math.max(0,a-o.size);r.length>l&&((s=(n=this.opts).onSelectionLimit)===null||s===void 0||s.call(n,a)),i=r.slice(0,l).map(c=>c.label)}return(e=this.renderer)===null||e===void 0||e.selectByLabels(i),this.syncSelection(),this.getSelection()}selectObjects(t){return this.selectByLabels(t)}deselectObjects(t){var e;const i=t.map(s=>this.labelToId.get(s)).filter(s=>!!s);return(e=this.renderer)===null||e===void 0||e.deselect(i),this.syncSelection(),this.getSelection()}selectCategories(t){const e=new Set(t);return this.selectByLabels([...this.labelToSeat.values()].filter(i=>e.has(i.categoryKey)).map(i=>i.label))}deselectCategories(t){const e=new Set(t);return this.deselectObjects(this.getSelection().filter(i=>e.has(i.categoryKey)).map(i=>i.label))}setSelectableObjects(t){this.opts.selectableObjects=[...t],this.selectableObjectLabels=new Set(t),this.reconcileSelectPolicy()}setUnavailableObjectsSelectable(t){this.opts.unavailableObjectsSelectable=t,this.reconcileSelectPolicy()}setObjectSelectable(t){this.opts.isObjectSelectable=t,this.reconcileSelectPolicy()}setMaxSelectedObjects(t){this.assertSelectionOptions(t,this.opts.numberOfPlacesToSelect),this.opts.maxSelectedObjects=t,this.trimSelectionToCap(),this.updateRendererInteraction(),this.syncSelection()}setNumberOfPlacesToSelect(t){this.assertSelectionOptions(this.opts.maxSelectedObjects,t),this.opts.numberOfPlacesToSelect=t,this.selectionWasValid=null,this.trimSelectionToCap(),this.updateRendererInteraction(),this.syncSelection()}getSelectionValidity(){const t=this.opts.numberOfPlacesToSelect;if(t===void 0)return null;const e=this.getSelection(),i=e.length;return{isValid:i===t,count:i,required:t,remaining:Math.max(0,t-i),objects:e}}clearSelection(){var t;(t=this.renderer)===null||t===void 0||t.clearSelection(),this.syncSelection()}getSelection(){var t,e;return(t=(e=this.renderer)===null||e===void 0?void 0:e.getSelection())!==null&&t!==void 0?t:[]}getReport(){return this.api.report(this.key).then(t=>(this.applyReportRevenue(t),t))}getControlRoomSnapshot(t=this.trendWindowMinutes){return this.setTrendWindow(t)}getConnection(){return{status:this.connectionStatus,lastMessageAt:this.lastMessageAt}}getLog(t={}){return this.api.log(this.key,t)}async setHoldTtl(t){try{await this.api.setHoldTtl(this.key,t),this.done("setHoldTtl",[],t?`Hold window set to ${Math.round(t/6e4)} min.`:"Hold window reset.")}catch(s){var e,i;this.toastErr("Couldn't update the hold window."),(e=(i=this.opts).onError)===null||e===void 0||e.call(i,s)}}zoomToFit(){var t,e;if(this.mode==="filterSections"&&this.filteredSectionLabel){this.clearFilteredSection();return}(t=this.renderer)===null||t===void 0||t.clearSectionFocus(),(e=this.renderer)===null||e===void 0||e.zoomToFit()}destroy(){var t,e,i,s,n;if(this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.feedTimer&&clearInterval(this.feedTimer),this.toastTimer&&clearTimeout(this.toastTimer),this.liveEventTimer&&clearTimeout(this.liveEventTimer),this.kpiCleanupTimer&&clearTimeout(this.kpiCleanupTimer),this.followLiveTimer&&clearTimeout(this.followLiveTimer),this.followSeatTimer&&clearTimeout(this.followSeatTimer),this.unblockAllConfirmTimer&&clearTimeout(this.unblockAllConfirmTimer),this.paintHandle!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.paintHandle),this.paintHandle=null,(t=this.channels)===null||t===void 0||t.destroy(),this.channels=null,this.channelsLoading=null,this.tokenRefreshTimer&&clearTimeout(this.tokenRefreshTimer),(e=this.layoutObserver)===null||e===void 0||e.disconnect(),this.layoutObserver=null,(i=this.root)===null||i===void 0||i.removeEventListener("keydown",this.onKeyDown),(s=this.els.rail)===null||s===void 0||s.removeEventListener("click",this.onRailClick),typeof document!="undefined"&&document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.ws){try{this.ws.close()}catch{}this.ws=null}(n=this.renderer)===null||n===void 0||n.destroy(),this.renderer=null,this.organizerAssetUrls.dispose(),this.root&&this.root.parentNode===this.host&&this.host.removeChild(this.root)}buildRenderer(){if(!this.doc)return;const t=this.isBulkSelectMode();this.renderer=new Pn(this.mapHost,{manageMode:!0,marqueeSelect:t,maxSelection:this.selectionCap(),selectableStatuses:this.selectableStatuses(),currency:this.currency,onSelect:e=>this.handleSeatSelect(e),onDeselect:()=>this.syncSelection(),onSelectionLimit:e=>{var i,s;return(i=(s=this.opts).onSelectionLimit)===null||i===void 0?void 0:i.call(s,e)},onMarquee:()=>this.syncSelection(),onSectionTap:e=>{var i,s;if(this.mode==="filterSections"){const n=this.filterableSections().find(o=>o.id===e);n&&this.setFilteredSection(n.label);return}(i=this.renderer)===null||i===void 0||i.focusSection(e),(s=this.channels)===null||s===void 0||s.handleSectionFocus(e)},onViewChange:()=>{var e;this.updateZoomHint(),(e=this.channels)===null||e===void 0||e.handleViewChange()}}),this.renderer.setChart(this.doc),this.repaintAll(),this.applyHeatOverlay(),this.updateZoomHint()}isBulkSelectMode(){var t;return this.mode==="block"||this.mode==="categories"||this.mode==="channels"&&((t=this.channels)===null||t===void 0?void 0:t.usesMarqueeSelection())===!0}selectableStatuses(){var t;return this.mode==="block"?["free","not_for_sale"]:this.mode==="select"||this.mode==="categories"||this.mode==="inspect"||this.isBulkSelectMode()||this.mode==="channels"&&((t=this.channels)===null||t===void 0?void 0:t.canSelect())===!0?["free","held","booked","not_for_sale"]:[]}updateRendererInteraction(){var t;const e=this.isBulkSelectMode();(t=this.renderer)===null||t===void 0||t.setManageInteraction({manageMode:!0,marqueeSelect:e,maxSelection:this.selectionCap(),selectableStatuses:this.selectableStatuses()}),this.updateZoomHint()}handleSeatSelect(t){if(this.mode==="select"&&!this.canSelectObject(t)){var e;(e=this.renderer)===null||e===void 0||e.deselect([t.id]),this.syncSelection();return}if(this.mode==="inspect"){var i;const s=this.getSelection().filter(n=>n.id!==t.id).map(n=>n.id);s.length&&((i=this.renderer)===null||i===void 0||i.deselect(s))}this.syncSelection()}buildUnitUniverse(t){for(const e of Ye(t))this.labelToId.set(e.label,e.id),this.labelToSeat.set(e.label,e),this.allIds.push(e.id);for(const e of Qi(t))for(const i of Zi(e))this.labelToId.has(i)||this.gaUnitLabelSet.add(i)}unitTotal(){return this.allIds.length+this.gaUnitLabelSet.size}knownLabels(){return[...this.labelToId.keys(),...this.gaUnitLabelSet]}repaintAll(){const t=this.renderer;if(!t)return;this.allIds.length&&t.setStatus(this.allIds,"free");const e={free:[],held:[],booked:[],not_for_sale:[]};for(const[i,s]of this.status.entries()){const n=this.labelToId.get(i);n&&e[io(s)].push(n)}["held","booked","not_for_sale"].forEach(i=>{e[i].length&&t.setStatus(e[i],i)})}async connect(){if(this.closed)return;let t;try{if(t=(await this.withAuthRetry(()=>this.api.subscribeTicket(this.key))).protocols,!t.length)throw new Error("manage_subscribe_ticket_missing")}catch(a){var e,i;this.setLive(!1),(e=(i=this.opts).onError)===null||e===void 0||e.call(i,a),this.scheduleReconnect();return}if(this.closed)return;let s;try{s=new WebSocket(this.api.socketUrl(this.key),t)}catch(a){var n,o;(n=(o=this.opts).onError)===null||n===void 0||n.call(o,a),this.scheduleReconnect();return}this.ws=s,s.onopen=()=>{this.attempt=0,this.setLive(!0),this.resnapshot().then(()=>this.refreshControlRoom()).catch(a=>{var r,l;return(r=(l=this.opts).onError)===null||r===void 0?void 0:r.call(l,a)}),this.refreshAvailability()},s.onmessage=a=>this.onMessage(a),s.onclose=()=>{this.ws===s&&(this.ws=null),this.setLive(!1),this.scheduleReconnect()},s.onerror=()=>{try{s.close()}catch{}}}scheduleReconnect(){if(this.closed||this.reconnectTimer)return;const t=Math.min(1e3*2**Math.min(this.attempt++,5),15e3);this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}onMessage(t){let e;try{e=JSON.parse(typeof t.data=="string"?t.data:"")}catch{return}if(!e||typeof e!="object")return;this.lastMessageAt=Date.now();const i=e;if((Array.isArray(i.hidden)||Array.isArray(i.closed))&&this.updateEffectiveAvailability(i.hidden,i.closed),i.type==="presence"){if(typeof i.shoppingSessions=="number"&&typeof i.activeHolds=="number"){if(this.livePresence={at:Date.now(),value:{shoppingSessions:i.shoppingSessions,activeHolds:i.activeHolds}},this.controlRoomSnapshot){var s,n;this.controlRoomSnapshot={...this.controlRoomSnapshot,presence:this.livePresence.value},(s=(n=this.opts).onControlRoom)===null||s===void 0||s.call(n,this.controlRoomSnapshot)}this.lastSyncedAt=Date.now(),this.recomputeTallies(),this.paintMonitorInsights()}return}if(i.type!=="hidden"){if(i.seats&&typeof i.seats=="object")this.applySnapshot(i.seats,typeof i.default=="string"?i.default:void 0);else if(Array.isArray(i.changes)){var o,a;const d=[],u=new Map;for(const p of i.changes){var r,l;const f=["free","held","booked","blocked"].includes(p.status)?p.status:"free",v=(r=this.status.get(p.label))!==null&&r!==void 0?r:"free";if(v===f)continue;this.setStatusLabel(p.label,f,v);const m=this.labelToId.get(p.label);if(m){var c;(c=this.renderer)===null||c===void 0||c.setStatus([m],io(f)),d.push(m)}const g=this.verbFor(v,f),b=`${g}:${f}`,y=(l=u.get(b))!==null&&l!==void 0?l:{labels:[],verb:g,status:f};y.labels.push(p.label),u.set(b,y)}for(const p of u.values()){const f=this.pushActivity(p.labels,p.verb,p.status);f&&this.paintSpatialActivity(f)}d.length&&(this.lastSyncedAt=Date.now(),this.afterPaint());const h=typeof((o=i.bookedValue)===null||o===void 0?void 0:o.gross)=="number"?i.bookedValue.gross:(a=i.revenue)===null||a===void 0?void 0:a.gross;typeof h=="number"&&Number.isFinite(h)&&this.applyLiveGross(h),this.recomputeTallies()}}}applyLiveGross(t){if(this.liveGross={at:Date.now(),value:t},this.authoritativeGrossRevenue=t,this.revenueStatus="current",this.controlRoomSnapshot){var e,i,s;const n={...(e=this.controlRoomSnapshot.bookedValue)!==null&&e!==void 0?e:this.controlRoomSnapshot.revenue,gross:t};this.controlRoomSnapshot={...this.controlRoomSnapshot,bookedValue:n,revenue:n},(i=(s=this.opts).onControlRoom)===null||i===void 0||i.call(s,this.controlRoomSnapshot)}}setStatusLabel(t,e,i=(s=>(s=this.status.get(t))!==null&&s!==void 0?s:"free")()){this.status.set(t,e),i!==e&&(i!=="free"&&(this.counts[i]-=1),e!=="free"&&(this.counts[e]+=1))}async resnapshot(){try{const t=await this.api.objects(this.key);this.applySnapshot(t.seats),this.updateEffectiveAvailability(t.hidden,t.closed),this.lastMessageAt=Date.now()}catch{}}applySnapshot(t,e){const i=n=>["free","held","booked","blocked"].includes(n)?n:"free",s=new Map;if(e!==void 0){const n=i(e);for(const o of this.knownLabels())s.set(o,n)}for(const[n,o]of Object.entries(t))s.set(n,i(o));this.status=s,this.modelVersion+=1,this.recountAll(),this.lastSyncedAt=Date.now(),this.repaintAll(),this.afterPaint(),this.recomputeTallies()}recountAll(){const t={held:0,booked:0,blocked:0};for(const e of this.status.values())e!=="free"&&(t[e]+=1);this.counts=t}setSeatsLocal(t,e){var i;const s=[];for(const n of t){this.setStatusLabel(n,e);const o=this.labelToId.get(n);o&&s.push(o)}s.length&&((i=this.renderer)===null||i===void 0||i.setStatus(s,io(e))),this.afterPaint(),this.recomputeTallies()}afterPaint(){if(this.keepLive&&typeof document!="undefined"&&document.hidden){var t;(t=this.renderer)===null||t===void 0||t.forceDraw()}}activityColor(t){return t==="held"?"#f4b740":t==="booked"?"#22a06b":t==="blocked"?"#8b94ac":"#6e7bff"}sectionsForLabels(t){const e=new Set;for(const s of t){const n=this.labelToSeat.get(s);if(!n)continue;const o=this.sectionByObject.get(n.rowId);o&&o!=="__ungrouped__"&&e.add(o)}const i=[...e];return{ids:i,labels:i.map(s=>{var n;return(n=this.sectionLabelById.get(s))!==null&&n!==void 0?n:s})}}pulseSeatLabels(t,e){const i=this.activityColor(e);for(const n of t.slice(0,Cm)){var s;const o=this.labelToId.get(n);o&&((s=this.renderer)===null||s===void 0||s.flashSeat(o,i))}}paintSpatialActivity(t){var e,i,s;const n=(e=t.sectionIds)!==null&&e!==void 0?e:this.sectionsForLabels(t.labels).ids,o=(i=(s=this.renderer)===null||s===void 0?void 0:s.getFocusedSection())!==null&&i!==void 0?i:null,a=this.followLive&&n.length===1&&(t.status==="held"||t.status==="booked");if(a&&o===n[0]){this.pulseSeatLabels(t.labels,t.status);return}if(a){this.followLiveTimer&&clearTimeout(this.followLiveTimer),this.followSeatTimer&&clearTimeout(this.followSeatTimer),this.followLiveTimer=setTimeout(()=>{var l;this.followLiveTimer=null,(l=this.renderer)===null||l===void 0||l.focusSection(n[0]),this.followSeatTimer=setTimeout(()=>{this.followSeatTimer=null,this.pulseSeatLabels(t.labels,t.status)},520)},220);return}if(!o&&n.length){const l=this.activityColor(t.status);for(const c of n.slice(0,Zl)){var r;(r=this.renderer)===null||r===void 0||r.flashSection(c,l)}return}(!n.length||o&&n.includes(o))&&this.pulseSeatLabels(t.labels,t.status)}locateSection(t){var e;(e=this.renderer)===null||e===void 0||e.focusSection(t)}locateActivity(t){var e;const i=this.feed.find(n=>n.id===t);if(!i)return;const s=(e=i.sectionIds)!==null&&e!==void 0?e:this.sectionsForLabels(i.labels).ids;if(this.followSeatTimer&&clearTimeout(this.followSeatTimer),s.length===1){this.locateSection(s[0]),this.followSeatTimer=setTimeout(()=>{this.followSeatTimer=null,this.pulseSeatLabels(i.labels,i.status)},520);return}this.zoomToFit(),this.followSeatTimer=setTimeout(()=>{if(this.followSeatTimer=null,s.length){const o=this.activityColor(i.status);for(const a of s.slice(0,Zl)){var n;(n=this.renderer)===null||n===void 0||n.flashSection(a,o)}}else this.pulseSeatLabels(i.labels,i.status)},280)}showLiveEvent(t){var e;const i=this.els.liveevent;if(!i)return;const s=(e=t.sectionLabels)!==null&&e!==void 0?e:[],n=s.length===1?s[0]:s.length>1?`${s.length} sections`:t.label,o=t.count===1?"seat":"seats";i.innerHTML=`
- ${Z(n)} · ${t.count.toLocaleString()} ${o} ${Z(t.verb)}
- Live`,i.classList.add("on"),this.liveEventTimer&&clearTimeout(this.liveEventTimer),this.liveEventTimer=setTimeout(()=>{this.liveEventTimer=null,i.classList.remove("on"),i.innerHTML=""},2800)}applyReportRevenue(t){this.authoritativeGrossRevenue=t.report.byCategory.reduce((e,i)=>{const s=Number.isFinite(i.bookedValue)?i.bookedValue:i.bookedRevenue;return e+(Number.isFinite(s)?s:0)},0),this.revenueStatus="current",this.recomputeTallies()}async refreshControlRoom(){const t=++this.revenueRequest,e=Date.now();try{var i,s,n;const r=await this.api.controlRoom(this.key,this.trendWindowMinutes),l=(i=(s=r.bookedValue)!==null&&s!==void 0?s:r.revenue)!==null&&i!==void 0?i:{gross:0,bySection:[]},c=((n=l.bySection)!==null&&n!==void 0?n:[]).map(h=>{const p=Number.isFinite(h.bookedValue)?h.bookedValue:h.bookedRevenue;return{...h,bookedValue:p!=null?p:0,bookedRevenue:p!=null?p:0}}),d={...l,bySection:c};let u={...r,bookedValue:d,revenue:d};if(t===this.revenueRequest){var o,a;if(this.livePresence&&this.livePresence.at>=e?u={...u,presence:this.livePresence.value}:this.livePresence=null,this.liveGross&&this.liveGross.at>=e){const h={...u.bookedValue,gross:this.liveGross.value};u={...u,bookedValue:h,revenue:h}}else this.liveGross=null;this.controlRoomSnapshot=u,this.rebaseServerTotals(u),this.lastSyncedAt=Date.now(),this.authoritativeGrossRevenue=u.bookedValue.gross,this.authoritativeCurrency=u.currency,this.currency=u.currency,this.revenueStatus="current",this.recomputeTallies(),this.applyHeatOverlay(),this.paintMonitorInsights(),(o=(a=this.opts).onControlRoom)===null||o===void 0||o.call(a,u)}return u}catch(r){throw t===this.revenueRequest&&(this.revenueStatus="stale",this.recomputeTallies()),r}}rebaseServerTotals(t){const e=t.totals;if(!e||["free","held","booked","blocked"].some(i=>!Number.isFinite(e[i]))){this.serverBaseline=null;return}this.serverBaseline={model:this.modelVersion,server:{free:e.free,held:e.held,booked:e.booked,blocked:e.blocked},client:this.clientTallies()}}clientTallies(){const{held:t,booked:e,blocked:i}=this.counts;return{held:t,booked:e,blocked:i,free:Math.max(0,this.unitTotal()-t-e-i)}}buildTallies(){var t,e;const i=this.clientTallies(),s=((t=this.serverBaseline)===null||t===void 0?void 0:t.model)===this.modelVersion?this.serverBaseline:null,n=l=>s?Math.max(0,s.server[l]+(i[l]-s.client[l])):i[l],o=(e=this.controlRoomSnapshot)===null||e===void 0||(e=e.event)===null||e===void 0?void 0:e.seatTotal,a={free:n("free"),held:n("held"),booked:n("booked"),blocked:n("blocked"),total:Number.isFinite(o)?o:this.unitTotal(),capacityPct:0,sellThroughPct:0,bookedValue:this.authoritativeGrossRevenue,grossRevenue:this.authoritativeGrossRevenue,bookedValueStatus:this.revenueStatus,revenueStatus:this.revenueStatus,currency:this.currency};a.capacityPct=a.total?Math.round(a.booked/a.total*100):0;const r=a.total-a.blocked;return a.sellThroughPct=r>0?Math.round(a.booked/r*100):0,a}recomputeTallies(){if(!this.closed){if(typeof requestAnimationFrame!="function"){this.flushTallies();return}this.paintHandle===null&&(this.paintHandle=requestAnimationFrame(()=>{this.paintHandle=null,this.flushTallies()}))}}flushTallies(){var t,e,i;if(this.closed)return;const s=this.buildTallies();this.paintKpis(s),this.mode==="view"?(this.paintLegend(s),this.paintMonitorInsights()):this.mode==="inspect"?this.renderInspectRail(this.getSelection()):this.mode==="block"?this.paintSelBar(this.getSelection()):this.mode==="channels"&&((t=this.channels)===null||t===void 0||t.handleSelectionChange()),(e=(i=this.opts).onTallies)===null||e===void 0||e.call(i,s)}verbFor(t,e){return e==="held"?"held":e==="booked"?"booked":e==="blocked"?"blocked":e==="free"?t==="blocked"?"unblocked":t==="booked"?"cancelled":"released":e}pushActivity(t,e,i,s=Date.now()){var n,o;const a=t[0];if(!a)return null;const r=this.sectionsForLabels(t),l={id:`${a}:${s}:${Math.random().toString(36).slice(2,6)}`,at:s,label:a,labels:[...t],count:t.length,verb:e,status:i,sectionIds:r.ids,sectionLabels:r.labels};return this.feed.unshift(l),this.feed.length>Hs&&(this.feed.length=Hs),this.mode==="view"&&this.paintFeed(),this.showLiveEvent(l),(n=(o=this.opts).onActivity)===null||n===void 0||n.call(o,l),l}seedFeed(t){const e={hold:"held",book:"booked",release:"released",expire:"expired",block:"blocked",unblock:"unblocked",unbook:"cancelled"},i={hold:"held",book:"booked",release:"free",expire:"free",block:"blocked",unblock:"free",unbook:"free"};for(const r of t){var s,n,o,a;const l=r.labels[0];if(!l)continue;const c=this.sectionsForLabels(r.labels),d={id:`log:${r.id}`,at:r.at,label:l,labels:[...r.labels],count:r.labels.length,verb:(s=e[r.action])!==null&&s!==void 0?s:r.action,status:(n=i[r.action])!==null&&n!==void 0?n:"free",sectionIds:c.ids,sectionLabels:c.labels};this.feed.push(d),(o=(a=this.opts).onActivity)===null||o===void 0||o.call(a,d)}this.feed.sort((r,l)=>l.at-r.at),this.feed.length>Hs&&(this.feed.length=Hs),this.mode==="view"&&this.paintFeed()}startFeedClock(){this.feedTimer=setInterval(()=>{this.mode==="view"&&(this.paintFeed(),this.paintMonitorInsights())},1e4)}selectionCap(){var t,e;return this.mode!=="select"?1e6:(t=(e=this.opts.numberOfPlacesToSelect)!==null&&e!==void 0?e:this.opts.maxSelectedObjects)!==null&&t!==void 0?t:1e6}canSelectObject(t){var e,i;const s=(e=this.status.get(t.label))!==null&&e!==void 0?e:"free",n=(i=this.opts.unavailableObjectsSelectable)!==null&&i!==void 0?i:!0,o=s==="free"||n||this.selectableObjectLabels.has(t.label);if(!this.opts.isObjectSelectable)return o;try{return this.opts.isObjectSelectable(t,o)===!0}catch(l){var a,r;return(a=(r=this.opts).onError)===null||a===void 0||a.call(r,l),!1}}applyInitialSelection(){var t;this.initialSelectionApplied||this.mode!=="select"||!this.renderer||(this.initialSelectionApplied=!0,this.selectByLabels((t=this.opts.selectedObjects)!==null&&t!==void 0?t:[]))}trimSelectionToCap(){var t;if(this.mode!=="select")return;const e=this.getSelection(),i=this.selectionCap();e.length<=i||(t=this.renderer)===null||t===void 0||t.deselect(e.slice(i).map(s=>s.id))}reconcileSelectPolicy(){var t;if(this.mode!=="select")return;const e=this.getSelection().filter(i=>!this.canSelectObject(i));e.length&&((t=this.renderer)===null||t===void 0||t.deselect(e.map(i=>i.id))),this.trimSelectionToCap(),this.syncSelection()}selectionLabels(){return this.getSelection().map(t=>t.label)}syncSelection(){var t,e,i;const s=this.getSelection();this.mode==="block"?this.paintSelBar(s):this.mode==="inspect"?this.renderInspectRail(s):this.mode==="select"?this.paintSelectSelection(s):this.mode==="categories"?this.paintCategorySelection(s):this.mode==="channels"&&((t=this.channels)===null||t===void 0||t.handleSelectionChange());const n=new Map(s.map(v=>[v.label,v]));if(this.mode==="select"){for(const[m,g]of n){var o,a;this.lastSelectionLabels.has(m)||(o=(a=this.opts).onObjectSelected)===null||o===void 0||o.call(a,g)}for(const m of this.lastSelectionLabels)if(!n.has(m)){var r,l;const g=this.labelToSeat.get(m);g&&((r=(l=this.opts).onObjectDeselected)===null||r===void 0||r.call(l,g))}const v=this.getSelectionValidity();if(v){var c,d;if((c=(d=this.opts).onSelectionValidityChange)===null||c===void 0||c.call(d,v),this.selectionWasValid!==v.isValid){var u,h,p,f;v.isValid?(u=(h=this.opts).onSelectionValid)===null||u===void 0||u.call(h,v):(p=(f=this.opts).onSelectionInvalid)===null||p===void 0||p.call(f,v)}this.selectionWasValid=v.isValid}}this.lastSelectionLabels=new Set(n.keys()),(e=(i=this.opts).onSelectionChange)===null||e===void 0||e.call(i,s)}buildChrome(){const t=document.createElement("div");t.className="slm",t.tabIndex=0,t.setAttribute("role","region"),t.setAttribute("aria-label","SeatLayer live control room");const e=Tl(this.opts.theme);for(const[s,n]of Object.entries(e))t.style.setProperty(s,n);t.innerHTML=`
-
`}paintFollowLiveButton(){const t=this.els.follow;t&&(t.classList.toggle("on",this.followLive),t.setAttribute("aria-pressed",String(this.followLive)),t.setAttribute("title",this.followLive?"Following new holds and bookings. Turn off to keep the current view.":"Stay on the current map view. Enable to follow new holds and bookings."))}paintHeatButton(){const t=this.els.heat;t&&(t.classList.toggle("on",this.heatEnabled),t.setAttribute("aria-pressed",String(this.heatEnabled)),t.setAttribute("aria-label",`Booking momentum overlay ${this.heatEnabled?"on":"off"}`),t.setAttribute("title",`${this.heatEnabled?"Hide":"Highlight"} sections booking fastest in the selected time window`),t.textContent="Booking momentum",this.paintMomentumHelp())}paintMomentumHelp(){var t,e;const i=(t=this.els.rail)===null||t===void 0?void 0:t.querySelector('[data-ref="momentumhelp"]');if(!i)return;i.hidden=!this.heatEnabled;const s=i.querySelector('[data-ref="momentumcopy"]');s&&(s.textContent=!((e=this.controlRoomSnapshot)===null||e===void 0)&&e.velocity.bySection.some(n=>n.netBooked>0)?"Warmer sections have more completed bookings, adjusted for section size. Holds and viewers are not counted.":`No completed bookings in the last ${this.trendWindowMinutes} minutes.`)}paintFullscreenButton(){this.els.fullscreen&&(this.els.fullscreen.textContent=this.isFullscreen()?"Exit full screen":"Full screen")}paintTrendWindow(){var t;(t=this.els.rail)===null||t===void 0||t.querySelectorAll("[data-window]").forEach(e=>{const i=Number(e.dataset.window);e.classList.toggle("on",i===this.trendWindowMinutes)})}setLive(t){var e;(e=this.root)===null||e===void 0||e.classList.toggle("live",t),this.els.livetext&&(this.els.livetext.textContent=t?"LIVE":"RECONNECTING"),this.paintMonitorInsights();const i=t?"live":"reconnecting";if(i!==this.connectionStatus){this.connectionStatus=i;try{var s,n;(s=(n=this.opts).onConnectionChange)===null||s===void 0||s.call(n,this.getConnection())}catch(r){var o,a;(o=(a=this.opts).onError)===null||o===void 0||o.call(a,r)}}}updateZoomHint(){var t,e;const i=this.els.zoomhint;if(!i)return;const s=this.mode==="block"&&((t=this.renderer)===null||t===void 0||(e=t.getRung)===null||e===void 0?void 0:e.call(t))!=="seats";i.classList.toggle("on",!!s)}formatKpiDelta(t,e,i){const s=e>0?"+":"−",n=Math.abs(e);return t==="booked-value"?`${s}${$s(n,i)}`:t==="booked-pct"?`${s}${n.toLocaleString()}pt`:`${s}${n.toLocaleString()}`}paintKpis(t){var e,i;if(!this.els.kpis)return;const s=t.bookedValueStatus==="current"?$s(t.bookedValue,t.currency):"—",n=this.presenceCounts(),o=[{key:"booked-inventory",raw:t.booked,n:t.booked.toLocaleString(),l:"Booked inventory",dot:"#22a06b",title:"Inventory units booked"},{key:"held-seats",raw:t.held,n:t.held.toLocaleString(),l:"Held inventory",dot:"#f4b740",title:"Inventory currently held"},{key:"free-seats",raw:t.free,n:t.free.toLocaleString(),l:"Available",dot:"#6e7bff",title:"Inventory available to book"},{key:"blocked",raw:t.blocked,n:t.blocked.toLocaleString(),l:"Blocked",dot:"#8b94ac",title:"Inventory withheld from booking"},{key:"viewing-map",raw:(e=n==null?void 0:n.shoppingSessions)!==null&&e!==void 0?e:null,n:n?n.shoppingSessions.toLocaleString():"—",l:"Viewing map",title:"Active map sessions right now"},{key:"active-holds",raw:(i=n==null?void 0:n.activeHolds)!==null&&i!==void 0?i:null,n:n?n.activeHolds.toLocaleString():"—",l:"Active holds",title:"Sessions currently holding inventory"},{key:"booked-pct",raw:t.capacityPct,n:`${t.capacityPct}%`,l:"Booked",title:"Booked inventory as a share of the whole event"},{key:"booked-value",raw:t.bookedValueStatus==="current"?t.bookedValue:null,n:s,l:"Booked value",title:"Configured value attached to booked inventory"}];let a=!1;this.els.kpis.innerHTML=o.map(r=>{const l=this.lastKpiValues.get(r.key),c=r.raw!=null&&l!=null&&r.raw!==l,d=c?r.raw-l:0;c&&(a=!0,this.activeKpiDeltas.set(r.key,{text:this.formatKpiDelta(r.key,d,t.currency),down:d<0})),r.raw!=null&&this.lastKpiValues.set(r.key,r.raw);const u=this.activeKpiDeltas.get(r.key);return`
Sales channels could not be loaded. Switch away and back to try again.
':this.renderBlockRail(),this.updateZoomHint()}renderViewRail(){this.els.rail.innerHTML=`
- ${this.railHeader("Monitor","read","Watch the event live. Inventory, buyers on the map and booking movement update on this board as they happen — nothing here changes the event.")}
-
-
-
',this.paintTrendWindow(),this.paintMomentumHelp()}applyHeatOverlay(){var t;const e=this.controlRoomSnapshot;if(!this.heatEnabled||!e){var i;(i=this.renderer)===null||i===void 0||i.setSectionHeat(null);return}const s=new Map(e.bookedValue.bySection.map(r=>[r.sectionId,Math.max(1,r.total)])),n=e.velocity.bySection.map(r=>{var l;return{sectionId:r.sectionId,rate:Math.max(0,r.netBooked)/((l=s.get(r.sectionId))!==null&&l!==void 0?l:1)/e.velocity.windowMinutes}}),o=Math.max(0,...n.map(r=>r.rate)),a={};for(const r of n)a[r.sectionId]=o>0?Math.sqrt(r.rate/o):0;(t=this.renderer)===null||t===void 0||t.setSectionHeat(a)}renderSelectRail(){var t,e,i;const s=(t=(e=this.doc)===null||e===void 0?void 0:e.categories)!==null&&t!==void 0?t:[],n=this.opts.numberOfPlacesToSelect,o=this.selectionCap();this.els.rail.innerHTML=`
- ${this.railHeader("Select","host","Pick seats for your own back-office operation — the selection is handed to your app. This tool is read-only inside the control room: it never books, releases or blocks seats by itself.")}
-
0selected
-
${n?`Select exactly ${n.toLocaleString()} object${n===1?"":"s"}.`:`Up to ${o.toLocaleString()} objects may be selected.`}
-
-
-
-
- ${s.length?`
Select by category
-
${s.map(a=>{var r,l;return`
- `}).join("")}
`:""}`,this.els.selectnum=this.els.rail.querySelector('[data-ref="selectnum"]'),this.els.selectmeta=this.els.rail.querySelector('[data-ref="selectmeta"]'),this.els.selectvalidity=this.els.rail.querySelector('[data-ref="selectvalidity"]'),this.els.selectclear=this.els.rail.querySelector('[data-ref="selectclear"]'),(i=this.els.rail.querySelector('[data-ref="selectall"]'))===null||i===void 0||i.addEventListener("click",()=>this.selectAll()),this.els.selectclear.addEventListener("click",()=>this.clearSelection()),this.els.rail.querySelectorAll("[data-select-cat]").forEach(a=>{a.addEventListener("click",()=>{const r=a.dataset.selectCat,l=[...this.labelToSeat.values()].filter(d=>d.categoryKey===r&&this.canSelectObject(d)),c=new Set(this.selectionLabels());l.length>0&&l.every(d=>c.has(d.label))?this.deselectCategories([r]):this.selectCategories([r])})}),this.paintSelectSelection(this.getSelection())}paintSelectSelection(t){var e;if(!this.els.selectnum||!this.els.selectmeta)return;const i=t.length;this.els.selectnum.textContent=i.toLocaleString(),this.els.selectmeta.textContent=i===1?"object selected":"objects selected",this.els.selectclear.disabled=i===0;const s=this.getSelectionValidity();this.els.selectvalidity&&(this.els.selectvalidity.textContent=s?s.isValid?`Ready — exactly ${s.required.toLocaleString()} selected.`:`Select ${s.remaining.toLocaleString()} more to continue.`:`${Math.max(0,this.selectionCap()-i).toLocaleString()} selections remaining.`);const n=new Set(t.map(o=>o.label));(e=this.els.rail)===null||e===void 0||e.querySelectorAll("[data-select-cat]").forEach(o=>{const a=o.dataset.selectCat,r=[...this.labelToSeat.values()].filter(u=>u.categoryKey===a&&this.canSelectObject(u)),l=r.filter(u=>n.has(u.label)).length,c=r.length>0&&l===r.length;o.classList.toggle("on",c),o.setAttribute("aria-pressed",String(c));const d=o.querySelector("[data-cat-count]");d&&(d.textContent=l?`${l}/${r.length}`:r.length.toLocaleString()),o.disabled=r.length===0})}renderFilterSectionsRail(){var t;const e=new Map;for(const s of this.filterableSections()){var i;e.set(s.label,[...(i=e.get(s.label))!==null&&i!==void 0?i:[],s])}this.els.rail.innerHTML=`
- ${this.railHeader("Filter sections","host","Narrow the map to one section for your own reporting. Sections sharing a label stay together and the map frames their combined inventory. Nothing changes for buyers.")}
- ${e.size?`
'}`,this.els.rail.querySelectorAll("[data-filter-section]").forEach(s=>{s.addEventListener("click",()=>this.setFilteredSection(s.dataset.filterSection))}),(t=this.els.rail.querySelector("[data-clear-filter]"))===null||t===void 0||t.addEventListener("click",()=>this.clearFilteredSection())}categorySeats(t){return[...this.labelToSeat.values()].filter(e=>e.categoryKey===t&&this.canSelectObject(e))}renderCategoriesRail(){var t,e;const i=(t=(e=this.doc)===null||e===void 0?void 0:e.categories)!==null&&t!==void 0?t:[];this.els.rail.innerHTML=`
- ${this.railHeader("Categories","event","Move seats to a different price category for this event only. The reusable chart keeps its design, and seats already held or booked keep the price they were sold at.")}
-
1Choose seats
-
Click or drag seats on the map, press ⌘A for all, or tick a whole category. A ticked category is selected; tick it again to remove it.
-
${i.length?i.map(n=>{var o,a;return`
- `}).join(""):'This chart has no categories.'}
-
- 0
- selected
-
-
-
-
-
-
2Move them to
-
Select seats first — then pick the category they should sell under.
-
${i.map(n=>{var o,a;return`
- `}).join("")}
`;const s=n=>this.els.rail.querySelector(`[data-ref="${n}"]`);this.els.categorynum=s("categorynum"),this.els.categorymeta=s("categorymeta"),this.els.categoryhelp=s("categoryhelp"),this.els.categoryclear=s("categoryclear"),s("categoryall").addEventListener("click",()=>this.selectAll()),this.els.categoryclear.addEventListener("click",()=>this.clearSelection()),this.els.rail.querySelectorAll("[data-pick-category]").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.pickCategory,a=this.categorySeats(o),r=new Set(this.selectionLabels());a.length>0&&a.every(l=>r.has(l.label))?this.deselectCategories([o]):this.selectCategories([o])})}),this.els.rail.querySelectorAll("[data-assign-category]").forEach(n=>{n.addEventListener("click",()=>{this.setCategory(n.dataset.assignCategory)})}),this.paintCategorySelection(this.getSelection())}paintCategorySelection(t){var e,i,s;if(!this.els.categorynum)return;const n=t.length;this.els.categorynum.textContent=n.toLocaleString(),this.els.categoryclear.disabled=n===0;const o=new Map;for(const l of t)o.set(l.categoryKey,((e=o.get(l.categoryKey))!==null&&e!==void 0?e:0)+1);const a=l=>{var c,d;return(c=(d=this.doc)===null||d===void 0||(d=d.categories.find(u=>u.key===l))===null||d===void 0?void 0:d.label)!==null&&c!==void 0?c:l};this.els.categorymeta&&(this.els.categorymeta.textContent=n===0?"selected":`${n===1?"seat":"seats"} selected · ${[...o].map(([l,c])=>`${c.toLocaleString()} ${a(l)}`).join(", ")}`),this.els.categoryhelp&&(this.els.categoryhelp.textContent=n===0?"Select seats first — then pick the category they should sell under.":`Choose the category the ${n===1?"selected seat":`${n.toLocaleString()} selected seats`} should sell under. Applies immediately.`);const r=new Set(t.map(l=>l.label));(i=this.els.rail)===null||i===void 0||i.querySelectorAll("[data-pick-category]").forEach(l=>{const c=l.dataset.pickCategory,d=this.categorySeats(c),u=d.filter(f=>r.has(f.label)).length,h=d.length>0&&u===d.length;l.classList.toggle("on",h),l.classList.toggle("partial",u>0&&!h),l.setAttribute("aria-pressed",String(h));const p=l.querySelector("[data-cat-count]");p&&(p.textContent=u?`${u.toLocaleString()}/${d.length.toLocaleString()}`:d.length.toLocaleString()),l.disabled=d.length===0}),(s=this.els.rail)===null||s===void 0||s.querySelectorAll("[data-assign-category]").forEach(l=>{var c;const d=l.dataset.assignCategory,u=[...this.labelToSeat.values()].filter(m=>m.categoryKey===d).length,h=(c=o.get(d))!==null&&c!==void 0?c:0,p=n>0&&h===n;l.disabled=n===0||p,l.classList.toggle("current",p);const f=l.querySelector("[data-cat-current]");f&&(f.textContent=`${u.toLocaleString()} ${u===1?"seat":"seats"} now`);const v=l.querySelector("[data-cat-action]");v&&(v.textContent=n===0?"Move here":p?"Already here":`Move ${(n-h).toLocaleString()} here`)})}renderTablesRail(){const t=this.tables(),e="Decide how each table sells for this event: every chair on its own, or the whole table as one booking. A table with held, booked, or blocked chairs is locked until that inventory is released, and channel allocations are kept.";if(this.inventoryModelVersion!==2){this.els.rail.innerHTML=`
- ${this.railHeader("Tables","event",e)}
-
This event still uses the older inventory model, which cannot switch tables between per-chair and whole-table selling. Upgrade the event's inventory model to unlock this tool.
Changes apply immediately to this event. Flexible group sizes (minimum and maximum guests) are set through the API, never guessed here.
`,this.els.rail.querySelectorAll("[data-table-all]").forEach(d=>{d.addEventListener("click",()=>{this.setTableBooking(n.filter(u=>!u.locked).map(u=>u.table.id),d.dataset.tableAll)})}),this.els.rail.querySelectorAll("[data-table-mode]").forEach(d=>{d.addEventListener("change",()=>{this.setTableBooking([d.dataset.tableMode],d.value)})})}renderInspectRail(t){var e,i,s,n,o,a,r;const l=t[t.length-1];if(!l){this.els.rail.innerHTML=`
- ${this.railHeader("Inspect","read","Click one seat on the map to read its live status, category, section and booking context. Nothing changes in this view.")}
-
Select a seat on the map.
`;return}const c=(e=this.status.get(l.label))!==null&&e!==void 0?e:"free",d={free:"Free",held:"Held",booked:"Booked",blocked:"Blocked"},u=(i=this.sectionByObject.get(l.rowId))!==null&&i!==void 0?i:ct,h=(s=this.sectionLabelById.get(u))!==null&&s!==void 0?s:"Other seats",p=(n=this.doc)===null||n===void 0?void 0:n.categories.find(b=>b.key===l.categoryKey),f=(o=this.controlRoomSnapshot)===null||o===void 0?void 0:o.bookedValue.bySection.find(b=>b.sectionId===u),v=(a=this.doc)===null||a===void 0?void 0:a.objects.find(b=>b.id===l.rowId),m=(v==null?void 0:v.type)==="row"?{label:"Row",value:v.label}:(v==null?void 0:v.type)==="table"?{label:"Table",value:v.label}:l.kind==="booth"?{label:"Type",value:"Booth"}:null,g=l.kind==="booth"?"Booth":"Seat";this.els.rail.innerHTML=`
- ${this.railHeader("Inspect","read",`Live status and section performance for this ${g.toLowerCase()}. Click another seat to switch.`)}
-
`}async refreshAvailability(){try{var t;const s=await this.withAuthRetry(()=>this.api.availability(this.key));this.availabilityRules=(t=s.rules)!==null&&t!==void 0?t:{},this.effectiveClosed=new Set(Al(this.availabilityRules)),this.mode==="sections"&&this.renderSectionsRail(),this.applySectionCanvasTreatment()}catch(s){var e,i;(e=(i=this.opts).onError)===null||e===void 0||e.call(i,s)}}async withAuthRetry(t){try{return await t()}catch(e){if(e instanceof he&&e.status===401&&this.opts.onTokenRefresh&&!this.tokenRefreshInFlight)return await this.rotateToken(),t();throw e}}updateEffectiveAvailability(t,e){let i=!1;Array.isArray(t)&&(this.effectiveHidden=new Set(t.filter(s=>typeof s=="string")),i=!0),Array.isArray(e)&&(this.effectiveClosed=new Set(e.filter(s=>typeof s=="string")),i=!0),i&&(this.mode==="sections"&&this.renderSectionsRail(),this.applySectionCanvasTreatment())}applySectionCanvasTreatment(){this.renderer&&(this.mode==="sections"?(this.renderer.setDimmedSections([...this.effectiveHidden]),this.renderer.setClosedSections([...this.effectiveClosed])):this.mode==="filterSections"&&this.filteredSectionLabel?this.applyFilteredSectionCanvas():(this.renderer.setDimmedSections(null),this.renderer.setClosedSections(null)))}sectionRowsInput(){return{sectionsBase:this.sectionsBase,doc:this.doc,availabilityRules:this.availabilityRules,effectiveHidden:this.effectiveHidden,effectiveClosed:this.effectiveClosed}}renderSectionsRail(){const{rows:t,hiddenSections:e,closedSections:i}=so(this.sectionRowsInput());if(!t.length){this.els.rail.innerHTML=`
- ${this.railHeader("Sections","event","Draw sections or zones in the designer to schedule availability per area. This chart has none yet.")}
-
No sections on this chart.
`;return}const s=[];e&&s.push(`${e} hidden`),i&&s.push(`${i} closed`);const n=s.length?s.join(" · "):"All sections open and on sale",o=e>0||i>0;this.els.rail.innerHTML=`
- ${this.railHeader("Sections","event","Decide when each zone or section goes on sale for this event. Keep it hidden, reveal it at a set time, or auto-reveal once the rest sells past a threshold. Hidden seats vanish for buyers; closed seats stay on the map (flat grey) but can't be bought.")}
-
`:"",n=this.sectionOptions.map(d=>``).join("");this.els.rail.innerHTML=`
- ${this.railHeader("Block","event","Take seats off sale for this event, or put blocked seats back. Drag a box on the map, press ⌘A for all, or pick a whole category or section below. Booked and held seats are never touched.")}
-
0selected
-
-
-
-
-
-
-
-
-
Select by category
-
Choose one or more. A checked category is selected; click it again to remove it.
-
${i||'No categories.'}
- ${s}
-
-
-
-
Leave empty to block permanently.
-
-
-
-
Blocked inventory
- 0 out of sale
-
-
Find blocked seats, select only the ones you need, then use “Put back on sale”.
-
-
-
-
-
- No blocked seats
-
-
-
-
-
-
-
For a full reset only. You will be asked to confirm.
-
- `;const o=d=>this.els.rail.querySelector(`[data-ref="${d}"]`);this.els.selnum=o("selnum"),this.els.doblock=o("doblock"),this.els.dounblock=o("dounblock"),this.els.selmeta=o("selmeta"),this.els.blockedcount=o("blockedcount"),this.els.blockedshowing=o("blockedshowing"),this.els.blockedlist=o("blockedlist"),this.els.selblocked=o("selblocked"),this.els.markall=o("markall"),this.els.markallnote=o("markallnote"),o("doblock").addEventListener("click",()=>{this.block()}),o("dounblock").addEventListener("click",()=>{this.unblock()}),o("selall").addEventListener("click",()=>this.selectAll()),o("clearsel").addEventListener("click",()=>this.clearSelection()),o("markall").addEventListener("click",()=>this.confirmUnblockAll()),this.els.rail.querySelectorAll("[data-cat]").forEach(d=>d.addEventListener("click",()=>this.toggleCategory(d.dataset.cat)));const a=this.els.rail.querySelector('[data-ref="section"]');a==null||a.addEventListener("change",()=>{a.value&&(this.selectSection(a.value),a.value="")});const r=o("blockedsearch"),l=o("blockedsection");r.value=this.blockedQuery,l.value=this.blockedSection,r.addEventListener("input",()=>{this.blockedQuery=r.value,this.blockedResultLimit=100,this.paintBlockedInventory()}),l.addEventListener("change",()=>{this.blockedSection=l.value,this.blockedResultLimit=100,this.paintBlockedInventory()}),o("selblocked").addEventListener("click",()=>{this.toggleLabels(this.filteredBlockedSeats().map(d=>d.label))}),o("blockedlist").addEventListener("click",d=>{const u=d.target,h=u.closest("[data-blocked-label]");h!=null&&h.dataset.blockedLabel?this.toggleLabels([h.dataset.blockedLabel]):u.closest("[data-blocked-more]")&&(this.blockedResultLimit+=100,this.paintBlockedInventory())});const c=o("release");c.addEventListener("change",()=>{const d=c.value?new Date(c.value).getTime():NaN;this.releaseAt=Number.isFinite(d)&&d>Date.now()?d:null;const u=o("releasenote");u.textContent=this.releaseAt?`New blocks auto-release ${new Date(this.releaseAt).toLocaleString()}.`:c.value?"Pick a time in the future.":"Leave empty to block permanently."}),this.paintSelBar(this.getSelection())}toggleCategory(t){const e=[];for(const[i,s]of this.labelToSeat.entries())s.categoryKey===t&&this.isBlockSelectable(i)&&e.push(i);this.toggleLabels(e)}toggleLabels(t){if(!this.renderer)return;const e=t.filter(s=>this.labelToSeat.has(s)&&this.isBlockSelectable(s));if(!e.length)return;const i=new Set(this.selectionLabels());if(e.every(s=>i.has(s))){const s=e.map(n=>this.labelToId.get(n)).filter(n=>!!n);this.renderer.deselect(s)}else this.renderer.selectByLabels(e);this.syncSelection()}isBlockSelectable(t){var e;const i=(e=this.status.get(t))!==null&&e!==void 0?e:"free";return i==="free"||i==="blocked"}paintSelBar(t){if(!this.els.selnum)return;this.els.selnum.textContent=t.length.toLocaleString();const e=t.filter(o=>{var a;return((a=this.status.get(o.label))!==null&&a!==void 0?a:"free")==="free"}).length,i=t.filter(o=>this.status.get(o.label)==="blocked").length;this.els.selmeta.textContent=t.length?`${e.toLocaleString()} available · ${i.toLocaleString()} blocked`:"selected";const s=this.els.doblock,n=this.els.dounblock;s.disabled=e===0,n.disabled=i===0,s.textContent=e?`Block ${e.toLocaleString()}`:"Block selected",n.textContent=i?`Put ${i.toLocaleString()} on sale`:"Put back on sale",this.paintCategoryControls(t),this.paintBlockedInventory()}paintCategoryControls(t){var e;const i=new Set(t.map(s=>s.label));(e=this.els.rail)===null||e===void 0||e.querySelectorAll("[data-cat]").forEach(s=>{const n=s.dataset.cat,o=[];for(const[d,u]of this.labelToSeat.entries())u.categoryKey===n&&this.isBlockSelectable(d)&&o.push(d);const a=o.filter(d=>i.has(d)).length,r=o.length>0&&a===o.length,l=a>0&&!r;s.disabled=o.length===0,s.classList.toggle("on",r),s.classList.toggle("partial",l),s.setAttribute("aria-pressed",r?"true":l?"mixed":"false"),s.setAttribute("title",r?`Remove all ${o.length.toLocaleString()} seats in this category from the selection`:l?`Select the remaining ${(o.length-a).toLocaleString()} seats in this category`:`Select all ${o.length.toLocaleString()} seats in this category`);const c=s.querySelector("[data-cat-count]");c&&(c.textContent=a?`${a.toLocaleString()}/${o.length.toLocaleString()}`:o.length.toLocaleString())})}filteredBlockedSeats(){const t=this.blockedQuery.trim().toLocaleLowerCase(),e=[];for(const[r,l]of this.labelToSeat.entries()){var i;if(this.status.get(r)!=="blocked")continue;const c=(i=this.sectionByObject.get(l.rowId))!==null&&i!==void 0?i:ct;if(!(this.blockedSection&&c!==this.blockedSection)){if(t){var s,n,o,a;const d=(s=(n=this.doc)===null||n===void 0||(n=n.categories.find(p=>p.key===l.categoryKey))===null||n===void 0?void 0:n.label)!==null&&s!==void 0?s:l.categoryKey,u=(o=this.sectionLabelById.get(c))!==null&&o!==void 0?o:"Other seats",h=(a=this.doc)===null||a===void 0?void 0:a.objects.find(p=>p.id===l.rowId);if(!`${r} ${d} ${u} ${(h==null?void 0:h.type)==="row"||(h==null?void 0:h.type)==="table"?h.label:""}`.toLocaleLowerCase().includes(t))continue}e.push(l)}}return e.sort((r,l)=>r.label.localeCompare(l.label,void 0,{numeric:!0,sensitivity:"base"}))}paintBlockedInventory(){if(!this.els.blockedlist)return;const t=[...this.status.entries()].filter(([,c])=>c==="blocked").length,e=this.filteredBlockedSeats(),i=e.slice(0,this.blockedResultLimit),s=new Set(this.selectionLabels()),n=e.filter(c=>s.has(c.label)).length,o=e.length>0&&n===e.length;this.els.blockedcount.textContent=t.toLocaleString(),this.els.blockedshowing.textContent=e.length?`Showing ${i.length.toLocaleString()} of ${e.length.toLocaleString()}`:t?"No matches":"No blocked seats";const a=this.els.selblocked;a.disabled=e.length===0,a.textContent=o?`Remove ${e.length.toLocaleString()} results`:`Select ${e.length.toLocaleString()} results`,this.els.blockedlist.innerHTML=i.length?i.map(c=>{var d,u,h,p;const f=(d=this.sectionByObject.get(c.rowId))!==null&&d!==void 0?d:ct,v=(u=this.sectionLabelById.get(f))!==null&&u!==void 0?u:"Other seats",m=(h=(p=this.doc)===null||p===void 0||(p=p.categories.find(b=>b.key===c.categoryKey))===null||p===void 0?void 0:p.label)!==null&&h!==void 0?h:c.categoryKey,g=s.has(c.label);return``}).join("")+(e.length>i.length?'':""):`
${t?"No blocked seats match this search or section.":"No seats are blocked. Newly blocked seats will appear here."}
`;const r=this.els.markall,l=r.dataset.confirm==="true";r.disabled=t===0,r.textContent=l?`Confirm: put all ${t.toLocaleString()} on sale`:`Put all ${t.toLocaleString()} blocked seats on sale`}confirmUnblockAll(){const t=this.els.markall;if(!(!t||t.disabled)){if(t.dataset.confirm==="true"){this.resetUnblockAllConfirm(),this.unblockAll();return}t.dataset.confirm="true",t.classList.add("danger"),this.els.markallnote.textContent="This changes every blocked seat. Click the red button again to confirm.",this.paintBlockedInventory(),this.unblockAllConfirmTimer&&clearTimeout(this.unblockAllConfirmTimer),this.unblockAllConfirmTimer=setTimeout(()=>this.resetUnblockAllConfirm(),6e3)}}resetUnblockAllConfirm(){this.unblockAllConfirmTimer&&clearTimeout(this.unblockAllConfirmTimer),this.unblockAllConfirmTimer=null;const t=this.els.markall;t&&(delete t.dataset.confirm,t.classList.remove("danger"),this.els.markallnote&&(this.els.markallnote.textContent="For a full reset only. You will be asked to confirm."),this.paintBlockedInventory())}done(t,e,i){var s,n;if(this.toastOk(i),e.length){const o=t==="block"?this.pushActivity(e,"blocked","blocked"):t==="unblock"||t==="unblockAll"?this.pushActivity(e,"unblocked","free"):t==="cancelBooking"?this.pushActivity(e,"cancelled","free"):null;o&&this.paintSpatialActivity(o)}t!=="setHoldTtl"&&this.refreshControlRoom().catch(o=>{var a,r;return(a=(r=this.opts).onError)===null||a===void 0?void 0:a.call(r,o)}),(s=(n=this.opts).onActionComplete)===null||s===void 0||s.call(n,{action:t,labels:e,count:e.length})}toastOk(t){this.toast(t,"ok")}toastErr(t){this.toast(t,"err")}toast(t,e){const i=this.els.toast;i&&(i.textContent=t,i.className=`slm-toast on ${e}`,this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>{i.className="slm-toast"},3200))}fail(t){var e,i;(e=(i=this.opts).onError)===null||e===void 0||e.call(i,t),this.els.rail&&(this.els.rail.innerHTML=`
Couldn't load this event. Check the event key and token.
`)}},Am=4;function Em(){return new Promise(t=>requestAnimationFrame(()=>t()))}async function Im(t){for(let e=0;e<240;e+=1){await Em();const i=t.stats();if(i.rendered>0&&i.idle)return}throw new Error("seatlayer: hosted 3D preview did not reach a stable frame")}function Mm(t,e){let i=null,s=!1;const n=(async()=>{const a=Ye(t.chart),r=await ll(),l=await r.prepareVenue3D({doc:t.chart,seats:a});if(s)return;const c=r.mountVenue3D(e,{doc:t.chart,seats:a,prepared:l},{portraitOverviewCrop:!0,skipInitialOverviewAnimation:!0});i=c,await Im(c)})(),o=()=>{if(s)throw new Error("seatlayer: hosted 3D preview has been destroyed");if(!i)throw new Error("seatlayer: hosted 3D preview is not ready");return i};return{contractVersion:4,state:"venue3d",ready:n,getQualityEvidence:()=>o().getQualityEvidence(),getQualityReport:()=>o().getQualityReport(),forceDraw:()=>{o()},destroy:()=>{s||(s=!0,i==null||i.dispose(),e.remove())}}}function _m(t,e,i,s,n){var o,a,r,l,c,d,u;const h=t.getRenderedQualityEvidence(),p=new Set([...h.labels.map(D=>D.categoryKey),...h.gaAreas.map(D=>D.categoryKey)]);if(n&&!p.has(n))throw new Error(`seatlayer: evidence category "${n}" has no inventory on this floor`);if(!h.labels.length&&!h.gaAreas.length){t.zoomToFit();return}const f=s?Dt(e).find(D=>D.id===s):Dt(e)[0];if(!f)throw new Error("seatlayer: preview floor does not exist");const v={...e,objects:f.objects,floors:void 0},m=new Map(Ye(v).map(D=>[D.id,D])),g=n?h.labels.filter(D=>D.categoryKey===n):h.labels,b=new Map;for(const D of g){var y;if(!D.sectionId)continue;const F=(y=b.get(D.sectionId))!==null&&y!==void 0?y:[];F.push(D),b.set(D.sectionId,F)}const k=[...b].sort((D,F)=>{const _=new Set(D[1].map(Y=>Y.categoryKey)).size,U=new Set(F[1].map(Y=>Y.categoryKey)).size;return+(F[1].length>=3)-+(D[1].length>=3)||U-_||F[1].length-D[1].length||D[0].localeCompare(F[0])})[0],w=(o=k==null?void 0:k[1])!==null&&o!==void 0?o:g,C=new Map;for(const D of w)C.set(D.categoryKey,((a=C.get(D.categoryKey))!==null&&a!==void 0?a:0)+1);const S=(r=n!=null?n:(l=[...C].sort((D,F)=>F[1]-D[1]||D[0].localeCompare(F[0]))[0])===null||l===void 0?void 0:l[0])!==null&&r!==void 0?r:(c=h.gaAreas[0])===null||c===void 0?void 0:c.categoryKey;if(!S){t.zoomToFit();return}const T=n?w:[...w.filter(D=>D.categoryKey===S),...w.filter(D=>D.categoryKey!==S),...h.labels.filter(D=>!w.includes(D))],E=[...new Map(T.map(D=>[D.seatId,D])).values()],L=E[0],I=E[1],M=E[2];if(L){var x,A;if(I&&t.setStatus([I.seatId],"held"),M&&t.setStatus([M.seatId],"booked"),(x=t.setManageInteraction)===null||x===void 0||x.call(t,{manageMode:!0,marqueeSelect:!1,selectableStatuses:["free"],maxSelection:1}),!(!((A=t.setEvidenceSelection)===null||A===void 0)&&A.call(t,L.seatId))){var P;(P=t.selectByLabels)===null||P===void 0||P.call(t,[L.label])}}if(n||p.size>=2){var N;(N=t.setCategoryFilter)===null||N===void 0||N.call(t,[S])}const W=L?void 0:h.gaAreas.filter(D=>D.categoryKey===S).sort((D,F)=>F.capacity-D.capacity||D.areaId.localeCompare(F.areaId))[0],B=(d=k==null?void 0:k[0])!==null&&d!==void 0?d:W==null?void 0:W.sectionId;B&&((u=t.focusSection)===null||u===void 0||u.call(t,B));const z=L?m.get(L.seatId):void 0,j=W?f.objects.find(D=>D.type==="gaArea"&&D.id===W.areaId):void 0,G=z!=null?z:(j==null?void 0:j.type)==="gaArea"?Qs(j.points,j.holes):void 0;if(G&&t.focusRegion){const D=i.clientWidth||1200,F=i.clientHeight||900,_=2,U=D/(_*1.12),Y=F/(_*1.12);t.focusRegion({x:G.x-U/2,y:G.y-Y/2,width:U,height:Y},{animate:!1})}}function Pm(t){if(typeof t=="string"){const e=document.querySelector(t);if(!e)throw new Error(`seatlayer: preview container "${t}" not found`);return e}if(!(t instanceof HTMLElement))throw new Error("seatlayer: preview container must be a CSS selector or an HTMLElement");return t}function Rm(t){var e,i;if(!t||typeof t!="object")throw new Error("seatlayer: preview options are required");if(!t.chart||typeof t.chart!="object")throw new Error("seatlayer: preview chart is required");if(t.view==="chart"&&t.state==="venue3d")throw new Error("seatlayer: venue3d evidence requires the venue3d preview view");if(t.view==="venue3d"&&t.state&&t.state!=="venue3d")throw new Error("seatlayer: the venue3d preview view requires venue3d evidence state");const s=t.view==="venue3d"||t.state==="venue3d",n=(e=t.state)!==null&&e!==void 0?e:"overview";if(!s&&n!=="overview"&&n!=="interaction")throw new Error(`seatlayer: unsupported preview evidence state "${String(n)}"`);const o=Pm(t.container),a=document.createElement("div");if(a.dataset.seatlayerBuyerRenderer=String(4),a.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;",o.replaceChildren(a),s)return Mm(t,a);const r=n,l=Cr(a,{maxSelection:10,currency:t.currency});l.setChart(t.chart,t.floorId?{floorId:t.floorId}:void 0),t.colorblindSafe&&((i=l.setColorblindSafe)===null||i===void 0||i.call(l,!0)),r==="interaction"?_m(l,t.chart,a,t.floorId,t.evidenceCategoryKey):l.zoomToFit(),l.forceDraw();let c=!1;return{contractVersion:4,state:r,getQualityEvidence:()=>l.getRenderedQualityEvidence(),getQualityReport:()=>{var d;return Sd(l.getRenderedQualityEvidence(),r,(d=t.evidenceCategoryKey)!==null&&d!==void 0?d:null)},forceDraw:()=>l.forceDraw(),destroy:()=>{c||(c=!0,l.destroy(),a.remove())}}}var yg=1,$m=1,Om=1,Fm=["hello","init","cmd","res","err","evt"],bt={UNSUPPORTED_COMMAND:"unsupported_command",BAD_PAYLOAD:"bad_payload",NOT_READY:"not_ready",DESTROYED:"destroyed"},ai=class extends Error{constructor(t,e,i){super(e),this.name="BridgeError",this.code=t,this.details=i}};function Vi(t){return typeof t=="number"&&Number.isFinite(t)&&Math.floor(t)===t}function Bm(t){if(Vi(t))return{min:t,max:t};if(t&&typeof t=="object"){const{min:e,max:i}=t;if(Vi(e)&&Vi(i)&&e<=i)return{min:e,max:i}}return null}function Jl(t,e={min:1,max:1}){const i=Math.min(t.max,e.max);return iGi(()=>a.postMessage(r))}}if(Vs((i=t.SeatLayerNative)===null||i===void 0?void 0:i.post)){const a=t.SeatLayerNative;return{name:"android",send:r=>Gi(()=>a.post(Ns(r)))}}if(Vs((s=t.SeatLayer)===null||s===void 0?void 0:s.postMessage)){const a=t.SeatLayer;return{name:"flutter",send:r=>Gi(()=>a.postMessage(Ns(r)))}}if(Vs((n=t.ReactNativeWebView)===null||n===void 0?void 0:n.postMessage)){const a=t.ReactNativeWebView;return{name:"rn",send:r=>Gi(()=>a.postMessage(Ns(r)))}}const o=t.parent;return o&&o!==t&&typeof o.postMessage=="function"?{name:"frame",send:a=>Gi(()=>o.postMessage(a,"*"))}:{name:"none",send:()=>{}}}function Gi(t){try{t()}catch{}}function Nm(t,e=window){const i=e.__slBridge,s={recv(n){try{t(n)}catch{}}};return e.__slBridge=s,()=>{e.__slBridge===s&&(i?e.__slBridge=i:delete e.__slBridge)}}function Vm(t,e=window){if(typeof e.addEventListener!="function")return()=>{};const i=s=>{try{t(s.data)}catch{}};return e.addEventListener("message",i),()=>e.removeEventListener("message",i)}var sc=["sys.ready","sys.error","sys.incompatible","selection.changed","hold.changed","hold.restored","hold.expired","ga.click","hint","error","seat.hover","deck.tap"],Gm=new Set(["seat.hover","selection.changed"]),nc=["hold","hold.extend","hold.resume","hold.partial-release","best-available","ga","tiers","floors","zoom","colorblind-safe","view-modes","seat-hover"];function Et(t){throw new ai(bt.BAD_PAYLOAD,t)}function st(t){return t==null?{}:((typeof t!="object"||Array.isArray(t))&&Et("payload must be an object"),t)}function qi(t,e){const i=t[e];return(typeof i!="string"||!i)&&Et(`\`${e}\` must be a non-empty string`),i}function yo(t,e){const i=t[e];return(typeof i!="number"||!Number.isFinite(i))&&Et(`\`${e}\` must be a finite number`),i}function Gs(t,e){if(!(t[e]===void 0||t[e]===null))return yo(t,e)}function oc(t,e){const i=t[e];if(i!=null)return typeof i!="string"&&Et(`\`${e}\` must be a string`),i}function ac(t,e){const i=t[e];return typeof i!="boolean"&&Et(`\`${e}\` must be a boolean`),i}function qm(t,e){if(!(t[e]===void 0||t[e]===null))return ac(t,e)}function rc(t,e){const i=qi(t,e);return i!=="flat"&&i!=="iso"&&i!=="perspective"&&Et(`\`${e}\` must be flat, iso or perspective`),i}function jm(t,e){const i=t[e];return(!Array.isArray(i)||i.some(s=>typeof s!="string"))&&Et(`\`${e}\` must be an array of strings`),i}function lc(t,e){const i=t[e];return i==null?null:(typeof i!="string"&&Et(`\`${e}\` must be a string or null`),i)}var cc={hold:async(t,e)=>({hold:await t.holdOrThrow({ttlMs:Gs(st(e),"ttlMs")})}),resumeHold:async(t,e)=>({hold:await t.resumeHoldOrThrow(qi(st(e),"holdId"))}),extendHold:async(t,e)=>({hold:await t.extendHold(Gs(st(e),"ttlMs"))}),release:async t=>(await t.release(),{}),releaseLabels:async(t,e)=>({released:await t.releaseLabels(jm(st(e),"labels"))}),bestAvailable:async(t,e)=>{const i=st(e);return{hold:await t.bestAvailableOrThrow(yo(i,"qty"),oc(i,"categoryKey"),{zoneId:oc(i,"zoneId"),preferPremium:qm(i,"preferPremium"),ttlMs:Gs(i,"ttlMs")})}},holdGA:async(t,e)=>{const i=st(e);return{hold:await t.holdGAOrThrow(qi(i,"areaId"),yo(i,"qty"),{tierId:i.tierId===void 0?void 0:lc(i,"tierId"),ttlMs:Gs(i,"ttlMs")})}},setSeatTier:(t,e)=>{const i=st(e);return t.setSeatTier(qi(i,"seatId"),lc(i,"tierId")),{}},getSelection:t=>({seats:t.getSelection()}),getCurrentHold:t=>({hold:t.getCurrentHold()}),getGAAreas:t=>({areas:t.getGAAreas()}),getFloors:t=>({floors:t.getFloors()}),setFloor:(t,e)=>(t.setFloor(qi(st(e),"floorId")),{}),setColorblindSafe:(t,e)=>(t.setColorblindSafe(ac(st(e),"on")),{}),setViewMode:(t,e)=>(t.setViewMode(rc(st(e),"mode")),{}),getViewMode:t=>({mode:t.getViewMode()}),zoomIn:t=>(t.zoomIn(),{}),zoomOut:t=>(t.zoomOut(),{}),zoomToFit:t=>(t.zoomToFit(),{}),destroy:t=>(t.destroy(),{})},dc=Object.keys(cc),Um=1e4;function Wm(t={}){var e,i,s,n,o,a;const r=(e=t.win)!==null&&e!==void 0?e:globalThis,l=(i=t.transport)!==null&&i!==void 0?i:ic(r),c=(s=t.createChart)!==null&&s!==void 0?s:(z=>new Ur(z)),d=(n=t.timeoutMs)!==null&&n!==void 0?n:Um,u=(o=t.schedule)!==null&&o!==void 0?o:(z=>{const j=r.requestAnimationFrame;typeof j=="function"?j.call(r,()=>z()):setTimeout(z,0)});let h=0,p=null,f=null,v=!1,m=!1,g=!1,b=!1;const y=new Map;let k=!1;const w=z=>{g||l.send(z)},C=(z,j)=>{w(Hm(z,++h,j))},S=()=>{if(k=!1,g)return;const z=[...y.entries()];y.clear();for(const[j,G]of z)C(j,G)},T=(z,j)=>{if(!g){if(!Gm.has(z)){C(z,j);return}y.set(z,j),!k&&(k=!0,u(S))}},E=(z,j="internal_error")=>{try{C("sys.error",bo(z,j))}catch{}},L=(z,j)=>(...G)=>{try{T(z,j(...G))}catch(D){E(D)}};let I=null;const M=()=>{I!==null&&(clearTimeout(I),I=null)},x=async z=>{var j;if(b)return;b=!0,M();const G=(j=z.p)!==null&&j!==void 0?j:{},D=Bm(G.protocol);if(!D){C("sys.incompatible",{code:bt.BAD_PAYLOAD,message:"`init.protocol` must be a number or {min,max}",web:{min:1,max:1}});return}const F=Jl(D);if(!F.ok){C("sys.incompatible",{message:F.reason,host:F.host,web:F.web});return}p=F.protocol;try{var _,U,Y;f=c(A(G)),await f.render(),v=!0,C("sys.ready",{protocol:p,mode:(_=f.getMode())!==null&&_!==void 0?_:"live",transport:l.name,chart:{event:(U=(Y=G.config)===null||Y===void 0?void 0:Y.event)!==null&&U!==void 0?U:null}})}catch(ie){f=null,E(ie,"render_failed")}},A=z=>{var j,G,D,F,_;const U=(j=z.config)!==null&&j!==void 0?j:{},Y=U.event;if(typeof Y!="string"||!Y)throw new ai(bt.BAD_PAYLOAD,"`init.config.event` is required");const ie=(G=(D=U.container)!==null&&D!==void 0?D:t.container)!==null&&G!==void 0?G:(F=r.document)===null||F===void 0?void 0:F.body;if(!ie)throw new ai(bt.BAD_PAYLOAD,"no container available to mount into");return{container:ie,event:Y,apiBase:U.apiBase,publicKey:U.publicKey,maxSelection:U.maxSelection,locale:U.locale,messages:U.messages,currency:U.currency,colorblindSafe:U.colorblindSafe,initialView:U.initialView===void 0?void 0:rc(U,"initialView"),seatTooltip:(_=z.chrome)===null||_===void 0?void 0:_.seatTooltip,onSelectionChange:L("selection.changed",ae=>({seats:ae})),onHold:L("hold.changed",ae=>({hold:ae})),onHoldRestored:L("hold.restored",ae=>({hold:ae})),onHoldExpired:L("hold.expired",()=>({})),onGAClick:L("ga.click",ae=>({area:ae})),onHint:L("hint",ae=>({message:ae})),onError:L("error",ae=>bo(ae,"picker_error")),onSeatHover:L("seat.hover",ae=>({details:ae})),onDeckTap:L("deck.tap",ae=>({floorId:ae}))}},P=async z=>{const j=z.id;if(!j){E(new ai(bt.BAD_PAYLOAD,`cmd \`${z.t}\` is missing \`id\``));return}const G=(F,_)=>{w(tc(j,z.t,{code:F,message:_}))},D=cc[z.t];if(!D){G(bt.UNSUPPORTED_COMMAND,`unknown command \`${z.t}\``);return}if(m){G(bt.DESTROYED,"the chart has been destroyed");return}if(!v||!f){G(bt.NOT_READY,"the chart is not ready yet");return}try{const F=await D(f,z.p);z.t==="destroy"&&(m=!0),w(Dm(j,z.t,F))}catch(F){w(tc(j,z.t,bo(F,"command_failed")))}},N=z=>{if(g)return;const j=ec(z);if(j)try{j.k==="init"?x(j):j.k==="cmd"&&P(j)}catch(G){E(G)}},W=Nm(N,r),B=Vm(N,r);return I=setTimeout(()=>{I=null,!b&&(b=!0,C("sys.error",{code:"host_timeout",message:`no init from the host within ${d}ms`}))},d),w(zm({bundle:(a=t.bundle)!==null&&a!==void 0?a:"unknown",protocol:{min:1,max:1},capabilities:[...nc],events:[...sc],commands:dc})),{close(){if(!g){g=!0,M(),y.clear(),B(),W();try{f==null||f.destroy()}catch{}f=null,v=!1}},get protocol(){return p},get transport(){return l.name}}}Xl(),vo(),po(),to();var Km="0.59.0";function Ym(t={}){return Wm({bundle:"0.59.0",...t})}return X.ACCESS_LINK_DEFAULTS=Ds,X.ApiError=As,X.BRIDGE_CAPABILITIES=nc,X.BRIDGE_COMMANDS=dc,X.BRIDGE_ERROR_CODES=bt,X.BRIDGE_EVENTS=sc,X.BRIDGE_PROTOCOL_MAX=Om,X.BRIDGE_PROTOCOL_MIN=$m,X.BUYER_RENDERER_CONTRACT_VERSION=Am,X.BridgeError=ai,X.BuyerAccessContext=Gr,X.BuyerAccessUnavailableError=Nn,X.BuyerRealtimeClient=Ls,X.ChannelsMode=go,X.EmbeddedDesigner=jf,X.ManageApi=eo,X.ManageApiError=he,X.PUBLIC_CHANNEL_ID=Ue,X.PUBLIC_CHANNEL_NAME=ze,X.SEATING_CHART_CALLBACK_PROPS=Xr,X.SEATING_CHART_HANDLE_METHODS=Wr,X.SEATING_CHART_IDENTITY_PROPS=Kr,X.SEATING_CHART_VALUE_PROPS=Yr,X.SeatManager=Lm,X.SeatPicker=Uv,X.SeatingChart=Ur,X.accessIntentDescription=Ol,X.accessIntentLabel=Bt,X.accessLine=$l,X.accessLinkBadge=Bl,X.accessLinkErrorCopy=Hi,X.accessLinkIsLive=lo,X.accessLinkPolicyLines=co,X.attachPickerFrame=Wv,X.bindSeatingChartHandle=_f,X.bucketRows=Pl,X.bucketRowsHtml=fo,X.buildSeatingChartOptions=Pf,X.createBuyerAccessContext=Wn,X.createControllerSink=Hn,X.decodeBridgeEnvelope=ec,X.detectBridgeTransport=ic,X.dropReviewRows=um,X.encodeBridgeEnvelope=Ns,X.intentForbidsCopy=Bs,X.intentSwitchBlockedCopy=Fl,X.isPublicChannelId=gt,X.markerLetter=Ft,X.markerOf=El,X.mutationCount=Os,X.needsMoveConfirmation=_l,X.negotiateBridgeProtocol=Jl,X.parseTicketOfferAvailability=il,X.planAssignment=Ml,X.renderChartDocument=Rm,X.retryAfterCopy=Rl,X.selectionSources=Il,X.startBridge=Ym,X.stateBadge=zl,X.suggestMarker=no,X.ticketOfferPrices=sl,X.version=Km,X})({});typeof window!="undefined"&&window.seatlayer&&(window.seatmap=window.seatmap||window.seatlayer);
diff --git a/package.json b/package.json
index c01c14b..5d38121 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@seatlayer/react-native",
- "version": "0.1.3",
+ "version": "0.2.0",
"description": "Official React Native SDK for interactive SeatLayer reserved-seating maps on iOS and Android.",
"license": "MIT",
"homepage": "https://docs.seatlayer.io/buyer-sdk/mobile/",
@@ -35,14 +35,12 @@
],
"sideEffects": false,
"scripts": {
- "generate:web": "node scripts/generate-web-document.mjs",
- "prebuild": "pnpm generate:web",
"build": "tsup",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"lint:package": "publint && attw --pack .",
- "validate": "pnpm generate:web && pnpm typecheck && pnpm test && pnpm build && pnpm lint:package",
+ "validate": "pnpm typecheck && pnpm test && pnpm build && pnpm lint:package",
"prepublishOnly": "pnpm validate"
},
"peerDependencies": {
diff --git a/scripts/generate-web-document.mjs b/scripts/generate-web-document.mjs
deleted file mode 100644
index bb7249f..0000000
--- a/scripts/generate-web-document.mjs
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env node
-
-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
-import { dirname, resolve } from 'node:path';
-import { fileURLToPath } from 'node:url';
-
-const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
-const templatePath = resolve(root, 'assets/index.html');
-const bundlePath = resolve(root, 'assets/seatlayer.js');
-const outputPath = resolve(root, 'src/generated/webDocument.ts');
-const marker = '/*__SEATLAYER_BUNDLE__*/';
-
-const template = readFileSync(templatePath, 'utf8');
-if (!template.includes(marker)) {
- throw new Error(`Missing ${marker} in ${templatePath}`);
-}
-
-const bundle = readFileSync(bundlePath, 'utf8')
- .replaceAll('
>;
+const configurationIds = new WeakMap