1import{X as je,dw as te,dx as ie,j as e,A as fe,I as S,e as C,dy as le,r as i,dz as Ne,dA as ye,o as L,dB as H,S as V,dC as re,W as q,aJ as be,aH as ve,au as ee,k as ke,aQ as we,dD as Se,l as ae,at as Ce}from"./index-BokBcvef.js";import{C as K}from"./Card-DuADMCgg.js";import{B as oe}from"./Banner-LYMtZ1YA.js";import{s as a,r as Be,f as Me,B as G,c as Ee,a as Fe}from"./PublicBookingApp-CJCGju-1.js";import{i as Le,s as se,g as Te,a as De,b as Re,c as Ae}from"./booking-copy-C96BGLSR.js";import{B as ze,C as ce,i as $e}from"./booking-types-rHJx1g2H.js";import{S as I}from"./Skeleton-fQvEY9Jq.js";function P(s,n,t){const r=te(s);return r?ie({l:n,c:t,h:r.h}):s}function Ie(s,n){const t=je[s]?.day.colorAccent??ze[s],r=n==="dark",c=r?(()=>{const u=te(t);return u?ie({...u,l:Math.max(u.l+.115,.66)}):t})():t;return{"--bk-slab":P(t,r?.21:.32,r?.03:.055),"--bk-slab-ink":P(t,r?.94:.95,.015),"--bk-slab-acc":r?c:P(t,.78,.11),"--bk-slab-line":P(t,r?.34:.42,r?.03:.045)}}function Pe({link:s}){const n=s.theme.layout;return e.jsxs("aside",{className:a.panel,"data-layout":n,children:[s.workspace.logoUrl?e.jsx("img",{className:a.logo,src:s.workspace.logoUrl,alt:s.workspace.name}):e.jsx("div",{className:a.wordmark,children:s.workspace.name}),e.jsxs("div",{className:a.repRow,children:[e.jsx(fe,{name:s.rep.name,src:s.rep.avatarUrl??void 0,size:"xl"}),e.jsxs("div",{children:[e.jsx("div",{className:a.repName,children:s.rep.name}),s.rep.role&&e.jsx("div",{className:a.repRole,children:s.rep.role})]})]}),e.jsx("h1",{className:a.eventTitle,children:s.title}),e.jsxs("div",{className:a.meta,children:[e.jsxs("div",{className:a.metaLine,children:[e.jsx(S,{name:"clock",size:C.sm}),s.durationMinutes," minutes"]}),s.conferencing&&e.jsxs("div",{className:a.metaLine,children:[e.jsx(S,{name:"video-camera",size:C.sm}),ce[s.conferencing]]}),e.jsxs("div",{className:a.metaLine,children:[e.jsx(S,{name:"globe",size:C.sm}),s.timezone,", ",le(s.timezone)]})]}),s.description&&e.jsx("p",{className:a.description,children:s.description}),s.workspace.tagline&&e.jsx("div",{className:a.panelFooter,children:s.workspace.tagline})]})}function He({weekStart:s,month:n,horizonDays:t,days:r,loading:c,selectedDate:u,selectedSlot:m,durationMinutes:v,repName:g,visitorTimezone:y,clockFormat:x,onMonth:j,onSelectDate:N,onSelectSlot:p}){const b=i.useMemo(()=>Ne(n.getFullYear(),n.getMonth(),s),[n,s]),M=i.useMemo(()=>ye(s),[s]),E=i.useMemo(()=>{const o=new Map;for(const k of r)o.set(k.dateKey,k);return o},[r]),f=u?E.get(u):void 0,h=new Date,Y=n.getFullYear()===h.getFullYear()&&n.getMonth()===h.getMonth(),D=new Date(h.getTime()+t*864e5),_=n.getFullYear()>D.getFullYear()||n.getFullYear()===D.getFullYear()&&n.getMonth()>=D.getMonth(),z=i.useMemo(()=>new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:x==="12h",timeZone:y}),[x,y]);function W(o){if(c)return e.jsx(I,{shape:"circle",width:36,height:36});const w=(E.get(o.iso)?.slots.length??0)>0,l=w?u===o.iso?"selected":"bookable":"unavailable";return e.jsx(L,{variant:l==="unavailable"?"ghost":"secondary",size:"md",circular:!0,selected:l==="selected",disabled:!w,sound:!1,"aria-label":H(o.date.toISOString(),y),onClick:()=>N(o.iso),children:o.day})}return e.jsxs("div",{className:a.pick,children:[e.jsxs("div",{className:a.calendarCol,children:[e.jsxs("div",{className:a.monthRow,children:[e.jsx("span",{className:a.monthLabel,children:n.toLocaleDateString(void 0,{month:"long",year:"numeric"})}),e.jsxs("span",{className:a.monthNav,children:[e.jsx(L,{variant:"secondary",size:"sm",circular:!0,disabled:Y,"aria-label":"Previous month",icon:e.jsx(S,{name:"caret-left",size:C.sm}),onClick:()=>j(-1)}),e.jsx(L,{variant:"secondary",size:"sm",circular:!0,disabled:_,"aria-label":"Next month",icon:e.jsx(S,{name:"caret-right",size:C.sm}),onClick:()=>j(1)})]})]}),e.jsx("div",{className:a.weekHeader,"aria-hidden":"true",children:M.map((o,k)=>e.jsx("span",{className:a.weekLabel,children:o},`${o}-${k}`))}),e.jsx("div",{className:a.dayGrid,role:"grid","aria-label":"Available dates",children:b.map(o=>e.jsx("div",{className:a.dayCellWrap,children:o.otherMonth?null:W(o)},o.iso))}),e.jsxs("div",{className:a.legend,children:[e.jsxs("span",{className:a.legendItem,children:[e.jsx("span",{className:`${a.legendDot} ${a.legendOpen}`})," open"]}),e.jsxs("span",{className:a.legendItem,children:[e.jsx("span",{className:`${a.legendDot} ${a.legendChosen}`})," chosen"]})]})]}),e.jsx(K,{className:a.slotCol,padding:"md",flat:!0,children:c?e.jsxs("div",{className:a.slotSkeleton,children:[e.jsxs("div",{className:a.slotSkeletonHead,children:[e.jsx(I,{variant:"text-sm",width:"65%"}),e.jsx(I,{variant:"text-sm",width:"40%"})]}),e.jsx("div",{className:a.slotList,children:Array.from({length:5},(o,k)=>e.jsx(I,{shape:"rounded",height:44},k))})]}):f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:a.slotDate,children:H(`${f.dateKey}T12:00:00Z`,y)}),e.jsxs("div",{className:a.slotCount,children:[f.slots.length," ",f.slots.length===1?"time":"times"," ·"," ",v," min"]}),e.jsx(V,{className:a.slotScroll,children:e.jsx("div",{className:a.slotList,children:f.slots.map(o=>e.jsx(L,{variant:"secondary",size:"lg",selected:m===o,onClick:()=>p(o),children:z.format(new Date(o))},o))})})]}):e.jsxs("div",{className:a.slotEmpty,children:["Pick a day to see the times ",g," is free."]})})]})}const ne="recaptcha-v2",Ye="https://www.google.com/recaptcha/api.js?render=explicit";let A=null;function _e(){return A||(A=new Promise((s,n)=>{if(document.getElementById(ne))return s();const t=document.createElement("script");t.id=ne,t.src=Ye,t.async=!0,t.defer=!0,t.onload=()=>s(),t.onerror=()=>{A=null,n(new Error("Could not load the verification check."))},document.head.appendChild(t)}),A)}function We(s,n){const[t,r]=i.useState(null),[c,u]=i.useState(!1),[m,v]=i.useState(null),g=i.useRef(null),y=i.useRef(null),x=i.useCallback(()=>
1{const p=y.current;if(!(!s||!p||!window.grecaptcha||g.current!==null))try{g.current=window.grecaptcha.render(p,{sitekey:s,theme:n,callback:b=>r(b),"expired-callback":()=>r(null)}),u(!0)}catch{v("Could not show the verification check.")}},[s,n]);i.useEffect(()=>{if(!s)return;let p=!1;return _e().then(()=>{if(p)return;const b=()=>{p||x()};window.grecaptcha?.ready?window.grecaptcha.ready(b):b()}).catch(b=>{p||v(b.message)}),()=>{p=!0}},[s,x]);const j=i.useCallback(p=>{y.current=p,p&&window.grecaptcha&&x()},[x]),N=i.useCallback(()=>{r(null),g.current!==null&&window.grecaptcha?.reset(g.current)},[]);return{ref:j,token:t,ready:c,error:m,reset:N}}function Oe(s){const n=s.trim().toLowerCase();return $e(n)?{valid:!0,error:null,normalised:n}:{valid:!1,error:"That does not look like an email address",normalised:null}}function qe({onBack:s}){return e.jsx(L,{variant:"ghost",size:"sm",icon:e.jsx(S,{name:"arrow-left",size:C.sm}),onClick:s,children:"Change time"})}function Ge({link:s,slotIso:n,visitorTimezone:t,submitting:r,error:c,capNotice:u,values:m,onChange:v,onSubmit:g}){const[y,x]=i.useState(!1),j=We(s.recaptchaSiteKey,s.theme.mode);i.useEffect(()=>{c&&j.reset()},[c]);const N=i.useMemo(()=>new Date(new Date(n).getTime()+s.durationMinutes*6e4).toISOString(),[n,s.durationMinutes]),p=m.guests,b=Le(m),M=!s.recaptchaSiteKey||!!j.token,E=b&&M&&!r,f=h=>v({...m,...h});return e.jsxs("div",{className:a.details,children:[u&&e.jsx("div",{className:a.capNotice,children:e.jsx(oe,{variant:"warning",role:"alert",children:u})}),e.jsx(V,{className:a.detailsScroll,children:e.jsxs("div",{className:a.detailsBody,children:[e.jsxs("div",{className:a.chosen,children:[e.jsxs("div",{className:a.chosenWhen,children:[H(n,t),","," ",re(n,N,t)]}),e.jsxs("div",{className:a.chosenMeta,children:[s.durationMinutes," minutes",s.conferencing?` · ${ce[s.conferencing]}`:"",` · ${t}, ${le(t)}`]})]}),e.jsxs("div",{className:a.form,children:[e.jsxs("div",{children:[e.jsxs("label",{className:a.fieldLabel,htmlFor:"booking-name",children:["Name ",e.jsx("span",{className:a.required,children:"*"})]}),e.jsx(q,{id:"booking-name",value:m.name,placeholder:"Your name",autoComplete:"name",onChange:h=>f({name:h})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:a.fieldLabel,htmlFor:"booking-email",children:["Work email ",e.jsx("span",{className:a.required,children:"*"})]}),e.jsx(q,{id:"booking-email",inputType:"email",value:m.email,placeholder:"[email protected]",autoComplete:"email",onChange:h=>f({email:h})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:a.fieldLabel,htmlFor:"booking-company",children:["Company ",e.jsx("span",{className:a.required,children:"*"})]}),e.jsx(q,{id:"booking-company",value:m.company,placeholder:"New Co",autoComplete:"organization",onChange:h=>f({company:h})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:a.fieldLabel,htmlFor:"booking-topic",children:["What would you like to talk about?"," ",e.jsx("span",{className:a.required,children:"*"})]}),e.jsx(be,{id:"booking-topic",rows:3,autoExpand:!0,value:m.topic,placeholder:"A line or two on what youâd like to cover.",onChange:h=>f({topic:h.target.value})})]}),e.jsxs("div",{children:[e.jsxs("span",{className:a.fieldLabel,id:"booking-guests-label",children:["Anyone else to invite?",e.jsx("span",{className:a.optional,children:" · optional"})]}),e.jsx(ve,{"aria-labelledby":"booking-guests-label",values:p,onChange:h=>f({guests:h}),placeholder:"[email protected]",validate:Oe})]}),s.recaptchaSiteKey&&e.jsxs("div",{className:a.captcha,children:[e.jsx("div",{className:a.captchaWidget,ref:j.ref}),j.error&&e.jsx(ee,{message:j.error})]}),c&&e.jsx(ee,{message:c})]})]})}),e.jsxs("div",{className:a.submitRow,children:[b&&!M?e.jsx("span",{className:a.submitHint,children:"Tick the box above so we know you are a person."}):se(m)&&e.jsx("span",{className:a.submitHint,children:se(m)}),e.jsx(L,{variant:"primary",size:"lg",disabled:!E,loading:r,icon:e.jsx(S,{name:"calendar-check",size:C.md}),onClick:()=>{x(!0),E&&g(p,j.token)},children:"Confirm booking"})]})]})}function Ve({link:s,result:n,bookerName:t,bookerEmail:r,guests:c,visitorTimezone:u}){const m=Te(c);return e.jsxs("div",{className:a.confirmed,children:[e.jsxs("div",{className:a.confirmedHead,children:[e.jsx("div",{className:a.tick,children:e.jsx(S,{name:"check",size:C.xl})}),e.jsxs("div",{children:[e.jsx("h2",{className:a.confirmedHeading,children:"Youâre booked."}),e.jsxs("p",{className:a.confirmedBody,children:["Weâve emailed ",r,n.conferenceUrl?` with the ${n.conferencing} link`:"",", and itâs on"," ",n.repName,"âs calendar.",m?` ${m}`:""]})]})]}),e.jsxs(K,{className:a.receipt,padding:"none",flat:!0,children:[e.jsxs("div",{className:a.receiptHead,children:[e.jsxs("div",{className:a.chosenWhen,children:[H(n.start,u),","," ",re(n.start,n.end,u)]}),e.jsxs("div",{className:a.chosenMeta,children:[s.title," with ",n.repName," · ",s.durationMinutes," minutes"]})]}),e.jsxs("div",{className:a.receiptBody,children:[n.conferenceUrl&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:a.receiptLabel,children:"Where"}),e.jsxs("span",{className:a.receiptValue,children:[n.conferencing," â link in the invite"]})]}),e.jsx("span",{className:a.receiptLabel,children:"Who"}),e.jsx("span",{className:a.receiptValue,children:De(t,c.length,n.repName)}),e.jsx("span",{className:a.receiptLabel,children:"Calendar"}),e.jsxs("span",{className:a.receiptValue,children:["Added to ",n.repName,"âs work calendar"]})]})]})]})}function Ke({repName:s}){const n=s.trim()||"This person";return e.jsx("div",{className:a.gateShell,children:e.jsxs("div",{className:a.gate,children:[e.jsx("h1",{className:a.gateHeading,children:"Not taking bookings yet"}
1),e.jsxs("p",{className:a.gateBody,children:[n," isnât taking bookings right now, so there are no times to show."]})]})})}function Ue({repName:s,retrying:n,onRetry:t}){return e.jsxs("div",{className:a.availabilityError,role:"alert",children:[e.jsx("div",{className:a.availabilityMark,"aria-hidden":"true",children:e.jsx(S,{name:"calendar-slash",size:C.xl})}),e.jsx("h2",{className:a.availabilityHeading,children:"Times arenât loading right now"}),e.jsx("p",{className:a.availabilityBody,children:Re(s)}),e.jsx(L,{className:a.availabilityRetry,variant:"primary",size:"lg",loading:n,onClick:t,children:"Try again"})]})}const Qe={name:"",email:"",company:"",topic:"",guests:[]};function ta(){const{handle:s="",eventSlug:n=""}=ke(),t=i.useMemo(()=>we(),[]),r=i.useMemo(()=>Se(),[]),[c,u]=i.useState(()=>{const d=new Date;return new Date(d.getFullYear(),d.getMonth(),1)}),[m,v]=i.useState(null),[g,y]=i.useState(null),[x,j]=i.useState("pick"),[N,p]=i.useState(Qe),[b,M]=i.useState(!1),[E,f]=i.useState(null),[h,Y]=i.useState(null),[D,_]=i.useState([]),[z,W]=i.useState(null),[o,k]=i.useState(null),w=ae({queryKey:["booking","link",s,n],queryFn:()=>Be(s,n),retry:!1,staleTime:6e4}),l=w.data,O=`${c.getFullYear()}-${String(c.getMonth()+1).padStart(2,"0")}`,B=ae({queryKey:["booking","availability",s,n,O],queryFn:()=>{const d=`${O}-01`,F=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();return Me(s,n,d,`${O}-${F}`,t)},enabled:!!l?.available,retry:!1,staleTime:3e4});i.useEffect(()=>{if(!l)return;const d=Ie(l.theme.accent,l.theme.mode),F=document.documentElement;for(const[T,R]of Object.entries(d))F.style.setProperty(T,R)},[l]),i.useEffect(()=>{l&&(document.title=`${l.title} · ${l.rep.name}`)},[l]);const $=B.data?.days??[],de=B.error instanceof G&&B.error.code==="calendar_reauth_required",[U,Q]=i.useState(!1),me=!!B.error||U,{refetch:Z}=B,he=i.useCallback(async()=>{Q(!0);try{await Z()}finally{Q(!1)}},[Z]);i.useEffect(()=>{if(m||$.length===0)return;const d=$.find(F=>F.slots.length>0);d&&v(d.dateKey)},[$,m]);const ue=i.useCallback(d=>{v(d),y(null)},[]),pe=i.useCallback(d=>{y(d),f(null),j("details")},[]),ge=i.useCallback(async(d,F)=>{if(g){M(!0),f(null),k(null);try{const T=await Ee(s,n,{start:g,name:N.name.trim(),email:N.email.trim().toLowerCase(),company:N.company.trim(),topic:N.topic.trim(),guests:d,recaptchaToken:F??void 0,visitorTimezone:t});Y(T),_(d),j("done")}catch(T){const R=T instanceof G?T:null;R?.code==="slot_taken"?(y(null),j("pick"),f(null),await B.refetch(),W("Someone just took that time. Here's what's still free.")):R?.code==="booking_cap"?k(Ae(l?.rep.name??"")):f(R?.message??"Could not book that time. Try again.")}finally{M(!1)}}},[s,n,g,N,t,B,l?.rep.name]);if(w.isPending)return e.jsx(Fe,{});if(w.error||!l){const d=w.error instanceof G&&w.error.status===404;return e.jsx("div",{className:a.shell,children:e.jsx(Ce,{message:d?"That booking link does not exist.":"We could not load this booking link. Try again in a moment.",onRetry:d?void 0:()=>{w.refetch()}})})}if(!l.available||de)return e.jsx(Ke,{repName:l.rep.name});const xe=x==="done",X=x==="done"?"pane":x==="details"?"details":"slots",J=x==="done"&&h?e.jsx(Ve,{link:l,result:h,bookerName:N.name.trim(),bookerEmail:N.email.trim().toLowerCase(),guests:D,visitorTimezone:t}):x==="details"&&g?e.jsx(Ge,{link:l,slotIso:g,visitorTimezone:t,submitting:b,error:E,capNotice:o,values:N,onChange:p,onSubmit:ge}):e.jsxs(e.Fragment,{children:[z&&e.jsx(oe,{variant:"warning",className:a.pickBanner,children:z}),me?e.jsx(Ue,{repName:l.rep.name,retrying:U,onRetry:he}):e.jsx(He,{weekStart:l.weekStart,month:c,horizonDays:l.horizonDays,days:$,loading:B.isPending,selectedDate:m,selectedSlot:g,durationMinutes:l.durationMinutes,repName:l.rep.name,visitorTimezone:t,clockFormat:r,onMonth:d=>{u(new Date(c.getFullYear(),c.getMonth()+d,1)),v(null),y(null)},onSelectDate:ue,onSelectSlot:pe})]});return e.jsx("div",{className:a.shell,"data-layout":l.theme.layout,children:e.jsxs(K,{className:a.card,"data-layout":l.theme.layout,padding:"none",flat:l.theme.layout==="slab",children:[e.jsx(Pe,{link:l}),e.jsxs("div",{className:a.paneShell,children:[x==="details"&&g&&e.jsx("div",{className:a.paneHeader,children:e.jsx(qe,{onBack:()=>j("pick")})}),xe?e.jsx(V,{className:a.paneScroll,children:e.jsx("main",{className:a.pane,"data-scroll":X,children:J})}):e.jsx("main",{className:a.pane,"data-scroll":X,children:J})]})]})})}export{ta as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.