@seatlayer/js 0.92.1 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -375,7 +375,7 @@ container: if you gave it a definite height — a fixed-height block, `height` /
375
375
  that block and tracks its size live via a `ResizeObserver`. If the container is
376
376
  content-sized (it collapses to whatever the iframe measures — typical full-page
377
377
  usage), the iframe instead grows so its bottom edge meets the bottom of the
378
- viewport. Either way the result is clamped to `minHeight` (default `480`), and the
378
+ viewport. Either way the result is clamped to `minHeight` (default `0`, so small containers stay within their bounds), and the
379
379
  verdict is re-probed on resize so a responsive layout can flip between the two. So
380
380
  you can either drop the Designer into a sized block (it fills the block) or give it
381
381
  `min-height: 760px` for full-page use (it fills the viewport). Every SDK-managed
@@ -390,7 +390,10 @@ while the Designer boots, then removes it the moment the iframe reports `ready`.
390
390
  If the session expires, the identity check fails, the iframe reports an error, or
391
391
  it never becomes ready, the host swaps in a dark **"Try again"** card with copy
392
392
  matched to the cause. The skeleton respects `prefers-reduced-motion` and adds no
393
- CSS files or external assets.
393
+ CSS files or external assets. It is deliberately **light**, matching the Designer
394
+ itself (which is light-only), so the hand-over from placeholder to editor never
395
+ flashes; a `theme` option for dark hosts is the follow-up once the Designer has a
396
+ dark mode.
394
397
 
395
398
  | Option | Type | Default | What it does |
396
399
  | --- | --- | --- | --- |
@@ -0,0 +1,58 @@
1
+ import"./chunk-OSZ7DOEH.js";var ae=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,se=/^[0-9 +()-]{6,20}$/,le=/^(\d{4})-(\d{2})-(\d{2})$/,ce=["required","invalid","too_long"],de=[["attendeeName","name","picker.bookingForm.name","Name"],["attendeeEmail","email","picker.bookingForm.email","Email"],["attendeePhone","phone","picker.bookingForm.phone","Phone"]],ue={email:"email",phone:"tel",number:"number",date:"date"};function ee(e){return e===void 0||e===""||e===!1||Array.isArray(e)&&!e.length}function pe(e,r,o,l){if(ee(o))return r?"required":null;let p=x=>!!l?.some(E=>E.id===x);if(e==="number")return typeof o=="number"&&Number.isFinite(o)?null:"invalid";if(e==="checkbox")return o===!0?null:"invalid";if(e==="select")return p(o)?null:"invalid";if(e==="multiselect")return Array.isArray(o)&&o.length<=50&&o.every(p)?null:"invalid";if(typeof o!="string")return"invalid";if(e==="phone")return se.test(o)?null:"invalid";if(o.length>500)return"too_long";if(e==="email")return ae.test(o)?null:"invalid";if(e==="date"){let x=le.exec(o);if(!x)return"invalid";let[E,F,B]=[Number(x[1]),Number(x[2]),Number(x[3])],w=new Date(Date.UTC(E,F-1,B));return w.getUTCFullYear()===E&&w.getUTCMonth()===F-1&&w.getUTCDate()===B?null:"invalid"}return null}function v(e,r,o){let l=document.createElement(e);return r&&(l.className=r),o!==void 0&&(l.textContent=o),l}function Z(e,r){let o=e?.[r];return o==="optional"||o==="required"?o:"off"}function te(e){let{form:r,t:o,idPrefix:l}=e,p=(r?.questions??[]).filter(n=>n&&!n.archived).sort((n,t)=>n.position-t.position),x=de.filter(([n])=>Z(r,n)!=="off"),E=p.filter(n=>n.scope==="ticket"),F=p.filter(n=>n.scope!=="ticket"),B=x.length>0||E.length>0;if(!B&&!F.length)return{element:null,validate:()=>!0,payload:()=>({}),showServerErrors:()=>!1};let w=[],A=[],S=v("div","sl-hco-bf"),K=v("div"),_=v("p","sl-hco-status sl-hco-error");_.setAttribute("role","alert"),_.hidden=!0;let U=0,R=(n,t)=>t==="required"?o("picker.bookingForm.required","This is required."):t==="too_long"?o("picker.bookingForm.tooLong","This is too long."):n==="email"?o("picker.bookingForm.invalidEmail","Enter a valid email address."):n==="phone"?o("picker.bookingForm.invalidPhone","Enter a valid phone number."):o("picker.bookingForm.invalid","Check this answer."),$=(n,t)=>{n.error.textContent=t?R(n.kind,t):"",n.error.hidden=!t;let i=n.kind==="multiselect"?n.control.closest("fieldset")??n.control:n.control;t?i.setAttribute("aria-invalid","true"):i.removeAttribute("aria-invalid")},X=(n,t)=>{let i=`${l}-bf${U++}`,c=v("div","sl-hco-field"),s=t.required?t.label:o("picker.bookingForm.optional","{label} (optional)",{label:t.label}),g=t.help?v("p","sl-hco-help",t.help):null;g&&(g.id=`${i}-h`);let h=v("p","sl-hco-ferr");h.id=`${i}-e`,h.hidden=!0;let C=y=>{y.setAttribute("aria-describedby",g?`${g.id} ${h.id}`:h.id),t.required&&y.tagName!=="FIELDSET"&&y.setAttribute("aria-required","true")},M;if(t.kind==="checkbox"||t.kind==="multiselect"){let y=t.kind==="multiselect"?v("fieldset","sl-hco-group"):null,k=y?t.options??[]:[{id:"",label:s}];y&&(y.appendChild(v("legend",void 0,s)),g&&y.appendChild(g),C(y));let T=k.map((b,I)=>{let P=v("label","sl-hco-check"),L=v("input");return L.type="checkbox",L.value=b.id,y?I===0&&(L.id=i):(L.id=i,C(L)),P.append(L,v("span",void 0,b.label)),(y??c).appendChild(P),L});y?c.appendChild(y):g&&c.appendChild(g),M={...t,control:T[0]??y??c,error:h,read:y?()=>T.filter(b=>b.checked).map(b=>b.value):()=>!!T[0]?.checked}}else{let y=v("label","sl-hco-label",s);y.htmlFor=i;let k;if(t.kind==="textarea")k=v("textarea","sl-hco-input"),k.rows=3,k.maxLength=500;else if(t.kind==="select"){k=v("select","sl-hco-input"),k.appendChild(new Option(o("picker.bookingForm.choose","Choose\u2026"),""));for(let b of t.options??[])k.appendChild(new Option(b.label,b.id))}else k=v("input","sl-hco-input"),k.type=ue[t.kind]??"text",t.kind==="number"?(k.step="any",k.inputMode="decimal"):t.kind!=="date"&&(k.maxLength=t.kind==="phone"?20:500),t.autocomplete&&(k.autocomplete=t.autocomplete);k.id=i,C(k),c.append(y,...g?[g]:[],k);let T=k;M={...t,control:k,error:h,read:()=>{let b=T.value.trim();return t.kind!=="number"?b:T.validity?.badInput?Number.NaN:b===""?void 0:Number(b)},write:b=>{T.value=b}}}c.appendChild(h);let Q=()=>$(M,null);return c.addEventListener("input",Q),c.addEventListener("change",Q),n.appendChild(c),w.push(M),M},N=(n,t,i)=>X(n,{key:`question:${t.id}`,...i!==void 0?{ticketKey:i}:{},kind:t.type,label:t.label,required:!!t.required,help:t.helpText,options:t.options}),q=n=>{if(A.includes(n.key))return;let t=!A.length;A.push(n.key);let i=v("fieldset","sl-hco-block");i.appendChild(v("legend","sl-hco-legend",n.title||o("picker.bookingForm.ticket","Ticket {number}",{number:A.length})));let c={};if(t&&x.some(([,s])=>s!=="phone")){let s=v("button","sl-hco-use",o("picker.bookingForm.useMyDetails","Use my details"));s.type="button",s.addEventListener("click",()=>{let g=e.buyer();for(let h of["name","email"]){let C=c[h];C&&g[h]&&(C.write?.(g[h]),$(C,null))}}),i.appendChild(s)}for(let[s,g,h,C]of x){let M=X(i,{key:s,ticketKey:n.key,kind:g,label:o(h,C),required:Z(r,s)==="required",autocomplete:"off"});g!=="phone"&&(c[g]=M)}for(let s of E)N(i,s,n.key);K.appendChild(i)};B&&e.tickets.forEach(q),S.appendChild(K);for(let n of F)N(S,n);S.appendChild(_);let D=n=>(_.textContent=n?o("picker.bookingForm.fix","Some details need attention."):"",_.hidden=!n,n?.control.focus(),!!n);return{element:S,validate(){let n=null;for(let t of w){let i=pe(t.kind,t.required,t.read(),t.options);$(t,i),i&&!n&&(n=t)}return!D(n)},payload(){let n=new Map,t=[];for(let i of w){let c=i.read();if(!ee(c)){if(i.key.startsWith("question:"))t.push({questionId:i.key.slice(9),...i.ticketKey!==void 0?{ticketKey:i.ticketKey}:{},value:c});else if(i.ticketKey!==void 0){let s=n.get(i.ticketKey)??{ticketKey:i.ticketKey},g=i.key==="attendeeName"?"name":i.key==="attendeeEmail"?"email":"phone";s[g]=String(c),n.set(i.ticketKey,s)}}}return{...n.size?{attendees:[...n.values()]}:{},...t.length?{answers:t}:{}}},showServerErrors(n){let t=(Array.isArray(n)?n:[]).filter(c=>!!c&&typeof c.key=="string");if(B){for(let c of t)typeof c.ticketKey=="string"&&!A.includes(c.ticketKey)&&q({key:c.ticketKey});w.sort((c,s)=>c.control.compareDocumentPosition(s.control)&4?-1:1)}let i=null;for(let c of w){let s=t.find(h=>h.key===c.key&&(h.ticketKey??void 0)===(c.ticketKey??void 0)),g=s?ce.includes(s.code)?s.code:"invalid":null;$(c,g),g&&!i&&(i=c)}return i?D(i):(_.textContent=o("picker.bookingForm.fix","Some details need attention."),_.hidden=!1,!1)}}}var he=9e4,ge=2e3,ne="https://checkout.razorpay.com/v1/checkout.js",oe="seatlayer-checkout-style",fe="@seatlayer/pending-checkout/v1";function me(e,r){try{window.sessionStorage.setItem(fe,JSON.stringify({orderId:e,...r?{eventKey:r}:{},storedAt:Date.now()}))}catch{}}var ke=`
2
+ /* The card is centred, but max-height:100% lets a long form reach the bottom
3
+ edge \u2014 and on the hosted buyer page that edge is the phone's edge, with the
4
+ Pay button last in the scroll. Reserve the home-indicator gutter here too.
5
+ --sl-safe-b is declared on .sl-picker, which this overlay lives inside, so it
6
+ inherits; it resolves to 0px in any host that is not inset. */
7
+ .sl-hco{position:absolute;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;
8
+ padding:16px 16px calc(16px + var(--sl-safe-b,0px));
9
+ background:color-mix(in srgb, var(--sl-bg) 82%, transparent);backdrop-filter:blur(3px)}
10
+ .sl-hco-card{width:100%;max-width:380px;max-height:100%;overflow:auto;padding:22px;
11
+ background:var(--sl-surface);color:var(--sl-text);border:1px solid var(--sl-line);
12
+ border-radius:var(--sl-radius);box-shadow:0 18px 48px rgba(0,0,0,.28)}
13
+ .sl-hco-title{margin:0 0 14px;font-size:19px;font-weight:650;letter-spacing:-.01em}
14
+ .sl-hco-summary{margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--sl-line)}
15
+ .sl-hco-seats{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
16
+ .sl-hco-seat{padding:3px 8px;font-size:12px;font-weight:600;border-radius:calc(var(--sl-radius) * .5);
17
+ background:var(--sl-bg);border:1px solid var(--sl-line)}
18
+ .sl-hco-total{display:flex;justify-content:space-between;align-items:baseline;font-size:14px}
19
+ .sl-hco-total strong{font-size:17px;font-weight:700}
20
+ .sl-hco-label{display:block;margin:12px 0 5px;font-size:12px;font-weight:600;color:var(--sl-muted)}
21
+ .sl-hco-input{width:100%;padding:10px 11px;font:inherit;font-size:15px;color:var(--sl-text);
22
+ background:var(--sl-bg);border:1px solid var(--sl-line);border-radius:calc(var(--sl-radius) * .55)}
23
+ .sl-hco-input:focus-visible{outline:2px solid var(--sl-accent);outline-offset:1px}
24
+ .sl-hco-pay{width:100%;margin-top:16px;padding:12px;font:inherit;font-size:15px;font-weight:650;
25
+ color:var(--sl-accent-ink);background:var(--sl-accent);border:0;
26
+ border-radius:calc(var(--sl-radius) * .55);cursor:pointer}
27
+ .sl-hco-pay[disabled]{opacity:.5;cursor:default}
28
+ .sl-hco-back{width:100%;margin-top:8px;padding:10px;font:inherit;font-size:14px;color:var(--sl-muted);
29
+ background:none;border:0;cursor:pointer;text-decoration:underline}
30
+ .sl-hco-note{margin:12px 0 0;font-size:12px;line-height:1.5;color:var(--sl-muted)}
31
+ .sl-hco-note a{color:inherit;text-decoration:underline;text-underline-offset:2px}
32
+ .sl-hco-status{margin:8px 0 0;font-size:14px;line-height:1.55}
33
+ .sl-hco-error{color:var(--sl-danger, #c0392b)}
34
+ .sl-hco-receipt{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;margin:14px 0 0;font-size:13px}
35
+ .sl-hco-receipt dt{color:var(--sl-muted)}
36
+ .sl-hco-receipt dd{margin:0;text-align:right}
37
+ .sl-hco-ref{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;word-break:break-all}
38
+ .sl-hco-tickets{display:block;width:100%;margin-top:14px;padding:12px;font:inherit;font-size:15px;
39
+ font-weight:650;text-align:center;text-decoration:none;color:var(--sl-accent-ink);
40
+ background:var(--sl-accent);border-radius:calc(var(--sl-radius) * .55)}
41
+ /* Booking form: one fieldset per ticket, then the booking's own questions.
42
+ Controls reuse .sl-hco-label/.sl-hco-input so a host theme reaches them. */
43
+ .sl-hco-block{min-width:0;margin:16px 0 0;padding:4px 12px 14px;border:1px solid var(--sl-line);
44
+ border-radius:calc(var(--sl-radius) * .55)}
45
+ .sl-hco-legend{padding:0 6px;font-size:13px;font-weight:650}
46
+ .sl-hco-use{margin:4px 0 0;padding:0;font:inherit;font-size:13px;font-weight:600;color:var(--sl-accent);
47
+ background:none;border:0;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
48
+ .sl-hco-help{margin:0 0 6px;font-size:12px;line-height:1.45;color:var(--sl-muted)}
49
+ .sl-hco-ferr{margin:5px 0 0;font-size:12px;line-height:1.4;color:var(--sl-danger, #c0392b)}
50
+ .sl-hco-input[aria-invalid="true"]{border-color:var(--sl-danger, #c0392b)}
51
+ textarea.sl-hco-input{min-height:72px;resize:vertical}
52
+ .sl-hco-group{min-width:0;margin:12px 0 0;padding:0;border:0}
53
+ .sl-hco-group legend{margin:0 0 5px;padding:0;font-size:12px;font-weight:600;color:var(--sl-muted)}
54
+ .sl-hco-group[aria-invalid="true"] legend{color:var(--sl-danger, #c0392b)}
55
+ .sl-hco-check{display:flex;gap:8px;align-items:flex-start;margin:8px 0 0;font-size:14px;line-height:1.4;cursor:pointer}
56
+ .sl-hco-check input{flex:none;width:18px;height:18px;margin:1px 0 0;accent-color:var(--sl-accent)}
57
+ .sl-hco-check input:focus-visible{outline:2px solid var(--sl-accent);outline-offset:2px}
58
+ `;function ye(){if(typeof document>"u"||document.getElementById(oe))return;let e=document.createElement("style");e.id=oe,e.textContent=ke,document.head.appendChild(e)}function be(e,r){let o=`${r} ${r===1?"seat is":"seats are"} held for a limited time.`;return e==="payments_off_for_event"?{title:"This event isn\u2019t sold online",body:`${o} The organiser isn\u2019t taking payment for this event here.`,detail:"Nothing has been charged. Check where you found this event for how to get tickets."}:e==="unavailable_for_event"?{title:"This event isn\u2019t taking payment yet",body:`${o} Online payment is not switched on for this event.`,detail:"Nothing has been charged. If you were sent here to pay, let the organiser know, only they can turn payment on for this event."}:{title:"Finish in the ticketing checkout",body:`${o} Payment for this event is taken elsewhere.`,detail:"Nothing has been charged. Continue in the checkout on this page to pay for your seats."}}var ve=3,xe=1,we=400,Ce=3e3;function re(e){if(!e||typeof e!="object")return!1;let r=e;return r.status!==503||r.code==="maintenance_mode"||r.reason==="maintenance_mode"?!1:r.code==="checkout_busy"||r.code==="database_busy"?!0:r.retryable===!0}function Ee(e,r=Math.random){let o=e?.retryAfterS,l=typeof o=="number"&&Number.isFinite(o)&&o>=0?o:xe,p=Math.floor(Math.max(0,Math.min(1,r()))*we);return Math.min(Ce,l*1e3+p)}function _e(e){return`${(typeof e?.notice=="string"?e.notice.trim():"")||(()=>{let l=e?.retryAfterS;if(typeof l!="number"||!Number.isFinite(l)||l<0)return"Booking is paused for a few minutes for maintenance. Please try again shortly.";let p=Math.max(1,Math.ceil(l/60));return`Booking is paused for maintenance. Please try again in about ${p} minute${p===1?"":"s"}.`})()} Nothing was charged. Your seats are still held.`}function Y(e,r){if(e==="maintenance_mode")return _e(r);switch(e){case"checkout_busy":case"database_busy":return r?.free?"We couldn\u2019t confirm your booking yet because it\u2019s very busy. Nothing was charged. Please try again.":"We couldn\u2019t start the payment yet because it\u2019s very busy. Nothing was charged. Please try again.";case"gateway_not_connected":case"payments_not_enabled_for_event":return"This event is not taking online payments. Contact the organiser to buy these seats.";case"provider_mismatch":return"This event\u2019s payment setup changed while you were choosing. Nothing was charged. Please try again.";case"hold_not_active":case"hold_not_found":return"Your seats were released before checkout started. Nothing was charged. Please pick again.";case"checkout_already_started":return"A payment for these seats is already in progress. Finish that one, or wait for it to time out before starting again.";case"event_closed":return"Sales for this event have closed.";case"insufficient_hosted_credits":return"Ticket sales are temporarily paused while the organiser updates their SeatLayer balance. Nothing was charged. Please try again later or contact the organiser.";case"gateway_currency_mismatch":case"unsupported_currency":case"mixed_currency_hold":case"price_unusable":return"These seats cannot be checked out right now because of a pricing configuration problem. Nothing was charged. Please contact the organiser.";case"provider_refused":return"The organiser\u2019s payment provider refused to start this payment. Nothing was charged. Please contact the organiser.";case"rate_limited":return"Too many attempts. Wait a moment and try again.";case"seats_unavailable":return"Those seats were taken while you were filling this in. Nothing was charged. Please pick again.";case"booking_form_incomplete":return"The details this event asks for changed while you were choosing. Nothing was charged. Please go back and try again.";default:return"We could not start the payment. Nothing was charged. Please try again."}}function Te(){let e=window.Razorpay;return e?Promise.resolve(e):new Promise((r,o)=>{let l=document.querySelector(`script[src="${ne}"]`),p=l??document.createElement("script"),x=()=>{let E=window.Razorpay;E?r(E):o(new Error("razorpay_unavailable"))};p.addEventListener("load",x,{once:!0}),p.addEventListener("error",()=>o(new Error("razorpay_script_failed")),{once:!0}),!l&&(p.src=ne,p.async=!0,document.head.appendChild(p))})}function a(e,r,o){let l=document.createElement(e);return r&&(l.className=r),o!==void 0&&(l.textContent=o),l}function Me(e){ye();let r=!0,o=!1,l=(u,f,m)=>{let d=e.t?.(u,m);return d&&d!==u?d:m?f.replace(/\{(\w+)\}/g,(z,H)=>H in m?String(m[H]):z):f},p=a("div","sl-hco");p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true");let x=a("div","sl-hco-card");p.appendChild(x);let E=()=>{r=!1,p.remove(),document.removeEventListener("keydown",B,!0)},F=()=>{E(),e.onCancel()};function B(u){u.key!=="Escape"||!p.isConnected||(u.stopPropagation(),u.preventDefault(),F())}document.addEventListener("keydown",B,!0);let w=a("h2","sl-hco-title","Checkout"),A=`sl-hco-t-${Math.random().toString(36).slice(2,8)}`;w.id=A,p.setAttribute("aria-labelledby",A);let S=(...u)=>{x.replaceChildren(w,...u)},K=u=>{if(!r)return;let f=a("p","sl-hco-status sl-hco-error",u);f.setAttribute("role","alert");let m=a("button","sl-hco-back","Back to seats");m.type="button",m.addEventListener("click",F),S(f,m)},_=u=>{if(!r)return;let f=a("p","sl-hco-status",u);f.setAttribute("role","status"),S(f)},U=async(u,f=!1)=>{_(f?l("checkout.confirmingSeats","Confirming your seats\u2026"):"Payment received. Confirming your seats\u2026");let m=Date.now()+he;for(;r&&Date.now()<m;){try{let d=await e.orderStatus(u);if(!r)return;if(d.status==="confirmed"){o=!0,w.textContent="Your tickets are confirmed";let z=a("p","sl-hco-status",`${d.seatCount} ${d.seatCount===1?"seat":"seats"} confirmed. Your tickets, with their door QR codes, are in your email.`),H=a("dl","sl-hco-receipt"),G=(d.tickets??[]).map(O=>O.displayLabel||O.label);G.length&&H.append(a("dt",void 0,"Seats"),a("dd",void 0,G.join(", ")));let J=f||d.totalMinor===0;H.append(a("dt",void 0,J?l("checkout.price","Price"):"Paid"),a("dd",void 0,J?l("checkout.free","Free"):`${d.amountFormatted} ${d.currency}`),a("dt",void 0,"Order"),a("dd","sl-hco-ref",d.orderId));let W=a("button","sl-hco-back","Close");if(W.type="button",W.addEventListener("click",F),d.ticketUrl){let O=a("a","sl-hco-tickets","View tickets & QR codes");O.href=d.ticketUrl,O.target="_blank",O.rel="noreferrer",S(z,H,O,W)}else S(z,H,W);e.onConfirmed(d);return}if(d.status==="failed"||d.status==="expired"){K(d.status==="expired"?"Your seats were released before payment completed. Nothing was charged. Please pick again.":"The payment did not complete. If you were charged, it has been refunded automatically.");return}}catch{}await new Promise(d=>setTimeout(d,ge))}!r||o||K(f?"Still confirming your booking. Once it is confirmed, your tickets will arrive by email. Nothing was charged.":"Still confirming with the payment provider. If your payment went through, your tickets will arrive by email shortly. You do not need to pay again.")};if(e.state.kind==="unavailable"){let u=be(e.state.reason,e.state.seatCount);w.textContent=u.title;let f=a("p","sl-hco-label","Seats held"),m=a("button","sl-hco-back","Back to seat map");return m.type="button",m.addEventListener("click",F),x.replaceChildren(f,w,a("p","sl-hco-status",u.body),a("p","sl-hco-note",u.detail),m),e.root.appendChild(p),m.focus(),{destroy:E}}if(e.state.kind==="resume")return e.root.appendChild(p),U(e.state.orderId),{destroy:E};let{order:R,provider:$,bookingForm:X}=e.state,N=e.state.free===!0,q=a("div","sl-hco-summary"),D=a("div","sl-hco-seats");for(let u of R.labels)D.appendChild(a("span","sl-hco-seat",u));let n=N?l("checkout.free","Free"):e.formatMoney(R.total,R.currency),t=a("div","sl-hco-total");t.append(a("span",void 0,"Total"),a("strong",void 0,n)),q.append(D,t);let i=a("form","sl-hco-form");i.noValidate=!0;let c=a("label","sl-hco-label","Email: your tickets go here"),s=a("input","sl-hco-input");s.type="email",s.required=!0,s.autocomplete="email",s.placeholder="you@example.com",s.id=`${A}-email`,c.htmlFor=s.id;let g=a("label","sl-hco-label","Name (optional)"),h=a("input","sl-hco-input");h.type="text",h.autocomplete="name",h.placeholder="Your name",h.id=`${A}-name`,g.htmlFor=h.id;let C=a("button","sl-hco-pay",N?l("checkout.confirmBooking","Confirm booking"):`Pay ${n}`);C.type="submit",C.disabled=!0;let M=a("button","sl-hco-back","Back to seats");M.type="button",M.addEventListener("click",F);let Q=new Date(R.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),y=a("p","sl-hco-note",N?`Your seats are held until ${Q}. ${l("checkout.freeNote","This event is free. Nothing is charged.")}`:`Your seats are held until ${Q}. Payment is handled by ${$==="razorpay"?"Razorpay":"Stripe"}. We never see your card details.`),k=a("p","sl-hco-note");k.append("The event organizer and SeatLayer use your email to issue and manage your tickets. ");let T=a("a",void 0,"Privacy Policy");T.href="https://seatlayer.io/privacy/",T.target="_blank",T.rel="noreferrer",k.appendChild(T);let b=()=>/.+@.+\..+/.test(s.value.trim());s.addEventListener("input",()=>{C.disabled=!b()});let I=te({form:X,tickets:R.tickets??[],idPrefix:A,t:l,buyer:()=>({name:h.value.trim(),email:s.value.trim()})}),P=a("p","sl-hco-status sl-hco-error");P.setAttribute("role","alert"),P.hidden=!0;let L=u=>{P.textContent=u,P.hidden=!1},j=!1,ie=async()=>{if(!j){j=!0,C.disabled=!0,_(N?l("checkout.confirmingBooking","Confirming your booking\u2026"):"Opening secure payment\u2026");try{let u={holdId:R.holdId,buyerEmail:s.value.trim(),...h.value.trim()?{buyerName:h.value.trim()}:{},...I.payload(),bookingFormVersion:1},f=0,m;for(;;)try{m=await e.startSession(u);break}catch(d){if(!r)return;if(f>=ve||!re(d))throw d;if(f+=1,_(N?l("checkout.busyRetryingBooking","Busy right now. Still confirming your booking\u2026"):l("checkout.busyRetryingPayment","Busy right now. Still opening secure payment\u2026")),await new Promise(z=>setTimeout(z,Ee(d))),!r)return}if(!r)return;if(m.status==="confirmed"){U(m.orderId,!0);return}if(m.redirectUrl){me(m.orderId,e.eventKey),_("Taking you to secure payment\u2026"),window.location.assign(m.redirectUrl);return}if(m.clientPayload){let d=m.clientPayload,z=await Te();if(!r)return;_("Waiting for payment\u2026"),new z({key:d.key,order_id:d.orderId,amount:d.amount,currency:d.currency,name:d.name,prefill:d.prefill,handler:()=>{U(m.orderId)},modal:{ondismiss:()=>{r&&V()}}}).open();return}K(Y("gateway_unavailable"))}catch(u){e.onError?.(u);let f=u;if(f?.code==="booking_form_incomplete"&&I.element){V(),I.showServerErrors(f.fields);return}if(re(f)){V(),L(N?l("checkout.busyFailedBooking",Y("checkout_busy",{free:!0})):l("checkout.busyFailedPayment",Y("checkout_busy")));return}K(f?.code==="seats_unavailable"?l("checkout.seatsUnavailable",Y(f.code)):Y(f?.code,f))}}};i.addEventListener("submit",u=>{u.preventDefault(),b()&&I.validate()&&ie()}),i.append(c,s,g,h),I.element&&i.appendChild(I.element),i.append(k,P,C,M,y);let V=()=>{w.textContent="Checkout",P.hidden=!0,P.textContent="",j=!1,S(q,i),C.disabled=!b()};return V(),e.root.appendChild(p),s.focus(),{destroy:E}}export{ve as CHECKOUT_BUSY_MAX_RETRIES,Ee as checkoutBusyDelayMs,Y as errorCopy,re as isCheckoutBusy,Me as mountCheckout,be as unavailableCopy};