mirror of
https://github.com/hanzoai/agency.git
synced 2026-11-02 19:13:28 +00:00
3 lines
21 KiB
Plaintext
3 lines
21 KiB
Plaintext
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./client.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=`hanzo-waitlist:`,i=`hanzo-waitlist:ref`;function a(e){return r+e}function o(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(a(e));if(!t)return null;let n=JSON.parse(t);return n?.email?{email:n.email,rank:n.rank,refCode:n.refCode}:null}catch{return null}}function s(e,t){if(!(typeof localStorage>`u`)){try{localStorage.setItem(a(e),JSON.stringify(t))}catch{}typeof window<`u`&&window.dispatchEvent(new CustomEvent(`hanzo-waitlist:change`,{detail:{slug:e}}))}}function c(e){if(!(typeof localStorage>`u`)){try{localStorage.removeItem(a(e))}catch{}typeof window<`u`&&window.dispatchEvent(new CustomEvent(`hanzo-waitlist:change`,{detail:{slug:e}}))}}function l(){if(!(typeof window>`u`))try{let e=new URLSearchParams(window.location.search).get(`ref`);e&&localStorage.setItem(i,e)}catch{}}function u(){if(!(typeof localStorage>`u`))try{return localStorage.getItem(i)??void 0}catch{return}}function d(e){let[n,r]=(0,t.useState)(()=>o(e));return(0,t.useEffect)(()=>{r(o(e));let t=t=>{let n=t.detail?.slug;n&&n!==e||r(o(e))},n=t=>{t.key===a(e)&&r(o(e))};return window.addEventListener(`hanzo-waitlist:change`,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(`hanzo-waitlist:change`,t),window.removeEventListener(`storage`,n)}},[e]),n}var f=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function p(r){let{waitlist:i,baseUrl:a,title:o=`Join the waitlist`,subtitle:s,submitLabel:c=`Join`,turnstileToken:l,email:d,onSuccess:p,onError:m}=r,h=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:a}),[a]),[g,_]=(0,t.useState)(d??``),[v,y]=(0,t.useState)(!1),[b,x]=(0,t.useState)(null),S=(0,t.useCallback)(async e=>{if(e?.preventDefault(),v)return;let t=g.trim().toLowerCase();if(!f.test(t)){let e=`Enter a valid email address.`;x(e),m?.({message:e,status:0});return}y(!0),x(null);let n=await h.join({waitlist:i,email:t,referrerCode:u(),turnstileToken:l});if(`ok`in n&&n.ok){y(!1),p?.(n);return}let r=n.message||`Something went wrong. Try again.`;x(r),m?.({message:r,status:n.status}),y(!1)},[v,h,g,m,p,l,i]);return(0,n.jsxs)(`form`,{onSubmit:S,noValidate:!0,children:[(0,n.jsx)(`h3`,{className:`hanzo-waitlist__title`,children:o}),s&&(0,n.jsx)(`p`,{className:`hanzo-waitlist__subtitle`,children:s}),(0,n.jsxs)(`div`,{className:`hanzo-waitlist__row`,children:[(0,n.jsx)(`input`,{className:`hanzo-waitlist__input`,type:`email`,inputMode:`email`,autoComplete:`email`,placeholder:`[email protected]`,value:g,onChange:e=>_(e.currentTarget.value),disabled:v,"aria-label":`Email address`,required:!0}),(0,n.jsx)(`button`,{type:`submit`,className:`hanzo-waitlist__button`,disabled:v||!g,children:v?`…`:c})]}),b&&(0,n.jsx)(`p`,{className:`hanzo-waitlist__error`,role:`alert`,children:b})]})}var m=[`webshare`,`email`,`x`,`linkedin`,`facebook`,`reddit`,`telegram`,`whatsapp`,`sms`,`copy`],h={webshare:{label:`Share`,href:()=>null,onClick:async({url:e,text:t})=>{if(typeof navigator<`u`&&`share`in navigator)try{await navigator.share({text:t,url:e})}catch{}}},email:{label:`Email`,href:({url:e,text:t})=>`mailto:?subject=Join%20the%20waitlist&body=${encodeURIComponent(`${t}\n\n${e}`)}`},x:{label:`X`,href:({url:e,text:t})=>`https://x.com/intent/post?text=${encodeURIComponent(t)}&url=${encodeURIComponent(e)}`},linkedin:{label:`LinkedIn`,href:({url:e})=>`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(e)}`},facebook:{label:`Facebook`,href:({url:e})=>`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(e)}`},reddit:{label:`Reddit`,href:({url:e,text:t})=>`https://reddit.com/submit?url=${encodeURIComponent(e)}&title=${encodeURIComponent(t)}`},telegram:{label:`Telegram`,href:({url:e,text:t})=>`https://t.me/share/url?url=${encodeURIComponent(e)}&text=${encodeURIComponent(t)}`},whatsapp:{label:`WhatsApp`,href:({url:e,text:t})=>`https://wa.me/?text=${encodeURIComponent(`${t} ${e}`)}`},sms:{label:`SMS`,href:({url:e,text:t})=>`sms:?&body=${encodeURIComponent(`${t} ${e}`)}`},copy:{label:`Copy link`,href:()=>null,onClick:async({url:e})=>{if(typeof navigator<`u`&&navigator.clipboard)try{await navigator.clipboard.writeText(e)}catch{}}}};function g(e){return(e??m).map(e=>{if(typeof e==`string`){let t=h[e];return t?{id:e,...t}:null}return e}).filter(e=>!!e)}function _(r){let{waitlist:i,refCode:a,shareUrl:o,rank:s=0,total:c,message:l,shareTargets:u,pointValues:d,baseUrl:f,onShared:p}=r,m=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:f}),[f]),h=(0,t.useMemo)(()=>g(u),[u]),[_,v]=(0,t.useState)(null),[y,b]=(0,t.useState)(null),x=d?.SHARE??2,S=(0,t.useMemo)(()=>{let e=l?l({url:o,text:``,rank:s,refCode:a}):s?`I'm #${s.toLocaleString()} on the waitlist. Climb with me:`:`Join me on the waitlist:`;return{url:o,text:e,rank:s,refCode:a}},[l,s,a,o]),C=(0,t.useMemo)(()=>typeof navigator>`u`||!(`share`in navigator)?h.filter(e=>e.id!==`webshare`):h,[h]),w=(0,t.useCallback)(async e=>{if(_)return;v(String(e.id)),b(null);try{e.onClick&&await e.onClick(S)}catch{}let t=e.href(S);t&&(t.startsWith(`mailto:`)||t.startsWith(`sms:`)?window.location.href=t:window.open(t,`_blank`,`noopener,noreferrer`));let n=await m.trackShare({waitlist:i,refCode:a,platform:String(e.id)}),r=0,o=!1;`ok`in n&&n.ok&&(r=n.awarded,o=n.alreadyClaimed,r>0?b(`+${r} from ${e.label}`):o&&b(`Already counted today`)),p?.(String(e.id),r,o),v(null),setTimeout(()=>b(null),2200)},[_,m,S,p,a,i]);return(0,n.jsxs)(`div`,{className:`hanzo-waitlist__share-wrap`,children:[(0,n.jsx)(`ul`,{className:`hanzo-waitlist__share`,role:`list`,children:C.map(e=>{let t=e.points??x,r=_===String(e.id),i=e.id===`webshare`||e.id===`copy`;return(0,n.jsx)(`li`,{children:(0,n.jsxs)(`button`,{type:`button`,className:`hanzo-waitlist__share-btn${i?``:` hanzo-waitlist__button--ghost`}`,onClick:()=>w(e),disabled:r,"aria-label":`${e.label} (+${t})`,children:[(0,n.jsx)(`span`,{className:`hanzo-waitlist__share-label`,children:e.label}),t>0&&(0,n.jsxs)(`span`,{className:`hanzo-waitlist__share-pts`,"aria-hidden":`true`,children:[`+`,t]})]})},String(e.id))})}),(0,n.jsx)(`div`,{className:`hanzo-waitlist__toast`,role:`status`,"aria-live":`polite`,children:y})]})}function v(e){return e.split(/[\s,;]+/).map(e=>e.trim()).filter(Boolean)}function y(r){let{waitlist:i,refCode:a,baseUrl:o,pointPerInvite:s=1,pointPerConversion:c=5,maxBatch:l=50,defaultMessage:u=``,onSent:d}=r,f=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:o}),[o]),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(``),[_,y]=(0,t.useState)(u),[b,x]=(0,t.useState)(!1),[S,C]=(0,t.useState)(null),[w,T]=(0,t.useState)(null),E=(0,t.useMemo)(()=>v(h),[h]),D=E.length,O=D>l,k=D*s,A=(0,t.useCallback)(async()=>{if(D===0||O||b)return;x(!0),T(null),C(null);let e=await f.invite({waitlist:i,refCode:a,emails:E,message:_||void 0});`ok`in e&&e.ok?(C(e),g(``),d?.(e)):T(e.message||`failed to send`),x(!1)},[b,f,D,E,_,d,O,a,i]);return(0,n.jsxs)(`div`,{className:`hanzo-waitlist__invite`,children:[(0,n.jsxs)(`button`,{type:`button`,className:`hanzo-waitlist__invite-toggle`,onClick:()=>m(e=>!e),"aria-expanded":p,children:[(0,n.jsx)(`span`,{children:`Invite friends`}),(0,n.jsxs)(`span`,{className:`hanzo-waitlist__invite-toggle-meta`,children:[`+`,s,`/sent · +`,c,`/joined`]}),(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`hanzo-waitlist__chev${p?` is-open`:``}`,children:`›`})]}),p&&(0,n.jsxs)(`div`,{className:`hanzo-waitlist__invite-panel`,children:[(0,n.jsxs)(`label`,{className:`hanzo-waitlist__invite-label`,htmlFor:`hw-invite-emails`,children:[`Emails`,(0,n.jsxs)(`span`,{className:`hanzo-waitlist__invite-hint`,children:[D,` `,D===1?`address`:`addresses`,O&&` — max ${l}`,!O&&D>0&&` · +${k} pts pending`]})]}),(0,n.jsx)(`textarea`,{id:`hw-invite-emails`,className:`hanzo-waitlist__invite-textarea`,placeholder:`[email protected]
|
||
[email protected], [email protected]`,rows:4,value:h,onChange:e=>g(e.currentTarget.value),disabled:b}),(0,n.jsx)(`input`,{type:`text`,className:`hanzo-waitlist__input`,placeholder:`Personal note (optional)`,value:_,maxLength:500,onChange:e=>y(e.currentTarget.value),disabled:b}),(0,n.jsx)(`button`,{type:`button`,className:`hanzo-waitlist__button`,onClick:A,disabled:b||D===0||O,children:b?`Sending…`:D>0?`Send ${D} ${D===1?`invite`:`invites`}`:`Send invites`}),w&&(0,n.jsx)(`p`,{className:`hanzo-waitlist__error`,role:`alert`,children:w}),S&&(0,n.jsxs)(`p`,{className:`hanzo-waitlist__invite-result`,role:`status`,children:[`Sent `,(0,n.jsx)(`strong`,{children:S.sent}),S.skipped>0&&(0,n.jsxs)(n.Fragment,{children:[`, skipped `,S.skipped,` `,(0,n.jsx)(`small`,{children:`(already on list)`})]}),S.invalid>0&&(0,n.jsxs)(n.Fragment,{children:[`, `,S.invalid,` invalid`]}),S.duplicates>0&&(0,n.jsxs)(n.Fragment,{children:[`, `,S.duplicates,` duplicates`]}),S.pointsAwarded>0&&(0,n.jsxs)(n.Fragment,{children:[` · +`,S.pointsAwarded,` pts`]})]})]})]})}var b=e=>e.aheadOf&&e.aheadOf>0?`${e.aheadOf.toLocaleString()} ${e.aheadOf===1?`person is`:`people are`} behind you. Refer friends to climb.`:`Refer friends to climb the list.`;function x(e){let{entry:r,waitlist:i,baseUrl:a,title:o=`You're on the list`,subtitle:s=b,hideShare:c,hideInvite:l,hidePoints:u,shareTargets:d,onEntryChange:f}=e,[p,m]=(0,t.useState)(r);r!==p&&r.email===p.email&&r.points!==p.points&&m(r);let h=r===p||r.points>=p.points?r:p,g=(0,t.useMemo)(()=>{if(typeof window>`u`)return h.shareUrl;let e=new URL(window.location.href);return e.search=``,e.searchParams.set(`ref`,h.refCode),e.toString()},[h.refCode,h.shareUrl]),v=(0,t.useCallback)((e,t)=>{let n={...h,points:e,pointBreakdown:t};m(n),f?.(n)},[f,h]),x=h.pointBreakdown,S=h.pointValues;return(0,n.jsxs)(`div`,{className:`hanzo-waitlist__success`,children:[(0,n.jsx)(`h3`,{className:`hanzo-waitlist__title`,style:{textAlign:`center`},children:o}),(0,n.jsx)(`div`,{className:`hanzo-waitlist__rank`,"aria-label":`Rank ${h.rank} of ${h.total}`,children:h.rank.toLocaleString()}),(0,n.jsxs)(`p`,{className:`hanzo-waitlist__of`,"aria-hidden":`true`,children:[`of `,h.total.toLocaleString()]}),(0,n.jsx)(`p`,{className:`hanzo-waitlist__meta`,children:s(h)}),!u&&(0,n.jsxs)(`div`,{className:`hanzo-waitlist__score`,"aria-label":`${h.points} points`,children:[(0,n.jsxs)(`div`,{className:`hanzo-waitlist__score-num`,children:[h.points.toLocaleString(),(0,n.jsx)(`span`,{className:`hanzo-waitlist__score-suffix`,children:`pts`})]}),(0,n.jsxs)(`ul`,{className:`hanzo-waitlist__score-breakdown`,role:`list`,children:[(0,n.jsxs)(`li`,{children:[(0,n.jsx)(`b`,{children:x.referrals}),` referrals `,(0,n.jsxs)(`small`,{children:[`×`,S.REFERRAL]})]}),(0,n.jsxs)(`li`,{children:[(0,n.jsx)(`b`,{children:x.shares}),` shares `,(0,n.jsxs)(`small`,{children:[`×`,S.SHARE]})]}),(0,n.jsxs)(`li`,{children:[(0,n.jsx)(`b`,{children:x.invitesSent}),` invites `,(0,n.jsxs)(`small`,{children:[`×`,S.INVITE_SENT]})]}),(0,n.jsxs)(`li`,{children:[(0,n.jsx)(`b`,{children:x.invitesConverted}),` joined `,(0,n.jsxs)(`small`,{children:[`×`,S.INVITE_CONVERTED]})]})]})]}),!c&&(0,n.jsx)(_,{waitlist:i,refCode:h.refCode,shareUrl:g,rank:h.rank,total:h.total,baseUrl:a,shareTargets:d,pointValues:h.pointValues,onShared:(e,t)=>{t>0&&v(h.points+t,{...x,shares:x.shares+t})}}),!l&&(0,n.jsx)(y,{waitlist:i,refCode:h.refCode,baseUrl:a,pointPerInvite:S.INVITE_SENT,pointPerConversion:S.INVITE_CONVERTED,onSent:e=>v(h.points+e.pointsAwarded,{...x,invitesSent:x.invitesSent+e.pointsAwarded})})]})}function S(r){let{waitlist:i,baseUrl:a,mode:o=`inline`,theme:c=`auto`,logo:u,title:f,subtitle:m,submitLabel:h,turnstileToken:g,successTitle:_,successSubtitle:v,triggerLabel:y=`Join waitlist`,hideShare:b,hideInvite:S,hidePoints:w,shareTargets:T,className:E,style:D,onSuccess:O,onError:k}=r,A=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:a}),[a]),j=d(i),[M,N]=(0,t.useState)(null),[P,F]=(0,t.useState)(!1);(0,t.useEffect)(()=>{l()},[]),(0,t.useEffect)(()=>{if(!j?.email){N(null);return}let e=!1;return A.status({waitlist:i,email:j.email}).then(t=>{e||`ok`in t&&t.ok&&N(t)}),()=>{e=!0}},[j?.email,A,i]);let I=(0,t.useCallback)(e=>{s(i,{email:e.email,rank:e.rank,refCode:e.refCode}),N(e),O?.(e)},[O,i]),L=(0,n.jsxs)(C,{theme:c,className:E,style:D,children:[u&&(0,n.jsx)(`div`,{className:`hanzo-waitlist__logo`,children:u}),M?(0,n.jsx)(x,{entry:M,waitlist:i,baseUrl:a,title:_,subtitle:v,hideShare:b,hideInvite:S,hidePoints:w,shareTargets:T,onEntryChange:N}):(0,n.jsx)(p,{waitlist:i,baseUrl:a,title:f,subtitle:m,submitLabel:h,turnstileToken:g,onSuccess:I,onError:k})]});return o===`inline`?L:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{type:`button`,className:`hanzo-waitlist__trigger`,onClick:()=>F(!0),children:M?`#${M.rank.toLocaleString()} — view`:y}),P&&(0,n.jsx)(`div`,{className:`hanzo-waitlist__backdrop`,role:`dialog`,"aria-modal":`true`,onClick:e=>{e.target===e.currentTarget&&F(!1)},children:(0,n.jsx)(`div`,{className:`hanzo-waitlist__dialog`,children:L})})]})}function C(e){let t=e.theme===`auto`?void 0:e.theme,r=[`hanzo-waitlist`,e.className].filter(Boolean).join(` `);return(0,n.jsx)(`div`,{className:r,"data-theme":t,style:e.style,children:(0,n.jsx)(`div`,{className:`hanzo-waitlist__card`,children:e.children})})}var w=e=>1-(1-e)**3;function T(e,n={}){let{duration:r=1200,ease:i=w,retrigger:a=!0}=n,[o,s]=(0,t.useState)(0),c=(0,t.useRef)(null),l=(0,t.useRef)(0);return(0,t.useEffect)(()=>{if(e==null)return;if(r<=0){s(e),l.current=e;return}if(typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches){s(e),l.current=e;return}let t=a?l.current:o,n=e;if(t===n)return;let u=performance.now(),d=e=>{let a=Math.min(1,(e-u)/r),o=t+(n-t)*i(a);s(Math.round(o)),a<1?c.current=requestAnimationFrame(d):(l.current=n,c.current=null)};return c.current=requestAnimationFrame(d),()=>{c.current&&cancelAnimationFrame(c.current)}},[e,r]),o}function E(r){let{waitlist:i,baseUrl:a,pageSize:o=25,theme:s=`auto`,highlightEmail:c,mode:l=`load-more`,loadMoreLabel:u=`Show more`,exhaustedLabel:d=`That's everyone`,animateTotal:f=!0,className:p,style:m,renderEmail:h}=r,g=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:a}),[a]),[_,v]=(0,t.useState)(1),[y,b]=(0,t.useState)([]),[x,S]=(0,t.useState)(null),[C,w]=(0,t.useState)(null),[E,O]=(0,t.useState)(!1),k=(0,t.useCallback)(async(e,t)=>{O(!0),w(null);let n=await g.list({waitlist:i,page:e,pageSize:o});`ok`in n&&n.ok?(S({total:n.total,totalPages:n.totalPages}),b(e=>{if(!t)return n.entries;let r=new Set(e.map(e=>e.rank)),i=n.entries.filter(e=>!r.has(e.rank));return[...e,...i]})):w(n.message||`failed to load`),O(!1)},[g,o,i]);(0,t.useEffect)(()=>{v(1),b([]),k(1,!1)},[k]);let A=x?.total??0,j=f===!1?0:typeof f==`object`?f.duration??1200:1200,M=T(x?A:null,{duration:j}),N=f===!1?A:M,P=l===`paginate`,F=x?_>=x.totalPages:!1,I=l===`load-more`&&x&&y.length>=x.total,L=(0,t.useCallback)(()=>{if(E)return;let e=_+1;v(e),k(e,!0)},[E,k,_]),R=s===`auto`?void 0:s;return(0,n.jsx)(`div`,{className:[`hanzo-waitlist`,p].filter(Boolean).join(` `),"data-theme":R,style:m,children:(0,n.jsxs)(`div`,{className:`hanzo-waitlist__card hanzo-waitlist-lb`,children:[(0,n.jsxs)(`header`,{className:`hanzo-waitlist-lb__head`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h3`,{className:`hanzo-waitlist__title`,children:`Leaderboard`}),(0,n.jsxs)(`p`,{className:`hanzo-waitlist__subtitle`,children:[(0,n.jsx)(`span`,{className:`hanzo-waitlist-lb__total`,children:N.toLocaleString()}),` on the list`]})]}),P&&(0,n.jsx)(D,{page:_,totalPages:x?.totalPages??1,busy:E,onChange:e=>{v(e),k(e,!1)}})]}),C&&(0,n.jsx)(`p`,{className:`hanzo-waitlist__error`,role:`alert`,children:C}),(0,n.jsxs)(`ol`,{className:`hanzo-waitlist-lb__list`,children:[y.map(e=>{let t=c&&e.email.toLowerCase()===c.toLowerCase();return(0,n.jsxs)(`li`,{className:`hanzo-waitlist-lb__row`,"data-mine":t?`true`:void 0,children:[(0,n.jsxs)(`span`,{className:`hanzo-waitlist-lb__rank`,children:[`#`,e.rank.toLocaleString()]}),(0,n.jsx)(`span`,{className:`hanzo-waitlist-lb__email`,children:h?h(e):e.email}),(0,n.jsx)(`span`,{className:`hanzo-waitlist-lb__refs`,"aria-label":`${e.referralCount} referrals`,children:e.referralCount.toLocaleString()})]},`${e.rank}-${e.email}`)}),!C&&y.length===0&&(0,n.jsx)(`li`,{className:`hanzo-waitlist-lb__empty`,children:E?`Loading…`:`No one yet — be the first.`})]}),!P&&x&&!I&&(0,n.jsx)(`footer`,{className:`hanzo-waitlist-lb__foot`,children:(0,n.jsx)(`button`,{type:`button`,className:`hanzo-waitlist__button hanzo-waitlist__button--ghost hanzo-waitlist-lb__more`,onClick:L,disabled:E,children:E?`Loading…`:u})}),!P&&I&&d&&(0,n.jsx)(`footer`,{className:`hanzo-waitlist-lb__foot`,children:(0,n.jsx)(`span`,{className:`hanzo-waitlist-lb__exhausted`,children:d})}),P&&(x?.totalPages??1)>1&&(0,n.jsx)(`footer`,{className:`hanzo-waitlist-lb__foot`,children:(0,n.jsx)(D,{page:_,totalPages:x?.totalPages??1,busy:E,onChange:e=>{v(e),k(e,!1)}})}),!P&&F&&!1]})})}function D(e){return(0,n.jsxs)(`div`,{className:`hanzo-waitlist-lb__pager`,children:[(0,n.jsx)(`button`,{type:`button`,className:`hanzo-waitlist__button hanzo-waitlist__button--ghost`,onClick:()=>e.onChange(Math.max(1,e.page-1)),disabled:e.busy||e.page<=1,"aria-label":`Previous page`,children:`←`}),(0,n.jsxs)(`span`,{className:`hanzo-waitlist-lb__pageinfo`,children:[e.page.toLocaleString(),` / `,e.totalPages.toLocaleString()]}),(0,n.jsx)(`button`,{type:`button`,className:`hanzo-waitlist__button hanzo-waitlist__button--ghost`,onClick:()=>e.onChange(Math.min(e.totalPages,e.page+1)),disabled:e.busy||e.page>=e.totalPages,"aria-label":`Next page`,children:`→`})]})}function O(e){let t=Math.max(0,Math.floor(e/1e3));if(t<30)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<7?`${i}d ago`:`${Math.floor(i/7)}w ago`}function k(e){return e?{x:`X`,twitter:`X`,linkedin:`LinkedIn`,facebook:`Facebook`,reddit:`Reddit`,telegram:`Telegram`,whatsapp:`WhatsApp`,email:`email`,sms:`SMS`,copy:`link`,webshare:`a friend`,mastodon:`Mastodon`,bluesky:`Bluesky`,threads:`Threads`}[e.toLowerCase()]??e:`somewhere`}function A(e){switch(e.type){case`join`:return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` joined`,e.source===`referral`?` (referred)`:``]});case`share`:{let t=e.platform?.toLowerCase();return t===`copy`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` copied their link`]}):t===`webshare`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` shared via system`]}):t===`email`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` shared by email`]}):t===`sms`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` texted their link`]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` shared on `,k(e.platform)]})}case`invite`:return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` invited a friend`]});case`referral`:return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`b`,{children:e.who}),` earned a referral`]})}}function j(r){let{waitlist:i,baseUrl:a,limit:o=8,types:s,pollInterval:c=12e3,theme:l=`auto`,formatEvent:u,formatRelative:d,showHeading:f=!0,heading:p=`Recent activity`,emptyLabel:m=`Quiet for now.`,className:h,style:g}=r,_=(0,t.useMemo)(()=>new e.WaitlistClient({baseUrl:a}),[a]),[v,y]=(0,t.useState)([]),[b,x]=(0,t.useState)(null),[,S]=(0,t.useState)(0),C=(0,t.useRef)(!0);(0,t.useEffect)(()=>{C.current=!0;let e=async()=>{let e=await _.activity({waitlist:i,limit:o,types:s});C.current&&`ok`in e&&e.ok&&(y(e.entries),x(e.now))};if(e(),c<=0)return;let t=window.setInterval(e,c);return()=>{C.current=!1,window.clearInterval(t)}},[_,i,o,c,s]),(0,t.useEffect)(()=>{let e=window.setInterval(()=>S(e=>e+1),1e4);return()=>window.clearInterval(e)},[]);let w=l===`auto`?void 0:l,T=(0,t.useCallback)(e=>{let t=d??O,n=b??Date.now(),r=Date.now()-(b??Date.now());return t(n-e+r)},[d,b]);return(0,n.jsx)(`div`,{className:[`hanzo-waitlist`,h].filter(Boolean).join(` `),"data-theme":w,style:g,children:(0,n.jsxs)(`div`,{className:`hanzo-waitlist__card hanzo-waitlist-act`,children:[f&&(0,n.jsxs)(`header`,{className:`hanzo-waitlist-act__head`,children:[(0,n.jsx)(`h3`,{className:`hanzo-waitlist__title`,children:p}),(0,n.jsx)(`span`,{className:`hanzo-waitlist-act__pulse`,"aria-hidden":`true`})]}),v.length===0?(0,n.jsx)(`p`,{className:`hanzo-waitlist__hint`,style:{textAlign:`left`},children:m}):(0,n.jsx)(`ul`,{className:`hanzo-waitlist-act__list`,role:`list`,children:v.map((e,t)=>{let r=T(e.ts);return(0,n.jsxs)(`li`,{className:`hanzo-waitlist-act__row`,children:[(0,n.jsx)(`span`,{className:`hanzo-waitlist-act__dot hanzo-waitlist-act__dot--${e.type}`,"aria-hidden":`true`}),(0,n.jsx)(`span`,{className:`hanzo-waitlist-act__text`,children:u?u(e,{relative:r}):A(e)}),(0,n.jsx)(`time`,{className:`hanzo-waitlist-act__time`,dateTime:new Date(e.ts).toISOString(),children:r})]},`${e.ts}-${t}`)})})]})})}exports.Waitlist=S,exports.WaitlistActivity=j,exports.WaitlistClient=e.WaitlistClient,exports.WaitlistInviteFriends=y,exports.WaitlistJoin=p,exports.WaitlistLeaderboard=E,exports.WaitlistShare=_,exports.WaitlistStatus=x,exports.captureReferrerFromUrl=l,exports.clearPersistedEntry=c,exports.entryKey=a,exports.join=e.join,exports.readPendingReferrer=u,exports.readPersistedEntry=o,exports.status=e.status,exports.useCountUp=T,exports.usePersistedEntry=d,exports.writePersistedEntry=s;
|
||
//# sourceMappingURL=waitlist.cjs.map |