const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmojiPackDialog-B7vGYXh6.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BjbcRgLk.js","assets/jsx-runtime-By8HlURe.js","assets/dist-DPmmj29U.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useQuery-CQCUTxAw.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-boOMG5Xx.js","assets/preload-helper-CZgWQFsJ.js","assets/dist-DQ_zK-Nr.js","assets/utils-BFSTDHdM.js","assets/button-PfnADMEc.js","assets/dist-Dpfwv2h4.js","assets/dist-DvXXZeEa.js","assets/dist-DEYuuXMO.js","assets/useNostrPublish-D1pQ9KV-.js","assets/useMutation-Du3NQIud.js","assets/useAppContext-ZpOJAKgd.js","assets/CustomEmoji-I2Dzbi7x.js","assets/customEmoji-kpim4Htm.js","assets/input-CspJi8Oq.js","assets/useUploadFile-geM_X2W-.js","assets/appBlossom-CsMDSd4h.js","assets/dialog-CV-ki2ew.js","assets/dist-HCKlYXPm.js","assets/react-dom-B3NAB_6u.js","assets/dist-D7Bu0-nC.js","assets/dist-CcIWO21i2.js","assets/dist-CPSwqoBy.js","assets/dist-BiDubxw8.js","assets/dist-CxcvWxxD2.js","assets/dist-CDe9cWnA.js","assets/dist-VfIIxYhK.js","assets/dist-CGiXP6ew.js","assets/Combination-CjNgozRb.js","assets/textarea-BgTH9QGZ.js","assets/label-vPn5dXR9.js","assets/checkbox-PjbMGVRG.js","assets/dist-kXp6QuJv.js","assets/dist-C7V3QC0v.js","assets/scroll-area-C7R5cbXG.js","assets/dist-l851fJFf.js","assets/dist-C2J943E6.js","assets/ConstellationStarMap-BWOJ8Zrc.js","assets/ArticleContent-DKyv8QKH.js","assets/EmbeddedNote-BIqVJ_l6.js","assets/ErrorBoundary-CeoYY2tU.js","assets/useTheme-DAiZ1C6g.js","assets/useEncryptedSettings-Mj6Bzp-m.js","assets/fontLoader-B9KxicFi.js","assets/sanitizeUrl-Bk5f35GN.js","assets/react-intl-DZWxPhxo.js","assets/encryptedFile-DKFYUsvG.js","assets/downloadFile-kpATXaJi.js","assets/nostrId-DcIQ4FCD.js","assets/letterTypes-BPWQWRGQ.js","assets/avatar-BQAt2c6L.js","assets/chunk-62JRHF6Z-BC2Zeguv.js","assets/hashtag-DjDKS0mr.js","assets/useProfileUrl-CaWgk1iO.js","assets/useNip05Resolve-DffiSbg0.js","assets/profileUrl-DpJiPx2H.js","assets/BioContent-DDUa8M5F.js","assets/useFollowActions-DsgUKin8.js","assets/dist-CKGV8nry.js","assets/ExternalFavicon-C4RKLGFC.js","assets/useUserStatus-B8wcD2cC.js","assets/haptics-Cp_uF-bV.js","assets/parseAddr-CsIsUI6W.js","assets/collapsible-D6IpicA3.js","assets/dist-Ds1tJnF3.js","assets/skeleton-CVls4GW9.js","assets/useAuthors-D2-iLlS9.js","assets/storageKey-Hu6452Ya.js","assets/safeNip19-BZNpFefA.js","assets/useEventInteractions-D6e37IFo.js","assets/nsiteSubdomain-DmdGxq_K.js","assets/tooltip-ihPDheAv.js","assets/timeAgo-BXjjbyXp.js","assets/getDisplayName-B6lnEGRj.js","assets/letterUtils-rB1MsAOm.js","assets/optimisticEvent-1jcgWuWv.js","assets/useLinkPreview-BkYXhPdP.js","assets/appRelays-Clm5NPIe.js","assets/packUtils-2qvnOK3p.js","assets/relayList-BL1oPXvf.js","assets/memorycard-MlvJNhop.js","assets/EmbeddedArticleCard-DcmW__gy.js","assets/articleHelpers-Dhr_Z8YP.js","assets/EmbeddedPublicationCard-CB7mdYv1.js","assets/bitcoinMoney-BhQyBHpS.js","assets/esplora-CScU9uce.js","assets/countries-Du6BjHuX.js","assets/campaign-DQCR5kmK.js","assets/quiz-C4N9ueCX.js","assets/extraKinds-CF0LI2P1.js","assets/sidebarItems-BUQKy0PN.js","assets/WikipediaIcon-Df-eqPdn.js","assets/BlueskyIcon-imVay4Hn.js","assets/formatNumber-D1ols1S-.js","assets/browser-B_X_RtOd.js","assets/imeta-AKViBfwk.js","assets/formatTime-CT4ZmnVr.js","assets/browser-C1AyMpfR.js","assets/LayoutContext-CseIvyNG.js","assets/useInView-DH5wwDuH.js","assets/useCustomEmojis-Dt5wlrd3.js","assets/EmbeddedNote-C_xrnWud.css","assets/lib-BtieP5-E.js","assets/lib-DhF-PQbN.js","assets/articleSmartypants-Bcj3a4SM.js","assets/markdownComponents-DZWBIHkp.js","assets/ClassifiedListingContent-CtJQH7_T.js","assets/BlobbiStateCard-DnVg3tNE.js","assets/blobbi-tV-LVZhE.js","assets/index-Bow5buFk.js","assets/useInfiniteQuery-D8okYDlC.js","assets/useLocalStorage-CLIGOX6B.js","assets/useLanguage--9xPt4K_.js","assets/credentialManager-Dv_8gYNN.js","assets/NewPostsPill-BaedKv8h.js","assets/dropdown-menu-DFQx4ARb.js","assets/dist-CogQAcR-.js","assets/usePortalContainer-DQGL8y5W.js","assets/popover-CpFQm40Y.js","assets/ProfileCard-DQLNVDBD.js","assets/useMuteList-CircRxPI.js","assets/useLoginActions-DN9mAG_d.js","assets/LoginFlow-CnOkE_pG.js","assets/qrcode-BozHOxi9.js","assets/useIsMobile-brkrNavj.js","assets/useShareOrigin-CbCLa1kb.js","assets/alert-8XHA_vtM.js","assets/ComposeDialogContent-DiIapF7b.js","assets/musicHelpers-B9zs9cce.js","assets/EmbeddedPost-DITW2flc.js","assets/dist-3TtKm3JK.js","assets/useSearchProfiles-B9G_eYtw.js","assets/useFeedSettings-BgA2vWPo.js","assets/birthday-CoMNDhVK.js","assets/resizeImage-LOlp-rx5.js","assets/DecryptedImage-DwsS1fNG.js","assets/wikimedia-CCPyM-j2.js","assets/NoteMoreMenu-3p8z2oYh.js","assets/radio-group-B1VhA2GH.js","assets/dist-QlrhncJe.js","assets/alert-dialog-CeTXY_OC.js","assets/separator-b5OgNKgY.js","assets/useUserLists-DfjIOk3O.js","assets/SubHeaderBar-3es_mHJE.js","assets/usePageRefresh-DfuHEbb5.js","assets/useMutedAuthorFilter-CJzmJTvY.js","assets/index-DWpLMzA2.css","assets/blobbi-shop-items-CNXfdKej.js","assets/BlobbiStageVisual-Dd-i9Ybg.js","assets/purify.es-DCh266OY.js","assets/BlobbiStageVisual-ZqmrGSeZ.css","assets/useBlobbiInteractions-BLqS6Kj4.js","assets/FloatingSocialHearts-B41ZB2oO.js","assets/BlobbiSocialActions-ByvTgEiI.js","assets/blobbi-action-utils-iVOeMboU.js","assets/ItemCarousel-BvL_DIgg.js","assets/CustomNipCard-BLY66QKO.js","assets/GitStatusCard-DBnz-4Be.js","assets/GitSiteLinks-Qp1PbuLj.js","assets/IssueCard-CyxWSjHq.js","assets/PullRequestCard-Dd8oTBrG.js","assets/badge-CmNUd8lU.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,$r as n,Ar as r,At as i,D as a,Dt as o,En as s,Fn as c,Fr as l,Ft as u,Gr as d,Gt as f,Hn as p,Ht as m,It as h,Jr as g,L as _,Ln as v,Lr as y,Mr as b,Nn as x,Nr as S,Nt as C,Ot as w,Pt as ee,Qt as T,R as E,Rn as te,Rr as ne,Tn as re,Tt as D,Un as O,Vn as ie,Vt as k,Wr as A,Wt as ae,X as oe,Xr as se,Xt as ce,Y as le,Zt as ue,_ as de,_n as fe,_r as j,a as pe,ai as M,ar as me,b as he,bi as ge,br as _e,bt as ve,ci as ye,cn as be,cr as xe,ct as Se,d as Ce,di as we,dt as Te,ei as Ee,fi as De,fn as Oe,fr as ke,g as Ae,gi as N,h as je,in as Me,ir as Ne,jt as Pe,ki as Fe,kr as Ie,kt as Le,ln as Re,lr as ze,lt as Be,m as Ve,mr as He,on as Ue,q as P,qr as We,qt as Ge,r as Ke,ri as qe,rn as Je,rr as Ye,rt as Xe,si as Ze,sr as Qe,st as $e,tn as et,tr as tt,ur as nt,v as rt,w as it,wt as at,x as ot,xi as st,yt as ct,z as lt,zn as ut,zr as dt,zt as ft}from"./lucide-icons-BjbcRgLk.js";import{t as pt}from"./react-dom-B3NAB_6u.js";import{t as mt}from"./jsx-runtime-By8HlURe.js";import{t as ht}from"./ErrorBoundary-CeoYY2tU.js";import{t as F}from"./preload-helper-CZgWQFsJ.js";import{t as gt}from"./dist-DPmmj29U.js";import{u as I}from"./esm-CRVqHnq2.js";import{h as _t,t as vt}from"./useQuery-CQCUTxAw.js";import{t as yt}from"./useMutation-Du3NQIud.js";import{$ as bt,A as xt,D as St,E as Ct,F as wt,G as Tt,I as Et,J as Dt,O as Ot,P as kt,R as At,S as jt,V as Mt,Z as Nt,a as Pt,at as Ft,c as It,dt as Lt,ft as Rt,g as zt,it as Bt,j as Vt,k as Ht,l as Ut,lt as Wt,mt as Gt,n as Kt,ot as qt,q as Jt,r as Yt,rt as Xt,s as Zt,st as Qt,t as $t,ut as en,w as tn}from"./EmbeddedNote-BIqVJ_l6.js";import{t as nn}from"./useAppContext-ZpOJAKgd.js";import{c as rn,l as an,p as on,s as sn,t as cn}from"./useTheme-DAiZ1C6g.js";import{r as L,t as ln}from"./sanitizeUrl-Bk5f35GN.js";import{o as un,r as dn}from"./react-intl-DZWxPhxo.js";import{n as fn,o as pn}from"./encryptedFile-DKFYUsvG.js";import{a as mn,n as hn}from"./downloadFile-kpATXaJi.js";import{i as gn,l as R,o as _n,s as vn,t as z}from"./useCurrentUser-boOMG5Xx.js";import{t as B}from"./utils-BFSTDHdM.js";import{t as V}from"./button-PfnADMEc.js";import{t as yn}from"./useNostrPublish-D1pQ9KV-.js";import{t as bn}from"./nostrId-DcIQ4FCD.js";import{n as xn}from"./useFollowActions-DsgUKin8.js";import{a as Sn,o as Cn}from"./appRelays-Clm5NPIe.js";import{n as wn,o as Tn,r as En,t as Dn}from"./avatar-BQAt2c6L.js";import{n as H}from"./chunk-62JRHF6Z-BC2Zeguv.js";import{n as U,r as On,t as kn}from"./CustomEmoji-I2Dzbi7x.js";import{n as An,t as jn}from"./useProfileUrl-CaWgk1iO.js";import{C as Mn,E as Nn,S as Pn,T as Fn,_ as In,a as Ln,b as Rn,c as zn,d as Bn,g as Vn,h as Hn,i as Un,l as Wn,m as Gn,o as Kn,p as qn,r as W,s as Jn,v as Yn,w as Xn,x as Zn,y as Qn}from"./BioContent-DDUa8M5F.js";import{r as $n}from"./dist-D7Bu0-nC.js";import{t as er}from"./ExternalFavicon-C4RKLGFC.js";import{t as tr}from"./parseAddr-CsIsUI6W.js";import{t as nr}from"./dist-CDe9cWnA.js";import{n as rr,r as ir,t as ar}from"./collapsible-D6IpicA3.js";import{i as or,r as sr,t as cr}from"./popover-CpFQm40Y.js";import{t as G}from"./skeleton-CVls4GW9.js";import{t as lr}from"./ProfileCard-DQLNVDBD.js";import{t as ur}from"./useAuthors-D2-iLlS9.js";import{n as dr,t as fr}from"./appBlossom-CsMDSd4h.js";import{n as pr,r as mr,t as hr}from"./safeNip19-BZNpFefA.js";import{d as gr,f as _r,m as vr,n as yr,p as br,t as xr,u as Sr}from"./useEventInteractions-D6e37IFo.js";import{a as Cr,i as wr,l as Tr,o as Er,s as Dr}from"./nsiteSubdomain-DmdGxq_K.js";import{g as Or,m as kr}from"./ComposeDialogContent-DiIapF7b.js";import{i as Ar,n as jr,t as Mr}from"./tooltip-ihPDheAv.js";import{a as Nr,i as Pr,n as Fr,r as Ir,s as Lr,t as Rr}from"./musicHelpers-B9zs9cce.js";import{n as zr}from"./dist-HCKlYXPm.js";import{a as Br,c as Vr,l as Hr,n as Ur,o as Wr,r as Gr,s as Kr,t as qr}from"./dialog-CV-ki2ew.js";import{t as Jr}from"./textarea-BgTH9QGZ.js";import{C as Yr,D as Xr,M as Zr,N as Qr,R as $r,T as ei,_ as ti,b as ni,d as ri,g as ii,h as ai,k as oi,v as si,x as ci,y as li}from"./EmbeddedPost-DITW2flc.js";import{t as ui}from"./timeAgo-BXjjbyXp.js";import{t as di}from"./getDisplayName-B6lnEGRj.js";import{i as fi,n as pi,r as mi,t as hi}from"./optimisticEvent-1jcgWuWv.js";import{i as gi,n as _i,r as vi,t as yi}from"./useLinkPreview-BkYXhPdP.js";import{r as bi,t as xi}from"./packUtils-2qvnOK3p.js";import{n as Si,r as Ci}from"./relayList-BL1oPXvf.js";import{_ as wi,h as Ti,l as Ei,m as Di,o as Oi,r as ki,s as Ai}from"./memorycard-MlvJNhop.js";import{a as ji,i as Mi,o as Ni,r as Pi}from"./EmbeddedPublicationCard-CB7mdYv1.js";import{l as Fi,t as Ii}from"./bitcoinMoney-BhQyBHpS.js";import{n as Li}from"./countries-Du6BjHuX.js";import{a as Ri,i as zi,n as Bi,o as Vi,r as Hi,s as Ui}from"./campaign-DQCR5kmK.js";import{a as Wi,c as Gi,d as Ki,i as qi,l as Ji,n as Yi,o as Xi,r as Zi,s as Qi,t as $i,u as ea}from"./quiz-C4N9ueCX.js";import{o as ta,p as na}from"./extraKinds-CF0LI2P1.js";import{b as ra,y as ia}from"./sidebarItems-BUQKy0PN.js";import{t as aa}from"./formatNumber-D1ols1S-.js";import{i as oa,n as sa,o as ca,s as la,t as ua}from"./imeta-AKViBfwk.js";import{t as da}from"./formatTime-CT4ZmnVr.js";import{o as fa}from"./LayoutContext-CseIvyNG.js";import{t as pa}from"./useInView-DH5wwDuH.js";import{t as ma}from"./NoteMoreMenu-3p8z2oYh.js";import{t as ha}from"./qrcode-BozHOxi9.js";import{t as ga}from"./useFeedSettings-BgA2vWPo.js";import{n as _a,r as va}from"./birthday-CoMNDhVK.js";import{n as ya,t as ba}from"./useInteractionReaction-yS8fuYfx.js";import{t as xa}from"./DecryptedImage-DwsS1fNG.js";import{t as K}from"./badge-CmNUd8lU.js";import{n as Sa,t as Ca}from"./colorMomentUtils-Bpys-FvF.js";import{t as wa}from"./contentWarning-CNDzjeMP.js";import{n as Ta,t as Ea}from"./streamStatus-DVDPiDhw.js";import{t as Da}from"./useRelayInfo-vo6x6CNq.js";import{t as Oa}from"./GitSiteLinks-Qp1PbuLj.js";import{t as ka}from"./useOpenPost-BwUmNKcO.js";import{t as Aa}from"./label-vPn5dXR9.js";import{n as ja,t as Ma}from"./radio-group-B1VhA2GH.js";import{t as Na}from"./switch-DKbY1cT2.js";import{r as Pa}from"./useRepostStatus-B31cmi_e.js";import{r as Fa}from"./useBitcoinSigner-FZ_QaYrL.js";import{t as Ia}from"./checkbox-PjbMGVRG.js";import"./separator-b5OgNKgY.js";import{t as La}from"./scroll-area-C7R5cbXG.js";import{n as Ra,t as za}from"./RepostMenu-Cxcb2_YK.js";import{n as Ba,r as Va,t as Ha}from"./lib-BtieP5-E.js";import{t as Ua}from"./useTrending-Chl2smhy.js";import{n as Wa,t as Ga}from"./vineGlobalMute-Du-DhONT.js";var q=e(Fe(),1),J=mt();function Ka(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return}}function qa({event:e,expanded:t=!1,className:n,disableSourceEmbed:r=!1}){let{highlight:i,context:a,source:o}=(0,q.useMemo)(()=>{let t=e.content.trim(),n=e.tags.find(([e])=>e===`context`)?.[1]?.trim(),r=n&&t&&n.includes(t)?n:void 0,i=e.tags.find(([e,,,t])=>e===`a`&&t!==`mention`)?.[1],a=e.tags.find(([e,,,t])=>e===`e`&&t!==`mention`),o=e.tags.find(([e,,,t])=>e===`r`&&t===`source`)?.[1]??e.tags.find(([e,,,t])=>e===`r`&&t!==`mention`)?.[1],s;if(i){let t=tr(i);if(t){let n=e.tags.find(([e,t])=>e===`a`&&t===i)?.[2];s={kind:`addr`,addr:t,relays:n?[n]:void 0}}}if(!s&&a?.[1]){let[,e,t,,n]=a;bn(e)&&(s={kind:`event`,id:e,relays:t?[t]:void 0,authorHint:bn(n)?n:void 0})}if(!s&&o){let e=L(o);e&&(s={kind:`url`,url:e})}return{highlight:t,context:r,source:s}},[e.tags,e.content]),s=e.tags.find(([e])=>e===`comment`)?.[1]?.trim()||void 0,c=o?.kind===`event`&&!r,l=s?(0,J.jsx)(`p`,{dir:`auto`,className:B(`whitespace-pre-wrap break-words text-foreground`,t?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`),children:s}):null;if(c&&o?.kind===`event`)return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[l,(0,J.jsx)($t,{eventId:o.id,relays:o.relays,authorHint:o.authorHint,highlightText:i,className:`my-0`})]});let u=a?(0,J.jsx)(Ya,{context:a,highlight:i,expanded:t}):(0,J.jsx)(Ja,{text:i,expanded:t});return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[l,u,o&&!r&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(D,{className:`size-3`}),`Highlighted from`]}),o.kind===`addr`?(0,J.jsx)(Dt,{addr:o.addr,className:`my-0`}):o.kind===`event`?(0,J.jsx)($t,{eventId:o.id,relays:o.relays,authorHint:o.authorHint,className:`my-0`}):(0,J.jsx)(At,{url:o.url,showActions:!1})]}),o&&r&&(0,J.jsx)(Xa,{source:o})]})}function Ja({text:e,expanded:t}){return e?(0,J.jsx)(`blockquote`,{className:B(`rounded-r-xl border-l-4 border-primary/70 bg-primary/5 px-4 py-3`),children:(0,J.jsx)(`p`,{className:B(`whitespace-pre-wrap break-words font-serif text-foreground`,t?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`),children:e})}):(0,J.jsx)(`div`,{className:B(`rounded-xl border border-dashed border-border px-4 py-3 text-center text-sm text-muted-foreground`),children:`Highlighted media`})}function Ya({context:e,highlight:t,expanded:n}){let r=e.indexOf(t),i=e.slice(0,r),a=e.slice(r+t.length);return(0,J.jsx)(`blockquote`,{className:B(`rounded-r-xl border-l-4 border-primary/70 bg-primary/5 px-4 py-3`),children:(0,J.jsxs)(`p`,{className:B(`whitespace-pre-wrap break-words font-serif`,n?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`),children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,J.jsx)(`mark`,{className:`rounded bg-primary/25 px-0.5 text-foreground`,children:t}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:a})]})})}function Xa({source:e}){if(e.kind===`url`){let t=Ka(e.url)??e.url;return(0,J.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow ugc`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ze,{className:`size-3`}),t]})}return(0,J.jsxs)(H,{to:e.kind===`addr`?`/${I.naddrEncode(e.addr)}`:`/${I.neventEncode({id:e.id})}`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(D,{className:`size-3`}),`Highlighted from Nostr`]})}var Za=e(pt(),1),Qa=(0,q.createContext)({activeSubdomain:null,setActiveSubdomain:()=>{}});function $a(){return(0,q.useContext)(Qa)}function eo({nip05:e,pubkey:t,className:n}){let{data:r,isPending:i}=An(e,t);return i?(0,J.jsx)(G,{className:B(`h-3 w-24 inline-block`,n)}):r?(0,J.jsxs)(`span`,{className:n,children:[`@`,Zn(e)]}):null}function to({nip05:e,pubkey:t,className:n,iconSize:r=16,showCheck:i=!1}){let{data:a,isPending:o}=An(e,t);if(o)return(0,J.jsxs)(`span`,{className:B(`inline-flex items-center gap-1`,n),children:[(0,J.jsx)(G,{className:`h-3 w-24`}),(0,J.jsx)(G,{className:`rounded-full`,style:{width:r,height:r}})]});if(!a)return null;let s=Pn(e),c=Mn(e),l=c===`_`;return(0,J.jsxs)(`span`,{className:B(`inline-flex items-center min-w-0`,n),children:[i&&(0,J.jsx)(dt,{className:`size-3.5 text-primary shrink-0 mr-1 mt-[0.2rem]`}),l?(0,J.jsxs)(H,{to:`/feed/${s}`,className:`truncate min-w-0 hover:underline`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:[`@`,s]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`truncate min-w-0`,children:[`@`,c,`@`]}),s&&(0,J.jsx)(H,{to:`/feed/${s}`,className:`shrink-0 hover:underline`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:s})]}),s&&(0,J.jsx)(H,{to:`/feed/${s}`,className:`inline-flex items-center shrink-0 ml-1 hover:opacity-80 transition-opacity`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:(0,J.jsx)(er,{url:`https://${s}`,size:r,className:`shrink-0`})})]})}function Y(e,t){return e.find(([e])=>e===t)?.[1]}function no(e){let t=ua(e);return t?{url:t.url,thumbnail:t.thumbnail,duration:t.duration,mime:t.mime,encryption:t.encryption}:{}}function ro(e){let t=Y(e.tags,`title`)??Y(e.tags,`subject`)??`Untitled Episode`,n=no(e.tags),r=e.tags.find(([e])=>e===`audio`),i=r?.[1]??n.url??Y(e.tags,`url`)??Y(e.tags,`media`);if(!i)return null;let a=r?.[2],o=n.duration??Y(e.tags,`duration`),s=o?parseFloat(o):void 0,c=Y(e.tags,`pubdate`)??Y(e.tags,`published_at`),l;if(c){let t=parseInt(c,10);if(isFinite(t)&&String(t)===c)l=t;else{let t=new Date(c);l=isFinite(t.getTime())?Math.floor(t.getTime()/1e3):e.created_at}}else l=e.created_at;let u=i===n.url?n.encryption:void 0,d=Y(e.tags,`image`)??n.thumbnail??Y(e.tags,`thumb`),f=d&&d===n.thumbnail&&n.encryption?fn(n.encryption):void 0;return{title:t,audioUrl:i,audioMime:a??n.mime??Y(e.tags,`m`),encryption:u,pubdate:l&&isFinite(l)?l:void 0,description:Y(e.tags,`description`)||e.content||``,artwork:d,artworkEncryption:f,duration:s&&isFinite(s)?s:void 0}}function io(e){let t=Y(e.tags,`title`)??Y(e.tags,`subject`)??`Trailer`,n=no(e.tags),r=n.url??Y(e.tags,`url`)??Y(e.tags,`media`);return r?{title:t,url:r,encryption:r===n.url?n.encryption:void 0,pubdate:e.created_at,type:Y(e.tags,`type`),season:Y(e.tags,`season`)}:null}function ao(e,t){return e.find(([e])=>e===t)?.[1]}function oo(e){let t=ao(e.tags,`d`)??``;return`/`+I.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}function so(e,t){return{id:e.id,title:t.title,artist:``,url:t.audioUrl,encryption:t.encryption,artwork:t.artwork,artworkEncryption:t.artworkEncryption,duration:t.duration,path:oo(e)}}function co(e,t){return{id:e.id,title:t.title,artist:``,url:t.url,encryption:t.encryption,path:oo(e)}}function lo({isPlaying:e,isActive:t,onClick:n,size:r=`lg`,loading:i}){let a=r===`lg`?`size-12`:`size-10`,o=r===`lg`?`size-5`:`size-4`;return(0,J.jsx)(`button`,{onClick:n,disabled:i,className:B(`shrink-0 rounded-full flex items-center justify-center transition-colors`,a,t&&e?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`,i&&`cursor-progress`),"aria-label":t&&e?`Pause`:`Play`,children:i?(0,J.jsx)(be,{className:B(o,`animate-spin`)}):t&&e?(0,J.jsx)(u,{className:o,fill:`currentColor`}):(0,J.jsx)(Le,{className:B(o,`ml-0.5`),fill:`currentColor`})})}function uo({event:e}){let t=Lr(),n=(0,q.useMemo)(()=>Fr(e),[e]),r=R(e.pubkey),i=Nr(e.id);if(!n)return null;let a=t.currentTrack?.id===e.id,o=i.status===`decrypting`,s=n.duration?da(n.duration):void 0,c=i=>{if(i.stopPropagation(),a&&t.isPlaying)t.pause();else if(a)t.resume();else{let i=Ir(e,n);i.artwork??=r.data?.metadata?.picture,t.playTrack(i)}};return(0,J.jsxs)(`div`,{className:B(`mt-3 rounded-2xl border overflow-hidden`,a?`border-primary bg-primary/5`:`border-border`),children:[n.artwork?(0,J.jsxs)(`div`,{className:`relative aspect-square max-h-[280px] w-full overflow-hidden cursor-pointer`,onClick:c,children:[(0,J.jsx)(xa,{url:n.artwork,encryption:n.artworkEncryption,alt:n.title,className:`w-full h-full object-cover`,loading:`lazy`,decoding:`async`,noticeFill:!0}),(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 hover:bg-black/10 transition-colors`,children:(0,J.jsx)(lo,{isPlaying:t.isPlaying,isActive:a,onClick:c,size:`lg`,loading:o})})]}):(0,J.jsxs)(`div`,{className:`relative flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[140px] cursor-pointer`,onClick:c,children:[(0,J.jsx)(ae,{className:`size-10 text-primary/20`}),(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(lo,{isPlaying:t.isPlaying,isActive:a,onClick:c,size:`lg`,loading:o})})]}),(0,J.jsxs)(`div`,{className:`p-3.5 space-y-1.5 cursor-pointer`,children:[(0,J.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:n.title}),n.artist&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:n.artist}),s&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Ie,{className:`size-3 shrink-0`}),(0,J.jsx)(`span`,{children:s})]}),(0,J.jsx)(Pr,{trackId:e.id})]})]})}function fo({event:e}){let t=(0,q.useMemo)(()=>Rr(e),[e]);if(!t)return null;let n=t.trackRefs.length;return(0,J.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-border overflow-hidden cursor-pointer`,children:[t.artwork?(0,J.jsx)(`div`,{className:`aspect-video max-h-[200px] w-full overflow-hidden`,children:(0,J.jsx)(`img`,{src:t.artwork,alt:t.title,className:`w-full h-full object-cover`,loading:`lazy`,decoding:`async`})}):(0,J.jsx)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[100px]`,children:(0,J.jsx)(Oe,{className:`size-10 text-primary/20`})}),(0,J.jsxs)(`div`,{className:`p-3.5 space-y-1.5`,children:[(0,J.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:t.title}),t.description&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:t.description}),n>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Oe,{className:`size-3 shrink-0`}),(0,J.jsxs)(`span`,{children:[n,` track`,n===1?``:`s`]})]})]})]})}function po({event:e}){let t=Lr(),n=(0,q.useMemo)(()=>ro(e),[e]),r=R(e.pubkey),i=di(r.data?.metadata,e.pubkey),a=Nr(e.id);if(!n)return null;let s=t.currentTrack?.id===e.id,c=a.status===`decrypting`,l=n.duration?da(n.duration):void 0,u=a=>{if(a.stopPropagation(),s&&t.isPlaying)t.pause();else if(s)t.resume();else{let a=so(e,n);a.artist=i,a.artwork??=r.data?.metadata?.picture,t.playTrack(a)}};return(0,J.jsxs)(`div`,{className:B(`mt-3 rounded-2xl border overflow-hidden`,s?`border-primary bg-primary/5`:`border-border`),children:[n.artwork?(0,J.jsxs)(`div`,{className:`relative aspect-square max-h-[280px] w-full overflow-hidden cursor-pointer`,onClick:u,children:[(0,J.jsx)(xa,{url:n.artwork,encryption:n.artworkEncryption,alt:n.title,className:`w-full h-full object-cover`,loading:`lazy`,decoding:`async`,noticeFill:!0}),(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 hover:bg-black/10 transition-colors`,children:(0,J.jsx)(lo,{isPlaying:t.isPlaying,isActive:s,onClick:u,size:`lg`,loading:c})})]}):(0,J.jsxs)(`div`,{className:`relative flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[140px] cursor-pointer`,onClick:u,children:[(0,J.jsx)(o,{className:`size-10 text-primary/20`}),(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(lo,{isPlaying:t.isPlaying,isActive:s,onClick:u,size:`lg`,loading:c})})]}),(0,J.jsxs)(`div`,{className:`p-3.5 space-y-1.5 cursor-pointer`,children:[(0,J.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug line-clamp-2`,children:n.title}),n.description&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:n.description}),l&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Ie,{className:`size-3 shrink-0`}),(0,J.jsx)(`span`,{children:l})]}),(0,J.jsx)(Pr,{trackId:e.id})]})]})}function mo({event:e}){let t=Lr(),n=(0,q.useMemo)(()=>io(e),[e]),r=R(e.pubkey),i=di(r.data?.metadata,e.pubkey),a=Nr(e.id);if(!n)return null;let s=t.currentTrack?.id===e.id,c=a.status===`decrypting`,l=a=>{if(a.stopPropagation(),s&&t.isPlaying)t.pause();else if(s)t.resume();else{let a=co(e,n);a.artist=i,a.artwork??=r.data?.metadata?.picture,t.playTrack(a)}};return(0,J.jsxs)(`div`,{className:B(`mt-3 rounded-2xl border overflow-hidden`,s?`border-primary bg-primary/5`:`border-border`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[100px] relative cursor-pointer`,onClick:l,children:[(0,J.jsx)(o,{className:`size-8 text-primary/20`}),(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(lo,{isPlaying:t.isPlaying,isActive:s,onClick:l,size:`lg`,loading:c})})]}),(0,J.jsxs)(`div`,{className:`p-3.5 space-y-1 cursor-pointer`,children:[(0,J.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:n.title}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Trailer`}),(0,J.jsx)(Pr,{trackId:e.id})]})]})}function ho(){let{user:e}=z(),{nostr:t}=gt(),n=_t(),{mutateAsync:r}=yn();return yt({mutationFn:async({aTag:n,awardEventId:i})=>{if(!e)throw Error(`User is not logged in`);let a=await Bn(t,e.pubkey),o=a?.tags??[[`d`,`profile_badges`]];if(o.some(([e,t],r)=>e===`a`&&t===n&&o[r+1]?.[0]===`e`&&o[r+1]?.[1]===i))return;let s=[...o.filter(([e,t])=>!(e===`d`&&t===`profile_badges`)),[`a`,n],[`e`,i]];await r({kind:Wn,content:``,tags:s,prev:a??void 0})},onMutate:({aTag:t,awardEventId:r})=>{let i=[`profile-badges`,e?.pubkey??``];return{snapshot:hi(n,i,{kind:Wn,pubkey:e?.pubkey??``,transform:e=>e.some(([n,i],a)=>n===`a`&&i===t&&e[a+1]?.[0]===`e`&&e[a+1]?.[1]===r)?e:[...e.filter(([e,t])=>!(e===`d`&&t===`profile_badges`)),[`a`,t],[`e`,r]]}),key:i}},onError:(e,t,r)=>{r&&pi(n,r.key,r.snapshot)},onSuccess:()=>{n.invalidateQueries({queryKey:[`profile-badges`,e?.pubkey]})}})}function go({awardEvent:e,prominent:t}){let{user:n}=z(),{refs:r}=Kn(n?.pubkey),{mutate:i,isPending:a,isSuccess:o}=ho(),s=e.tags.find(([e,t])=>e===`a`&&t?.startsWith(`30009:`))?.[1],c=r.some(e=>e.aTag===s)||o;return!s||!n?null:c?(0,J.jsxs)(`span`,{className:B(`inline-flex items-center gap-1 text-muted-foreground`,t?`text-sm`:`text-xs`),children:[(0,J.jsx)(We,{className:t?`size-4`:`size-3`}),`Accepted`]}):t?(0,J.jsx)(V,{className:`rounded-full px-6 h-10 text-sm font-semibold gap-2 shadow-md hover:scale-105 active:scale-95 transition-all`,onClick:t=>{t.stopPropagation(),i({aTag:s,awardEventId:e.id})},disabled:a,style:{filter:`drop-shadow(0 2px 8px hsl(var(--primary) / 0.25))`},children:a?(0,J.jsx)(be,{className:`size-4 animate-spin`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(N,{className:`size-4`}),`Accept Badge`]})}):(0,J.jsx)(V,{size:`sm`,variant:`outline`,className:`h-7 px-2.5 text-xs font-medium gap-1 transition-colors hover:bg-primary hover:text-primary-foreground`,onClick:t=>{t.stopPropagation(),i({aTag:s,awardEventId:e.id})},disabled:a,children:a?(0,J.jsx)(be,{className:`size-3 animate-spin`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(N,{className:`size-3`}),`Accept`]})})}function _o({event:e}){let t=(0,q.useMemo)(()=>Ln(e),[e]);if(!t)return null;let n=t.image??t.thumbs.find(e=>e.dimensions===`512x512`)?.url??t.thumbs[0]?.url;return(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsxs)(`div`,{className:`relative isolate flex flex-col items-center py-10 overflow-hidden rounded-2xl`,children:[(0,J.jsx)(`div`,{className:`absolute -z-10 pointer-events-none`,"aria-hidden":`true`,style:{width:360,height:360,top:`50%`,left:`50%`,transform:`translate(-50%, -55%)`},children:(0,J.jsx)(`div`,{className:`w-full h-full animate-badge-spotlight`,style:{background:`repeating-conic-gradient( hsl(var(--primary) / 0.08) 0deg 6deg, transparent 6deg 18deg )`,maskImage:`radial-gradient(circle, black 15%, transparent 70%)`,WebkitMaskImage:`radial-gradient(circle, black 15%, transparent 70%)`}})}),(0,J.jsx)(yo,{heroImage:n,badgeName:t.name}),(0,J.jsxs)(`div`,{className:`relative z-[1] mt-4 text-center px-6 max-w-xs`,children:[(0,J.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug`,children:t.name}),t.description&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t.description})]})]})})}var vo=48;function yo({heroImage:e,badgeName:t}){let n=Rn(25,1.08),r=(0,q.useRef)(null),i=e?{maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`,maskSize:`cover`,WebkitMaskSize:`cover`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`,maskPosition:`center`,WebkitMaskPosition:`center`}:void 0,a=(0,q.useCallback)(e=>{if(e.pointerType===`touch`)return;n.onPointerMove(e);let t=n.ref.current,i=r.current;if(!t||!i)return;let a=t.getBoundingClientRect(),o=(e.clientX-a.left-vo)/(a.width-vo*2)*100,s=(e.clientY-a.top-vo)/(a.height-vo*2)*100;i.style.background=`radial-gradient(circle at ${o}% ${s}%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.08) 35%, transparent 65%)`,i.style.opacity=`1`},[n]),o=(0,q.useCallback)(e=>{if(e.pointerType===`touch`)return;n.onPointerLeave(e);let t=r.current;t&&(t.style.opacity=`0`)},[n]),s={...n.style,touchAction:`auto`,transformStyle:`preserve-3d`,padding:vo,margin:-48};return(0,J.jsxs)(`div`,{ref:n.ref,style:s,onPointerMove:a,onPointerLeave:o,className:`relative z-[1] select-none`,children:[e?(0,J.jsx)(`img`,{src:e,alt:t,className:`size-28 rounded-2xl object-cover drop-shadow-lg`,loading:`lazy`,decoding:`async`}):(0,J.jsx)(`div`,{className:`size-28 rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-transparent flex items-center justify-center`,children:(0,J.jsx)(N,{className:`size-12 text-primary/30`})}),e&&i&&(0,J.jsx)(`div`,{ref:r,className:`absolute pointer-events-none`,style:{inset:vo,opacity:0,transition:`opacity 0.4s ease-out`,mixBlendMode:`overlay`,...i},"aria-hidden":`true`})]})}function bo({event:e}){let{user:t}=z(),n=(0,q.useMemo)(()=>qn(e),[e]),r=(0,q.useMemo)(()=>In(e),[e]),i=r&&r.pubkey===e.pubkey?r:void 0,{badgeMap:a}=Un((0,q.useMemo)(()=>i?[i]:[],[i])),o=i?`${zn}:${i.pubkey}:${i.identifier}`:void 0,s=(o?a.get(o):void 0)?.event,c=(0,q.useMemo)(()=>i?I.naddrEncode({kind:zn,pubkey:i.pubkey,identifier:i.identifier}):void 0,[i]),l=t?Gn(e,t.pubkey):!1,u=n[0],d=Math.max(n.length-1,0);return(0,J.jsxs)(`div`,{className:`mt-1 space-y-2`,children:[u&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`to`}),(0,J.jsx)(xo,{pubkey:u}),d>0&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`and `,d,` `,d===1?`other`:`others`]})]}),s?c?(0,J.jsx)(H,{to:`/${c}`,className:`block`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(_o,{event:s})}):(0,J.jsx)(_o,{event:s}):(0,J.jsx)(So,{name:i?Yn(i.identifier):void 0,href:c?`/${c}`:void 0}),l&&(0,J.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,J.jsx)(go,{awardEvent:e,prominent:!0})})]})}function xo({pubkey:e}){let t=R(e),n=t.data?.metadata,r=n?.name??n?.display_name??`Anonymous`,i=jn(e,n);return t.isLoading?(0,J.jsx)(G,{className:`h-3.5 w-24 inline-block`}):(0,J.jsx)(W,{pubkey:e,asChild:!0,children:(0,J.jsx)(H,{to:i,className:`font-semibold text-foreground hover:underline truncate max-w-[14rem]`,onClick:e=>e.stopPropagation(),children:t.data?.event?(0,J.jsx)(U,{tags:t.data.event.tags,children:r}):r})})}function So({name:e,href:t}){let n=(0,J.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-dashed border-border py-10 px-6 flex flex-col items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`size-20 rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-transparent flex items-center justify-center`,children:(0,J.jsx)(N,{className:`size-8 text-primary/40`})}),e?(0,J.jsx)(`p`,{className:`text-sm font-semibold text-center`,children:e}):(0,J.jsx)(G,{className:`h-4 w-32`})]});return t?(0,J.jsx)(H,{to:t,className:`block`,onClick:e=>e.stopPropagation(),children:n}):n}function Co(e){if(!Hn(e))return null;let t=t=>e.tags.find(([e])=>e===t)?.[1],n=t(`d`);if(!n)return null;let r=t(`title`)??n,i=t(`description`),a=L(t(`image`)),o=[],s=new Set;for(let t=0;tCo(e),[e]),{badgeMap:n,isLoading:r}=Un((0,q.useMemo)(()=>t?.badges.map(e=>({pubkey:e.pubkey,identifier:e.identifier}))??[],[t])),[i,a]=(0,q.useState)(!1);if(!t)return null;let{badges:o,image:s,description:c,title:l}=t,u=o.length>wo,d=u?wo-1:wo,f=Math.max(0,o.length-d),p=i?o:o.slice(0,d);return(0,J.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[s?(0,J.jsxs)(`div`,{className:`relative isolate overflow-hidden rounded-2xl border border-border bg-black`,children:[(0,J.jsx)(`div`,{className:`aspect-[3/1] w-full`,children:(0,J.jsx)(`img`,{src:s,alt:l,className:`size-full object-cover`,loading:`lazy`,decoding:`async`})}),(0,J.jsx)(`div`,{className:`absolute inset-0 pointer-events-none bg-gradient-to-t from-black/85 via-black/30 to-transparent`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 p-4 sm:p-5 text-white`,children:[(0,J.jsx)(`h3`,{className:`text-xl sm:text-2xl font-bold leading-tight drop-shadow-md break-words`,children:l}),c&&(0,J.jsx)(`p`,{className:`text-sm text-white/85 mt-1.5 leading-snug line-clamp-2 drop-shadow break-words`,children:c})]})]}):(0,J.jsxs)(`div`,{className:`rounded-2xl border border-border bg-gradient-to-br from-primary/5 via-transparent to-primary/5 px-5 py-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(N,{className:`size-3.5`}),`Badge set`]}),(0,J.jsx)(`h3`,{className:`text-xl font-bold mt-1.5 leading-tight break-words`,children:l}),c&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5 leading-relaxed line-clamp-3 break-words`,children:c})]}),r?(0,J.jsxs)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-3`,children:[o.slice(0,d).map((e,t)=>(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,J.jsx)(G,{className:`size-12 rounded-lg`}),(0,J.jsx)(G,{className:`h-2.5 w-12`})]},`${e.aTag}-${t}`)),u&&(0,J.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-1.5`,children:(0,J.jsx)(G,{className:`size-12 rounded-lg`})})]}):p.length>0?(0,J.jsxs)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-3`,children:[p.map((e,t)=>{let r=n.get(e.aTag);return(0,J.jsxs)(H,{to:`/${I.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`,className:`flex flex-col items-center gap-1.5 group`,title:r?.description||r?.name||e.identifier,onClick:e=>e.stopPropagation(),children:[r?(0,J.jsx)(Qn,{badge:r,size:48}):(0,J.jsx)(`div`,{className:`size-12 rounded-lg border border-border bg-background flex items-center justify-center`,children:(0,J.jsx)(N,{className:`size-6 text-muted-foreground`})}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground text-center leading-tight line-clamp-2 max-w-[4.5rem] group-hover:text-foreground transition-colors`,children:r?.name||e.identifier})]},`${e.aTag}-${t}`)}),f>0&&!i&&(0,J.jsx)(`button`,{className:`flex flex-col items-center justify-center gap-1.5`,onClick:e=>{e.stopPropagation(),a(!0)},children:(0,J.jsxs)(`div`,{className:`size-12 rounded-lg bg-muted hover:bg-muted/80 flex items-center justify-center text-muted-foreground text-xs font-medium transition-colors`,children:[`+`,f]})})]}):o.length>0?(0,J.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/30 p-4 text-center text-sm text-muted-foreground`,children:[o.length,` badge`,o.length===1?``:`s`,` referenced but definitions could not be loaded.`]}):(0,J.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-secondary/20 p-4 text-center text-sm text-muted-foreground`,children:`This badge set doesn't reference any badges yet.`})]})}var Eo={sm:`size-6 text-[10px]`,md:`size-8 text-xs`},Do={sm:`-space-x-1.5`,md:`-space-x-2`};function Oo({pubkey:e,size:t=`sm`}){let{data:n}=R(e),r=n?.metadata,i=Tn(r),a=r?.name||r?.display_name||`Anonymous`,o=a.charAt(0).toUpperCase();return(0,J.jsxs)(Mr,{children:[(0,J.jsx)(Ar,{asChild:!0,children:(0,J.jsxs)(Dn,{shape:i,className:B(Eo[t],`ring-2 ring-background`),children:[(0,J.jsx)(En,{src:r?.picture}),(0,J.jsx)(wn,{className:`bg-muted text-muted-foreground`,children:o})]})}),(0,J.jsx)(jr,{side:`bottom`,className:`text-xs`,children:a})]})}function ko({pubkeys:e,maxVisible:t=5,size:n=`sm`,className:r}){let i=e.slice(0,t),a=e.length-t;return(0,J.jsxs)(`div`,{className:B(`flex items-center`,Do[n],r),children:[i.map(e=>(0,J.jsx)(Oo,{pubkey:e,size:n},e)),a>0&&(0,J.jsxs)(`span`,{className:`pl-2.5 text-xs text-muted-foreground`,children:[`+`,a]})]})}function Ao(e,t){return e.find(([e])=>e===t)?.[1]}function jo(e,t){return e.filter(([e])=>e===t)}function Mo(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=JSON.parse(t);if(typeof e.description==`string`&&e.description)return e.description;if(typeof e.name==`string`&&e.name)return e.name;if(typeof e.address==`string`&&e.address)return e.address}catch{}return e}var No=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),Po=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}),Fo=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`});function Io(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Lo(e){let t=Ao(e.tags,`start`);if(!t)return``;if(e.kind===31922){let n=new Date(t+`T00:00:00Z`);if(isNaN(n.getTime()))return t;let r=Ao(e.tags,`end`);if(r){let e=new Date(r+`T00:00:00Z`);if(!isNaN(e.getTime())&&e>n){let t=new Date(e.getTime()-864e5);if(t>n)return`${No.formatToParts(n).filter(e=>e.type!==`year`&&e.type!==`literal`||e.value===` `).map(e=>e.type===`literal`&&e.value.includes(`,`)?``:e.value).join(``).trim()} – ${No.format(t)}`}}return No.format(n)}if(e.kind===31923){let n=parseInt(t,10);if(isNaN(n))return t;let r=new Date(n*1e3),i=Ao(e.tags,`end`);if(i){let e=parseInt(i,10);if(!isNaN(e)&&e>n){let t=new Date(e*1e3);return Io(r,t)?`${Po.format(r)} – ${Fo.format(t)}`:`${Po.format(r)} – ${Po.format(t)}`}}return Po.format(r)}return t}function Ro({event:e,compact:t,className:r}){let i=(0,q.useMemo)(()=>Ao(e.tags,`title`),[e.tags]),a=(0,q.useMemo)(()=>Ao(e.tags,`image`),[e.tags]),o=(0,q.useMemo)(()=>Ao(e.tags,`location`),[e.tags]),s=(0,q.useMemo)(()=>o?Mo(o):void 0,[o]),c=(0,q.useMemo)(()=>Lo(e),[e]),l=(0,q.useMemo)(()=>jo(e.tags,`t`).map(([,e])=>e).filter(Boolean),[e.tags]),u=(0,q.useMemo)(()=>jo(e.tags,`p`),[e.tags]),d=e.content.trim().length>0,f=(0,q.useMemo)(()=>Ao(e.tags,`summary`),[e.tags]),p=(0,q.useMemo)(()=>u.map(([,e])=>e).filter(Boolean),[u]);return(0,J.jsx)(`div`,{className:B(`mt-2 rounded-xl border border-border overflow-hidden`,r),children:t?(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsxs)(`div`,{className:`relative h-[180px] overflow-hidden`,children:[(0,J.jsx)(`img`,{src:a,alt:i??`Calendar event`,className:`h-full w-full object-cover`,loading:`lazy`,decoding:`async`}),p.length>0&&(0,J.jsx)(`div`,{className:`absolute bottom-2 left-3`,children:(0,J.jsx)(ko,{pubkeys:p,maxVisible:4,size:`md`})})]}):(0,J.jsxs)(`div`,{className:`relative flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[100px]`,children:[(0,J.jsx)(n,{className:`h-10 w-10 text-primary/30`}),p.length>0&&(0,J.jsx)(`div`,{className:`absolute bottom-2 left-3`,children:(0,J.jsx)(ko,{pubkeys:p,maxVisible:4,size:`md`})})]}),(0,J.jsxs)(`div`,{className:`p-3 space-y-2`,children:[i&&(0,J.jsx)(`h3`,{className:`text-base font-bold leading-snug line-clamp-2`,children:i}),c&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(Ie,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:c})]}),(f||d)&&(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground max-h-[2.8em] overflow-hidden relative`,children:f&&!d?(0,J.jsx)(`p`,{className:`line-clamp-2`,children:f}):(0,J.jsx)(Ut,{event:e,className:`text-sm`,hideEmbedImages:!0})}),s&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg bg-secondary/50 px-3 py-2`,children:[(0,J.jsx)(Je,{className:`h-4 w-4 shrink-0 text-red-500`}),(0,J.jsx)(`span`,{className:`text-sm truncate`,children:s})]}),l.length>0&&(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.slice(0,4).map(e=>(0,J.jsx)(K,{variant:`secondary`,className:`text-[11px] px-2 py-0.5`,children:e},e))})]})]}):(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsx)(`div`,{className:`aspect-video rounded-lg overflow-hidden`,children:(0,J.jsx)(`img`,{src:a,alt:i??`Calendar event`,className:`h-full w-full object-cover`,loading:`lazy`,decoding:`async`})}):(0,J.jsx)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent py-8`,children:(0,J.jsx)(n,{className:`h-10 w-10 text-primary/30`})}),(0,J.jsxs)(`div`,{className:`space-y-2 p-3`,children:[i&&(0,J.jsx)(`h3`,{className:`text-[15px] font-semibold leading-snug`,children:i}),c&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Ie,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:c})]}),s&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Je,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:s})]}),u.length>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(he,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`span`,{children:[u.length,` `,u.length===1?`participant`:`participants`]})]}),f&&!d&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f}),d&&(0,J.jsx)(`div`,{children:(0,J.jsx)(Ut,{event:e,className:`text-sm`,hideEmbedImages:!!a})}),l.length>0&&(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:l.map(e=>(0,J.jsx)(K,{variant:`secondary`,className:`text-[11px] px-2 py-0`,children:e},e))})]})]})})}var zo=[`#a78bfa`,`#f472b6`,`#fbbf24`,`#38bdf8`,`#34d399`,`#fb7185`],Bo=[`#fbbf24`,`#a78bfa`,`#f472b6`,`#fde68a`],Vo=16,Ho=3,Uo=10,Wo=44,Go=[`❤️`,`💖`,`💕`,`💗`],Ko=130,qo=220,Jo=55,Yo=90,Xo=360,Zo=4.5,Qo=6200;function $o(){return Array.from({length:Vo},(e,t)=>({left:4+Math.random()*92,delay:Math.random()*1.2,speed:Jo+Math.random()*(Yo-Jo),size:7+Math.random()*5,color:zo[t%zo.length],sway:(Math.random()-.5)*50,spin:270+Math.random()*360,round:t%3==0}))}function es(){return Array.from({length:Ho},()=>({char:`🎈`,left:10+Math.random()*80,delay:Math.random()*.8,speed:Jo+Math.random()*(Yo-Jo),sway:(Math.random()-.5)*40,fontSize:15+Math.random()*6}))}function ts(){return Array.from({length:Wo},(e,t)=>({char:Go[t%Go.length],left:2+Math.random()*96,delay:Math.random()**2*1.1,speed:Ko+Math.random()*(qo-Ko),sway:(Math.random()-.5)*90,spin:(Math.random()-.5)*120,fontSize:16+Math.random()*16}))}function ns(){let e=Array.from({length:3},()=>({char:`👻`,left:10+Math.random()*80,delay:Math.random()*.9,speed:45+Math.random()*20,sway:(Math.random()-.5)*40,fontSize:15+Math.random()*6})),t=Array.from({length:3},()=>({char:`🦇`,left:5+Math.random()*90,delay:Math.random()*1.1,speed:75+Math.random()*25,sway:(Math.random()-.5)*90,fontSize:12+Math.random()*5}));return[...e,...t]}function rs(){return Array.from({length:Uo},(e,t)=>({char:`✦`,left:5+Math.random()*88,top:8+Math.random()*74,delay:Math.random()*1.6,duration:.9+Math.random()*.6,fontSize:10+Math.random()*10,color:Bo[t%Bo.length]}))}function is(){return Array.from({length:3},()=>({char:`🎃`,left:8+Math.random()*80,top:12+Math.random()*65,delay:Math.random()*1.4,duration:1.1+Math.random()*.5,fontSize:14+Math.random()*6}))}function as({variant:e}){let t=(0,q.useRef)(null),[n,r]=(0,q.useState)(),i=e===`hearts`,a=i?900:Xo,o=i?4:Zo;(0,q.useLayoutEffect)(()=>{let e=t.current?.offsetHeight??0;r(Math.min(e+24,a))},[a]);let s=(0,q.useMemo)(()=>e===`confetti`||e===`birthday`?$o():[],[e]),c=(0,q.useMemo)(()=>e===`birthday`?es():e===`spooky`?ns():[],[e]),l=(0,q.useMemo)(()=>e===`hearts`?ts():[],[e]),u=(0,q.useMemo)(()=>e===`sparkle`?rs():e===`spooky`?is():[],[e]),d=e=>n?Math.min(n/e,o):0;return(0,J.jsxs)(`div`,{ref:t,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 overflow-hidden motion-reduce:hidden z-10`,style:{"--celebration-distance":`${n??0}px`},children:[n!==void 0&&s.map((e,t)=>(0,J.jsx)(`span`,{className:`absolute animate-celebration-fall`,style:{top:-12,left:`${e.left}%`,width:e.size,height:e.round?e.size:e.size*.45,backgroundColor:e.color,borderRadius:e.round?`9999px`:`1px`,opacity:0,animationDelay:`${e.delay}s`,animationDuration:`${d(e.speed)}s`,"--celebration-sway":`${e.sway}px`,"--celebration-spin":`${e.spin}deg`}},`f-${t}`)),n!==void 0&&l.map((e,t)=>(0,J.jsx)(`span`,{className:`absolute animate-heart-fall select-none`,style:{top:-20,left:`${e.left}%`,fontSize:e.fontSize,lineHeight:1,opacity:0,animationDelay:`${e.delay}s`,animationDuration:`${d(e.speed)}s`,"--celebration-sway":`${e.sway}px`,"--celebration-spin":`${e.spin}deg`},children:e.char},`h-${t}`)),n!==void 0&&c.map((e,t)=>(0,J.jsx)(`span`,{className:`absolute animate-celebration-rise select-none`,style:{bottom:-20,left:`${e.left}%`,fontSize:e.fontSize,lineHeight:1,opacity:0,animationDelay:`${e.delay}s`,animationDuration:`${d(e.speed)}s`,"--celebration-sway":`${e.sway}px`},children:e.char},`b-${t}`)),u.map((e,t)=>(0,J.jsx)(`span`,{className:`absolute animate-celebration-twinkle select-none`,style:{left:`${e.left}%`,top:`${e.top}%`,fontSize:e.fontSize,lineHeight:1,color:e.color,opacity:0,animationDelay:`${e.delay}s`,animationDuration:`${e.duration}s`},children:e.char},`s-${t}`)),e===`sunrise`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`absolute inset-0 animate-celebration-glow`,style:{background:`linear-gradient(to top, rgb(251 191 36 / 0.28), rgb(251 146 60 / 0.10) 40%, transparent 65%)`,opacity:0}}),(0,J.jsx)(`div`,{className:`absolute left-1/2 animate-celebration-sun`,style:{bottom:-36,width:56,height:56,borderRadius:`9999px`,background:`radial-gradient(circle, #fde68a 0%, #fbbf24 55%, #f59e0b 100%)`,boxShadow:`0 0 32px 12px rgb(251 191 36 / 0.35)`,opacity:0}})]})]})}function os(e,t){return e.find(([e])=>e===t)?.[1]}function ss(e){return e<=3?{cols:e,rows:1}:e===4?{cols:2,rows:2}:{cols:3,rows:2}}function cs(e){let t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,r=parseInt(e.slice(5,7),16)/255,i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*i(t)+.7152*i(n)+.0722*i(r)}function ls({colors:e}){return(0,J.jsx)(`div`,{className:`flex flex-col w-full rounded-2xl overflow-hidden`,style:{height:180},children:e.map((e,t)=>(0,J.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function us({colors:e}){return(0,J.jsx)(`div`,{className:`flex w-full rounded-2xl overflow-hidden`,style:{height:180},children:e.map((e,t)=>(0,J.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function ds({colors:e}){let{cols:t}=ss(e.length);return(0,J.jsx)(`div`,{className:`grid w-full rounded-2xl overflow-hidden`,style:{height:180,gridTemplateColumns:`repeat(${t}, 1fr)`},children:e.map((e,t)=>(0,J.jsx)(`div`,{style:{backgroundColor:e}},t))})}function fs(e,t){let n=360/t,r=.5,i=e*n-90-r,a=n+r*2,o=1.5,s=[`50% 50%`];for(let e=0;e<=12;e++){let t=(i+a*e/12)*Math.PI/180,n=50+50*o*Math.cos(t),r=50+50*o*Math.sin(t);s.push(`${n}% ${r}%`)}return`polygon(${s.join(`, `)})`}function ps({colors:e}){return(0,J.jsxs)(`div`,{className:`relative w-full rounded-2xl overflow-hidden`,style:{height:180},children:[(0,J.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:e[0]}}),e.map((t,n)=>(0,J.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:t,clipPath:fs(n,e.length)}},n))]})}function ms({colors:e}){let t=e.length,n=t*Math.max(2,4-t),r=180/n,i=Math.ceil(600/r),a=[];for(let r=0;r(0,J.jsx)(`div`,{style:{backgroundColor:e}},t))})})}function hs({colors:e}){let t=580/e.length;return(0,J.jsx)(`div`,{className:`w-full rounded-2xl overflow-hidden`,style:{height:180},children:(0,J.jsx)(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 400 180`,preserveAspectRatio:`none`,xmlns:`http://www.w3.org/2000/svg`,shapeRendering:`geometricPrecision`,children:e.map((e,n)=>{let r=n*t,i=(n+1)*t,a=n*t-180,o=(n+1)*t-180;return(0,J.jsx)(`polygon`,{points:[`${r},0`,`${i},0`,`${o},180`,`${a},180`].join(` `),fill:e},n)})})})}var gs={horizontal:ls,vertical:us,grid:ds,star:ps,checkerboard:ms,diagonalStripes:hs};function _s({event:e}){let t=(0,q.useMemo)(()=>Ca(e.tags),[e.tags]),{applyCustomTheme:n}=cn(),[r,i]=(0,q.useState)(!1),a=(0,q.useId)();(0,q.useEffect)(()=>{if(r){let e=setTimeout(()=>i(!1),500);return()=>clearTimeout(e)}},[r]);let o=e=>{e.stopPropagation(),i(!0),n(Sa(t))};if(t.length===0)return null;let s=` `,c=`data:image/svg+xml,${encodeURIComponent(s)}`;return(0,J.jsxs)(`button`,{onClick:o,className:`flex items-center gap-1.5 hover:opacity-80 active:scale-95 transition-all shrink-0`,title:`Set as theme`,children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Set as theme`}),(0,J.jsxs)(`div`,{className:`relative size-9 rounded-full overflow-hidden`,id:a,children:[(0,J.jsx)(`img`,{src:c,alt:``,className:`w-9 h-9`,decoding:`async`}),r&&(0,J.jsx)(`div`,{className:`absolute inset-0 animate-eyelid-blink`,children:(0,J.jsx)(`div`,{className:`absolute rounded-full bg-background w-full h-full bottom-0 left-0`})})]})]})}function vs({event:e}){let t=(0,q.useMemo)(()=>Ca(e.tags),[e.tags]),n=os(e.tags,`layout`)??`horizontal`,r=os(e.tags,`name`),i=e.content.trim(),a=i.length>0&&[...i].length<=2&&/\p{Emoji}/u.test(i)?i:void 0,o=gs[n]??ls,s=(0,q.useMemo)(()=>t.length===0?.5:t.reduce((e,t)=>e+cs(t),0)/t.length,[t])>.5?`text-black/80`:`text-white/90`;return t.length===0?null:(0,J.jsxs)(`div`,{className:`mt-2`,children:[r&&(0,J.jsx)(`p`,{className:`text-[15px] font-medium mb-2`,children:r}),(0,J.jsxs)(`div`,{className:`relative isolate`,children:[(0,J.jsx)(o,{colors:t}),a&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,J.jsx)(`span`,{className:B(`text-4xl drop-shadow-lg select-none`,s),children:a})})]}),(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-2`,children:t.map((e,t)=>(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e)},className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono text-muted-foreground hover:bg-secondary/60 transition-colors`,title:`Copy ${e}`,children:[(0,J.jsx)(`span`,{className:`size-2.5 rounded-sm shrink-0 border border-border/40`,style:{backgroundColor:e}}),e]},t))})]})}function ys({event:e}){let t=(0,q.useMemo)(()=>{try{return Ai(Ei(e.content))}catch{return null}},[e.content]),n=Oi(e),r=ki(e),i=Ti(e,`state`),a=Ti(e,`filename`),o=Ti(e,`region`),s=Di(o,a),c=mr(e.pubkey),l=c&&n?`/memory-cards/${c}/${encodeURIComponent(n)}`:void 0,u=t?.title||Ti(e,`title`)||`(untitled save)`,d=!!t,f=r===0||i===`header`,p=(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-3 rounded-xl border border-border bg-secondary/30 p-3 transition-colors hover:bg-secondary/50`,children:[d?(0,J.jsx)(wi,{frames:t.frames,size:56}):(0,J.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground`,children:(0,J.jsx)(Ne,{className:`size-6`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-[15px] font-semibold leading-snug`,children:d?u:f?`System block`:`Continuation block`}),d&&a&&(0,J.jsx)(`p`,{className:`truncate font-mono text-xs text-muted-foreground`,children:a}),!d&&(0,J.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:f?`Header & directory`:`Part of a multi-block save`}),(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground`,children:[n&&(0,J.jsx)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5 font-mono`,children:n}),r>=0&&(0,J.jsxs)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5 font-mono`,children:[`block #`,r]}),o&&(0,J.jsxs)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5`,children:[s?`${s} `:``,o]})]})]}),l&&(0,J.jsx)(A,{className:`size-5 shrink-0 text-muted-foreground`})]});return l?(0,J.jsx)(H,{to:l,className:`block`,onClick:e=>e.stopPropagation(),children:p}):p}function bs({pubkeys:e,parentEventId:t,parentRelayHint:n,parentAuthorHint:r,label:i=`Replying to`,className:a}){let o=e.filter(Boolean),s=o.slice(0,2);return(0,J.jsxs)(`div`,{className:a||`flex items-center flex-wrap gap-x-1 text-sm text-muted-foreground mt-2 mb-1 min-w-0 overflow-hidden`,children:[t?(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsx)(`span`,{className:`shrink-0 cursor-pointer hover:underline`,children:i})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)($t,{eventId:t,relays:n?[n]:void 0,authorHint:r,className:`border-0 rounded-none`,disableHoverCards:!0})})]}):(0,J.jsx)(`span`,{className:`shrink-0`,children:i}),s.map((e,t)=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 min-w-0`,children:[(0,J.jsx)(xs,{pubkey:e}),t2&&(0,J.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`and `,o.length-2,` other`,o.length-2==1?``:`s`]})]})}function xs({pubkey:e}){let t=R(e),n=t.data?.metadata?.name||t.data?.metadata?.display_name||`Anonymous`,r=jn(e,t.data?.metadata);return t.isLoading?(0,J.jsx)(G,{className:`h-3.5 w-20 inline-block`}):(0,J.jsx)(W,{pubkey:e,asChild:!0,children:(0,J.jsxs)(H,{to:r,className:`text-primary hover:underline truncate max-w-[200px] inline-block align-bottom`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:t.data?.event?.tags??[],children:n})]})})}var Ss=`flex items-center gap-x-1 text-sm text-muted-foreground mt-2 mb-1 min-w-0 overflow-hidden`;function Cs(e){let t=e.tags.find(([e])=>e===`A`),n=e.tags.find(([e])=>e===`E`),r=e.tags.find(([e])=>e===`I`)?.[1],i=e.tags.find(([e])=>e===`K`)?.[1],a=e.tags.find(([e])=>e===`P`)?.[1];if(t){let e=t[1],n=t[2]||void 0,r=tr(e);if(r)return{type:`addr`,addr:r,rootKind:i,relayHint:n}}if(n){let e=n[1],t=n[2]||void 0,r=n[3]||a||void 0,o=bn(r)?r:void 0;if(bn(e))return{type:`event`,eventId:e,rootKind:i,relayHint:t,authorHint:o}}if(r)return{type:`external`,identifier:r,rootKind:i}}var ws={0:`a profile`,1:`a post`,3:`a follow list`,4:`an encrypted message`,6:`a repost`,7:`a reaction`,8:`a badge award`,16:`a repost`,10002:`a relay list`,20:`a photo`,21:`a video`,22:`a short video`,62:`a request to vanish`,1063:`a file`,1018:`a vote`,1068:`a poll`,1111:`a comment`,1222:`a voice message`,1311:`a live chat message`,8211:`a letter`,15683:`a Love List`,1617:`a patch`,1618:`a pull request`,1619:`a pull request update`,1621:`an issue`,1630:`a status update`,1631:`a status update`,1632:`a status update`,1633:`a status update`,2473:`a bird detection`,12473:`a Birdex`,3367:`a color moment`,7516:`a found log`,5128:`an nsite snapshot`,15128:`an nsite`,16767:`a theme`,10008:`profile badges`,30008:`a badge set`,30009:`a badge`,30023:`an article`,33953:`an ebook`,34609:`a magazine`,39731:`a magazine issue`,30030:`an emoji pack`,30054:`a podcast episode`,30055:`a podcast trailer`,3063:`a Zapstore asset`,30063:`a Zapstore release`,30311:`a stream`,30312:`a room`,30313:`a meeting`,30315:`a status`,30402:`a listing`,30617:`a repository`,30618:`a repository update`,30817:`a custom NIP`,31922:`a calendar event`,31923:`a calendar event`,31990:`an app`,32267:`a Zapstore app`,34139:`a playlist`,34236:`a short video`,34550:`a community`,35128:`an nsite`,36767:`a theme`,36787:`a track`,37381:`a Magic deck`,37516:`a treasure`,3e4:`a follow set`,30621:`a constellation`,39089:`a follow pack`,9735:`a zap`,9802:`a highlight`,39701:`a web bookmark`,8333:`a zap`,31124:`a Blobbi`,31871:`an attestation`,33863:`a fundraiser`,37849:`a quiz`,7849:`a quiz result`},Ts={0:he,1:T,4:Me,6:na,8:N,16:na,20:se,21:t,22:t,1063:Ye,1018:Ve,1068:g,1222:ue,1311:at,1617:Ye,8211:Me,15683:s,1618:te,1619:te,1621:y,1630:y,1631:dt,1632:l,1633:ne,5128:re,15128:ve,35128:ve,10008:N,30008:N,30009:N,30023:Ze,39701:M,33953:Ze,34609:m,39731:m,30030:le,30054:o,30055:o,3063:k,30063:k,30311:at,30312:rt,30313:Ee,30402:E,30617:p,30618:p,31990:k,32267:k,34236:S,36767:P,16767:P,36787:ae,34139:ae,37381:ra,37516:ia,7516:ia,3:a,10002:Te,3e4:he,39089:h,3367:ft,9735:Ke,9802:D,8333:Ke,31124:He,2473:De,12473:De,30621:P,31871:$e,33863:c,37849:r,7849:b};function Es(e){return ws[e]??`an unsupported event`}function Ds(e){if(!e)return`a post`;let t=parseInt(e,10);return isNaN(t)?e===`web`||e===`https`||e===`http`?`a link`:e===`#`?`a hashtag`:e:Es(t)}var Os={30009:`badge`,30008:`badges`,30030:`emoji pack`,36767:`theme`,16767:`theme`,3e4:`follow set`,39089:`follow pack`,37381:`deck`,37516:`treasure`,30621:`constellation`,34550:`community`,30054:`episode`,30055:`trailer`,34139:`playlist`,39701:`bookmark`},ks={32267:`on Zapstore`,30063:`Zapstore release`,3063:`Zapstore asset`};function As(e){let t=Ts[e.kind];if(Tr(e.kind)){let n=e.kind===5128?`nsite snapshot`:`nsite`,r=e.tags.find(([e])=>e===`title`)?.[1],i=e.tags.find(([e])=>e===`d`)?.[1],a=r||i;return{text:a?`${a} ${n}`:`an ${n}`,icon:t}}if(e.kind===31990){try{let n=JSON.parse(e.content)?.name||e.tags.find(([e])=>e===`name`)?.[1];if(n)return{text:`${n} app`,icon:t}}catch{}return{text:`an app`,icon:t}}let n=e.tags.find(([e])=>e===`title`)?.[1],r=e.tags.find(([e])=>e===`name`)?.[1],i=e.tags.find(([e])=>e===`d`)?.[1],a=e.tags.find(([e])=>e===`alt`)?.[1]?.trim(),o=n||r||i,s=ks[e.kind];if(s&&o)return{text:`${o} ${s}`,icon:t};let c=Os[e.kind];return c&&o?{text:`${o} ${c}`,icon:t}:ws[e.kind]&&o?{text:o,icon:t}:a?{text:a,icon:t}:{text:Es(e.kind),icon:t}}function js(e){if(e.kind>=3e4&&e.kind<4e4){let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)return`/${I.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}`}return`/${I.neventEncode({id:e.id,author:e.pubkey})}`}function X({prefix:e,className:t,loading:n,children:r}){return(0,J.jsxs)(`div`,{className:t||Ss,children:[(0,J.jsx)(`span`,{className:`shrink-0`,children:e}),n?(0,J.jsx)(G,{className:`h-3.5 w-24 inline-block`}):r]})}function Ms({display:e,link:t,hoverContent:n}){let r=e.icon;return(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsxs)(H,{to:t,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[r&&(0,J.jsx)(r,{className:`size-3.5 shrink-0`}),e.text]})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:n})]})}var Ns=new Set([`1`,`11`,`1111`,`1222`,`1244`]);function Ps(e,t){let[n,r,i]=t===`root`?[`E`,`K`,`P`]:[`e`,`k`,`p`],a=e.tags.find(([e])=>e===n),o=e.tags.find(([e])=>e===r)?.[1];if(!a&&!o)return;let s=a?.[3],c=e.tags.find(([e])=>e===i)?.[1],l=a?.[1];return{kind:o,pubkey:bn(s)?s:bn(c)?c:void 0,eventId:bn(l)?l:void 0,relayHint:a?.[2]||void 0}}function Fs({event:e,className:t}){let n=Ps(e,`parent`)??Ps(e,`root`);if(n?.kind&&Ns.has(n.kind))return(0,J.jsx)(Is,{event:e,parent:n,className:t});let r=Cs(e);if(!r)return null;switch(r.type){case`addr`:return(0,J.jsx)(Ls,{root:r,className:t});case`event`:return(0,J.jsx)(Hs,{root:r,className:t});case`external`:return(0,J.jsx)(Js,{root:r,className:t});default:return null}}function Is({event:e,parent:t,className:n}){let{data:r}=vi(t.pubkey?void 0:t.eventId,t.relayHint?[t.relayHint]:void 0),i=t.pubkey??r?.pubkey;return(0,J.jsx)(bs,{pubkeys:[i,Ps(e,`root`)?.pubkey].filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t),parentEventId:t.eventId,parentRelayHint:t.relayHint,parentAuthorHint:i,className:n})}function Ls({root:e,className:t}){return e.addr?.kind===0?(0,J.jsx)(zs,{pubkey:e.addr.pubkey,className:t}):e.addr?.kind===10008||e.addr?.kind===30008&&e.addr.identifier===`profile_badges`?(0,J.jsx)(Bs,{root:e,className:t}):e.addr?.kind===3?(0,J.jsx)(Rs,{pubkey:e.addr.pubkey,kind:3,icon:a,noun:`follow list`,className:t}):e.addr?.kind===10002?(0,J.jsx)(Rs,{pubkey:e.addr.pubkey,kind:10002,icon:Te,noun:(0,J.jsx)(dn,{id:`relayList.commentContextNoun`,defaultMessage:`relay list`}),className:t}):e.addr?.kind===33863?(0,J.jsx)(Ks,{root:e,className:t}):(0,J.jsx)(Vs,{root:e,className:t})}function Rs({pubkey:e,kind:t,icon:n,noun:r,className:i}){let a=R(e),o=a.data?.metadata,s=o?.name??o?.display_name??`Anonymous`,c=(0,q.useMemo)(()=>I.npubEncode(e),[e]),l=(0,q.useMemo)(()=>`/${I.naddrEncode({kind:t,pubkey:e,identifier:``})}`,[t,e]);return(0,J.jsxs)(X,{prefix:`Commenting on`,className:i,loading:a.isLoading,children:[(0,J.jsx)(W,{pubkey:e,asChild:!0,children:(0,J.jsxs)(H,{to:`/${c}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:a.data?.event?.tags??[],children:s}),`'s`]})}),(0,J.jsxs)(H,{to:l,className:`inline-flex items-center gap-1 text-primary hover:underline shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(n,{className:`size-3.5 shrink-0`}),r]})]})}function zs({pubkey:e,className:t}){let n=R(e),r=n.data?.metadata,i=r?.name??r?.display_name??`Anonymous`,a=(0,q.useMemo)(()=>I.npubEncode(e),[e]);return(0,J.jsx)(X,{prefix:`Commenting on`,className:t,loading:n.isLoading,children:(0,J.jsx)(W,{pubkey:e,asChild:!0,children:(0,J.jsxs)(H,{to:`/${a}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:n.data?.event?.tags??[],children:i})]})})})}function Bs({root:e,className:t}){let n=e.addr?.pubkey??``,r=R(n),i=r.data?.metadata,a=i?.name??i?.display_name??`Anonymous`,o=(0,q.useMemo)(()=>I.npubEncode(n),[n]),s=(0,q.useMemo)(()=>{if(e.addr)try{return`/${I.naddrEncode({kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier})}`}catch{return}},[e.addr]),c=e.addr?(0,J.jsx)(Dt,{addr:{kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier},className:`border-0 rounded-none`}):void 0;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,loading:r.isLoading,children:[s&&c?(0,J.jsx)(Ms,{display:{text:`profile badges`,icon:N},link:s,hoverContent:c}):(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,J.jsx)(N,{className:`size-3.5 shrink-0`}),`profile badges`]}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`by`}),(0,J.jsx)(W,{pubkey:n,asChild:!0,children:(0,J.jsxs)(H,{to:`/${o}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:r.data?.event?.tags??[],children:a})]})})]})}function Vs({root:e,className:t}){let{data:n,isLoading:r}=_i(e.addr,e.relayHint?[e.relayHint]:void 0),i=e.rootKind===`34550`||e.addr?.kind===34550?`Posted in`:`Commenting on`,a=n?As(n):{text:Ds(e.rootKind)},o=n?js(n):void 0,s=e.addr?(0,J.jsx)(Dt,{addr:{kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier},className:`border-0 rounded-none`}):void 0;return(0,J.jsx)(X,{prefix:i,className:t,loading:r,children:o&&s?(0,J.jsx)(Ms,{display:a,link:o,hoverContent:s}):o?(0,J.jsxs)(H,{to:o,className:`inline-flex items-center gap-1 text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[a.icon&&(0,J.jsx)(a.icon,{className:`size-3.5 shrink-0`}),a.text]}):(0,J.jsx)(`span`,{className:`truncate`,children:a.text})})}function Hs({root:e,className:t}){let{data:n,isLoading:r}=vi(e.eventId,e.relayHint?[e.relayHint]:void 0,e.authorHint);if(n?.kind===7)return(0,J.jsx)(Us,{event:n,className:t});if(n?.kind===1018)return(0,J.jsx)(qs,{event:n,className:t});if(n?.kind===9735||n?.kind===8333)return(0,J.jsx)(Ws,{event:n,className:t});if(n?.kind===9802)return(0,J.jsx)(Gs,{event:n,className:t});let i=n?As(n):{text:Ds(e.rootKind)},a=n?js(n):void 0,o=e.eventId?(0,J.jsx)($t,{eventId:e.eventId,relays:e.relayHint?[e.relayHint]:void 0,authorHint:e.authorHint,className:`border-0 rounded-none`,disableHoverCards:!0}):void 0;return(0,J.jsx)(X,{prefix:`Commenting on`,className:t,loading:r,children:a&&o?(0,J.jsx)(Ms,{display:i,link:a,hoverContent:o}):(0,J.jsx)(`span`,{className:`truncate`,children:i.text})})}function Us({event:e,className:t}){let n=R(e.pubkey),r=n.data?.metadata,i=di(r,e.pubkey),a=js(e),o=`/${I.npubEncode(e.pubkey)}`;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,children:[(0,J.jsx)(H,{to:a,className:`text-primary hover:underline shrink-0 cursor-pointer`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(On,{content:e.content,tags:e.tags,className:`inline-block h-[1.2em] w-[1.2em] align-text-bottom object-contain`})}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`by`}),n.isLoading?(0,J.jsx)(G,{className:`h-3.5 w-16 inline-block`}):(0,J.jsx)(W,{pubkey:e.pubkey,asChild:!0,children:(0,J.jsxs)(H,{to:o,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:n.data?.event?.tags??[],children:i})]})})]})}function Ws({event:e,className:t}){let n=(0,q.useMemo)(()=>kr(e),[e]),r=(0,q.useMemo)(()=>Or(e),[e]),{format:i}=Yt(),a=R(r||void 0),o=a.data?.metadata,s=di(o,r),c=js(e),l=(0,q.useMemo)(()=>{if(bn(r))try{return`/${I.npubEncode(r)}`}catch{return}},[r]);return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,children:[(0,J.jsxs)(H,{to:c,className:`inline-flex items-center gap-1 text-primary hover:underline shrink-0 cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(Ke,{className:`size-3.5 shrink-0 text-amber-500`}),(0,J.jsx)(`span`,{children:n>0?`${i(n)} zap`:`zap`})]}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`shrink-0`,children:`by`}),a.isLoading?(0,J.jsx)(G,{className:`h-3.5 w-16 inline-block`}):(0,J.jsx)(W,{pubkey:r,asChild:!0,children:(0,J.jsxs)(H,{to:l,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:a.data?.event?.tags??[],children:s})]})})]})]})}function Gs({event:e,className:t}){let n=R(e.pubkey),r=n.data?.metadata,i=di(r,e.pubkey),a=js(e),o=`/${I.npubEncode(e.pubkey)}`,s=(0,J.jsx)($t,{eventId:e.id,authorHint:e.pubkey,className:`border-0 rounded-none`,disableHoverCards:!0});return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,loading:n.isLoading,children:[(0,J.jsx)(W,{pubkey:e.pubkey,asChild:!0,children:(0,J.jsxs)(H,{to:o,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:n.data?.event?.tags??[],children:i}),`'s`]})}),(0,J.jsx)(Ms,{display:{text:`highlight`},link:a,hoverContent:s})]})}function Ks({root:e,className:t}){let n=e.addr?.pubkey??``,r=R(n),i=r.data?.metadata,a=di(i,n),o=(0,q.useMemo)(()=>{if(n)try{return`/${I.npubEncode(n)}`}catch{return}},[n]),s=(0,q.useMemo)(()=>{if(e.addr)try{return`/${I.naddrEncode({kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier})}`}catch{return}},[e.addr]),l=e.addr?(0,J.jsx)(Dt,{addr:{kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier},className:`border-0 rounded-none`}):void 0;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,loading:r.isLoading,children:[o?(0,J.jsx)(W,{pubkey:n,asChild:!0,children:(0,J.jsxs)(H,{to:o,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:r.data?.event?.tags??[],children:a})]})}):(0,J.jsxs)(`span`,{className:`truncate`,children:[`@`,(0,J.jsx)(U,{tags:r.data?.event?.tags??[],children:a}),`'s`]}),s&&l?(0,J.jsx)(Ms,{display:{text:`fundraiser`,icon:c},link:s,hoverContent:l}):(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,J.jsx)(c,{className:`size-3.5 shrink-0`}),`fundraiser`]})]})}function qs({event:e,className:t}){let n=R(e.pubkey),r=n.data?.metadata,i=di(r,e.pubkey),a=js(e),o=`/${I.npubEncode(e.pubkey)}`,s=Kt(e);return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,children:[n.isLoading?(0,J.jsx)(G,{className:`h-3.5 w-16 inline-block`}):(0,J.jsx)(W,{pubkey:e.pubkey,asChild:!0,children:(0,J.jsxs)(H,{to:o,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`@`,(0,J.jsx)(U,{tags:n.data?.event?.tags??[],children:i})]})}),(0,J.jsxs)(H,{to:a,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(Ve,{className:`size-3.5 shrink-0`}),s?`vote for ${s}`:`vote`]})]})}function Js({root:e,className:t}){let n=e.identifier??``;if(n.startsWith(`isbn:`))return(0,J.jsx)(Zs,{identifier:n,className:t});if(n.startsWith(`http://`)||n.startsWith(`https://`)){let e=Mt(n);return e?(0,J.jsx)(Qs,{card:e,url:n,className:t}):(0,J.jsx)(Ys,{url:n,className:t})}return n.startsWith(`iso3166:`)?(0,J.jsx)(Xs,{identifier:n,className:t}):n.startsWith(`bitcoin:tx:`)?(0,J.jsx)($s,{identifier:n,className:t}):n.startsWith(`bitcoin:address:`)?(0,J.jsx)(ec,{identifier:n,className:t}):(0,J.jsx)(X,{prefix:`Commenting on`,className:t,children:(0,J.jsx)(H,{to:`/i/${encodeURIComponent(n)}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:n})})}function Ys({url:e,className:t}){let{data:n,isLoading:r}=yi(e),i=`/i/${encodeURIComponent(e)}`,a;try{a=new URL(e).hostname.replace(/^www\./,``)}catch{a=e}let o=n?.title;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,loading:r,children:[(0,J.jsx)(er,{url:e,size:14,className:`shrink-0`}),(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsx)(H,{to:i,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:o||a})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(Tt,{url:e,className:`border-0 rounded-none`,navigateToComments:!0})})]})]})}function Xs({identifier:e,className:t}){let n=e.slice(8),r=Li(n);return(0,J.jsx)(X,{prefix:`Commenting on`,className:t,children:(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsx)(H,{to:`/i/${encodeURIComponent(e)}`,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:r?r.subdivisionName?`${r.flag} ${r.subdivisionName}`:`${r.flag} ${r.name}`:e})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-64 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,J.jsx)(`span`,{className:`text-2xl leading-none shrink-0`,role:`img`,"aria-label":r?`Flag of ${r.name}`:n,children:r?.flag??`🌍`}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Je,{className:`size-3 shrink-0`}),(0,J.jsx)(`span`,{children:r?.subdivisionName?`Region`:`Country`})]}),(0,J.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r?.subdivisionName??r?.name??n}),r?.subdivisionName&&r.name&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:r.name})]})]})})]})})}function Zs({identifier:e,className:t}){let n=e.slice(5),{data:r,isLoading:i}=Qr(n),a=`/i/${encodeURIComponent(e)}`,o=r?.title??e,s=r?.cover?.medium||r?.cover?.large,c=r?.authors?.map(e=>e.name).join(`, `);return(0,J.jsx)(X,{prefix:`Commenting on`,className:t,loading:i,children:(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsxs)(H,{to:a,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(Ze,{className:`size-3.5 shrink-0`}),o]})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-72 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[s?(0,J.jsx)(`img`,{src:s,alt:r?.title||`Book cover`,className:`w-9 h-12 rounded object-cover shrink-0`,loading:`lazy`,decoding:`async`}):(0,J.jsx)(`div`,{className:`w-9 h-12 rounded bg-secondary flex items-center justify-center shrink-0`,children:(0,J.jsx)(Ze,{className:`size-4 text-muted-foreground/40`})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(Ze,{className:`size-3 shrink-0`}),(0,J.jsx)(`span`,{children:`Book`})]}),(0,J.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r?.title||`ISBN ${n}`}),c&&(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[`by `,c]})]})]})})]})})}function Qs({card:e,url:t,className:n}){let{data:r,isLoading:i}=li((0,q.useMemo)(()=>e.kind===`multiverse`?{kind:`multiverse`,multiverseId:e.multiverseId}:{kind:`set`,set:e.set,number:e.number,lang:e.lang},[e])),a=`/i/${encodeURIComponent(t)}`,o=r?.name??`Magic card`,s=r?ni(r,`small`):void 0;return(0,J.jsx)(X,{prefix:`Commenting on`,className:n,loading:i,children:(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsxs)(H,{to:a,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ra,{className:`size-3.5 shrink-0`}),o]})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-72 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[s?(0,J.jsx)(`img`,{src:s,alt:r?.name??`Magic card`,className:`w-9 h-12 rounded object-cover shrink-0`,loading:`lazy`,decoding:`async`}):(0,J.jsx)(`div`,{className:`w-9 h-12 rounded bg-secondary flex items-center justify-center shrink-0`,children:(0,J.jsx)(ra,{className:`size-4 text-muted-foreground/40`})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(ra,{className:`size-3 shrink-0`}),(0,J.jsx)(`span`,{children:`Magic Card`})]}),(0,J.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r?.name??`Unknown card`}),r?.set_name&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:r.set_name})]})]})})]})})}function $s({identifier:e,className:t}){let n=e.slice(11),r=`/i/${encodeURIComponent(e)}`,i=n.length>19?`${n.slice(0,8)}…${n.slice(-8)}`:n;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,children:[(0,J.jsx)(we,{className:`size-3.5 shrink-0 text-orange-500`}),(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsxs)(H,{to:r,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`transaction `,(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:i})]})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(ei,{txid:n,link:r})})]})]})}function ec({identifier:e,className:t}){let n=e.slice(16),r=`/i/${encodeURIComponent(e)}`,i=n.length>19?`${n.slice(0,8)}…${n.slice(-8)}`:n;return(0,J.jsxs)(X,{prefix:`Commenting on`,className:t,children:[(0,J.jsx)(we,{className:`size-3.5 shrink-0 text-orange-500`}),(0,J.jsxs)(Xn,{openDelay:300,closeDelay:150,children:[(0,J.jsx)(Nn,{asChild:!0,children:(0,J.jsxs)(H,{to:r,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`address `,(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:i})]})}),(0,J.jsx)(Fn,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(Yr,{address:n,link:r})})]})]})}var tc=(0,q.lazy)(()=>F(()=>import(`./EmojiPackDialog-B7vGYXh6.js`).then(e=>({default:e.EmojiPackDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]))),nc=24;function rc(e){if(e.kind!==30030)return null;let t=e.tags.find(([e])=>e===`d`)?.[1];if(!t)return null;let n=e.tags.find(([e])=>e===`name`)?.[1]||t,r=e.tags.find(([e])=>e===`picture`)?.[1],i=e.tags.find(([e])=>e===`about`)?.[1],a=[];for(let t of e.tags)t[0]===`emoji`&&t[1]&&t[2]&&a.push({shortcode:t[1],url:t[2]});return{identifier:t,name:n,picture:r,about:i,emojis:a}}function ic({event:e}){let t=(0,q.useMemo)(()=>rc(e),[e]),{user:n}=z(),{nostr:r}=gt(),{mutateAsync:i}=yn(),a=_t(),{toast:o}=vn(),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),p=n?.pubkey===e.pubkey,m=vt({queryKey:[`emoji-list`,n?.pubkey],queryFn:async()=>n?(await r.query([{kinds:[10030],authors:[n.pubkey],limit:1}]))[0]??null:null,enabled:!!n,staleTime:6e4}),h=`30030:${e.pubkey}:${t?.identifier??``}`,g=(0,q.useMemo)(()=>m.data?m.data.tags.some(([e,t])=>e===`a`&&t===h):!1,[m.data,h]),_=(0,q.useCallback)(async()=>{if(!n||!t)return;c(!0);let e=[`emoji-list`,n.pubkey],r=hi(a,e,{kind:10030,pubkey:n.pubkey,transform:e=>fi(e,`a`,h)});try{let e=m.data?.tags.filter(([e])=>e===`emoji`||e===`a`)??[],n;n=g?e.filter(([e,t])=>!(e===`a`&&t===h)):[...e,[`a`,h]],await i({kind:10030,content:``,tags:n}),a.invalidateQueries({queryKey:[`emoji-list`]}),a.invalidateQueries({queryKey:[`custom-emojis`]}),o({title:g?`Pack removed`:`Pack added`,description:g?`"${t.name}" removed from your emoji collection.`:`"${t.name}" added to your emoji collection!`})}catch(t){console.error(`Failed to update emoji list:`,t),pi(a,e,r),o({title:`Failed`,description:`Could not update your emoji collection.`,variant:`destructive`})}finally{c(!1)}},[n,t,m.data,g,h,i,a,o]);if(!t)return null;let v=d?t.emojis:t.emojis.slice(0,nc),y=d?0:t.emojis.length-nc;return(0,J.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t.picture&&(0,J.jsx)(`img`,{src:t.picture,alt:t.name,className:`size-12 rounded-lg object-cover shrink-0 border border-border`,decoding:`async`}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-[15px] truncate`,children:t.name}),t.about&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2 mt-0.5`,children:t.about})]})]}),v.length>0&&(0,J.jsx)(`div`,{className:`rounded-xl border border-border bg-secondary/30 p-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[v.map(e=>(0,J.jsx)(`div`,{className:`group relative`,title:`:${e.shortcode}:`,children:(0,J.jsx)(kn,{name:e.shortcode,url:e.url,className:`size-8 object-contain rounded transition-transform group-hover:scale-125`})},e.shortcode)),y>0&&(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f(!0)},className:`flex items-center justify-center size-8 rounded bg-muted text-muted-foreground text-xs font-medium hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer`,children:[`+`,y]})]})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[n&&(0,J.jsxs)(V,{variant:g?`secondary`:`default`,size:`sm`,className:B(`h-8 text-xs gap-1.5`,g&&`text-muted-foreground`),disabled:s,onClick:_,children:[s?(0,J.jsx)(be,{className:`size-3.5 animate-spin`}):g?(0,J.jsx)(We,{className:`size-3.5`}):(0,J.jsx)(w,{className:`size-3.5`}),g?`Added`:`Add to Collection`]}),p&&(0,J.jsxs)(V,{variant:`outline`,size:`sm`,className:`h-8 text-xs gap-1.5`,onClick:()=>u(!0),children:[(0,J.jsx)(C,{className:`size-3.5`}),`Edit`]})]}),l&&(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(tc,{open:l,onOpenChange:u,editEvent:e})})]})}function ac(e,t){return e.find(([e])=>e===t)?.[1]}function oc(e,t){return e.filter(([e,n])=>e===t&&n).map(([,e])=>e)}function sc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function cc({title:e,text:t}){return!e&&!t?null:(0,J.jsxs)(`div`,{className:`mt-2.5 rounded-xl bg-secondary/50 px-3.5 py-2.5`,children:[e&&(0,J.jsx)(`p`,{className:`text-base font-semibold text-foreground break-words`,children:e}),t&&(0,J.jsx)(`p`,{className:B(`text-sm leading-relaxed text-muted-foreground break-words`,e&&`mt-1`),children:t})]})}function lc({event:e,url:t,mime:n,encryption:r,description:i}){let a=R(e.pubkey).data?.metadata,o=di(a,e.pubkey)??`Anonymous`;return(0,J.jsxs)(`div`,{className:`mt-3`,children:[(0,J.jsx)(xt,{src:t,mime:n,encryption:r,avatarUrl:a?.picture,avatarFallback:o[0]?.toUpperCase()??`?`,avatarShape:Tn(a)}),i&&(0,J.jsx)(cc,{text:i})]})}function uc({url:e,encryption:t,filename:n}){let{toast:r}=vn(),i=un(),[a,o]=(0,q.useState)(!1);return(0,J.jsxs)(V,{variant:`outline`,size:`sm`,className:`shrink-0 rounded-full gap-1.5`,onClick:async()=>{if(!a){o(!0);try{await hn(e,t,n)}catch{r({title:i.formatMessage({id:`fileMetadata.downloadFailed`,defaultMessage:`Download failed`}),description:i.formatMessage({id:`fileMetadata.decryptFailed`,defaultMessage:`This file couldn't be decrypted. Please try again.`}),variant:`destructive`})}finally{o(!1)}}},disabled:a,children:[a?(0,J.jsx)(be,{className:`size-3.5 animate-spin`}):(0,J.jsx)(j,{className:`size-3.5`}),(0,J.jsx)(dn,{id:`fileMetadata.download`,defaultMessage:`Download`})]})}function dc({event:e,compact:t}){let n=L(ac(e.tags,`url`)),r=ac(e.tags,`m`)??``,i=ac(e.tags,`alt`),a=ac(e.tags,`webxdc`),o=ac(e.tags,`dim`),s=ac(e.tags,`blurhash`),c=ac(e.tags,`thumb`)??ac(e.tags,`image`),l=ac(e.tags,`summary`),u=ac(e.tags,`size`),d=pn({algorithm:ac(e.tags,`encryption-algorithm`),key:ac(e.tags,`decryption-key`),nonce:ac(e.tags,`decryption-nonce`),hash:ac(e.tags,`ox`),mime:ac(e.tags,`m`),fallbacks:oc(e.tags,`fallback`)}),f=r.startsWith(`image/`);if(!n)return null;let p=e.content||void 0,m=i??void 0,h=n.split(`/`).pop()??`file`,g=u?sc(Number(u)):void 0;if(r===`application/x-webxdc`){let e=m?.replace(/^Webxdc app:\s*/i,``)??l??h.replace(`.xdc`,``);return(0,J.jsxs)(`div`,{className:`mt-3`,children:[(0,J.jsx)(Ct,{url:n,uuid:a,icon:c,encryption:d,showNameCard:!1}),(0,J.jsx)(cc,{title:e,text:p})]})}if(f)return(0,J.jsxs)(`div`,{className:`mt-3`,children:[(0,J.jsx)(jt,{images:[n],imetaMap:o||s||d?new Map([[n,{dim:o,blurhash:s,encryption:d}]]):void 0}),p&&!t&&(0,J.jsx)(cc,{text:p})]});if(r.startsWith(`video/`))return(0,J.jsxs)(`div`,{className:`mt-3`,children:[(0,J.jsx)(Vt,{src:n,poster:c,encryption:d,dim:o,blurhash:s,title:m}),p&&!t&&(0,J.jsx)(cc,{text:p})]});if(r.startsWith(`audio/`))return(0,J.jsx)(lc,{event:e,url:n,mime:r,encryption:d,description:p});let _=m??h,v=r?r.split(`/`).pop()?.toUpperCase():void 0;return(0,J.jsxs)(`div`,{className:`mt-3`,children:[(0,J.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3.5 p-4`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-muted shrink-0`,children:(0,J.jsx)(tt,{className:`size-6 text-muted-foreground`})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-semibold truncate`,children:_}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[v,g].filter(Boolean).join(` · `)||`File`})]}),d?(0,J.jsx)(uc,{url:n,encryption:d,filename:_}):(0,J.jsx)(V,{variant:`outline`,size:`sm`,className:`shrink-0 rounded-full gap-1.5`,asChild:!0,children:(0,J.jsxs)(`a`,{href:n,download:!0,children:[(0,J.jsx)(j,{className:`size-3.5`}),(0,J.jsx)(dn,{id:`fileMetadata.download`,defaultMessage:`Download`})]})})]})}),p&&(0,J.jsx)(cc,{text:p})]})}function fc({event:e}){let t=e.kind===3,n=R(t?e.pubkey:``),r=t?n.data?.metadata:void 0,{title:i,description:o,image:s,pubkeys:c,variant:l}=(0,q.useMemo)(()=>bi(e,{authorMetadata:r,authorDisplayName:r?.name||r?.display_name}),[e,r]),u=(0,q.useMemo)(()=>xi(e,c),[e,c]),d=(0,q.useMemo)(()=>L(s),[s]);return(0,J.jsxs)(`div`,{className:`mt-2`,children:[i&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(l===`follow-list`?a:l===`follow-set`?he:h,{className:`size-4 text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:i})]}),o&&(0,J.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-3 mb-3`,children:o}),d&&(0,J.jsx)(`div`,{className:`rounded-2xl overflow-hidden mb-3`,children:(0,J.jsx)(`img`,{src:d,alt:i,className:`w-full max-h-[200px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),(0,J.jsx)(Jt,{pubkeys:u,maxVisible:8,size:`md`})]})}function pc({entry:e,fetchInfo:t,className:n}){let r=un(),{data:i}=Da(t?e.url:void 0),a=Ci(e.url),o=i?.name?.trim()||a,s=(0,q.useMemo)(()=>L(i?.icon),[i?.icon]),c=!!(i?.limitation?.payment_required??i?.payment_required),l=!!(i?.limitation?.auth_required??i?.auth_required),u=(i?.supported_nips??[]).filter(e=>e===42||e===50),d=c||l||u.length>0,f=o!==a;return(0,J.jsxs)(`div`,{className:B(`flex items-center gap-3 px-3 py-2.5 transition-colors hover:bg-muted/40`,n),children:[(0,J.jsxs)(H,{to:`/r/${encodeURIComponent(e.url)}`,className:`flex min-w-0 flex-1 items-center gap-3 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(Dn,{className:`size-8 shrink-0 border border-border/70`,children:[(0,J.jsx)(En,{src:s,alt:r.formatMessage({id:`relayList.relayIcon`,defaultMessage:`{name} icon`},{name:o})}),(0,J.jsx)(wn,{children:(0,J.jsx)(Te,{className:`size-4 text-muted-foreground`})})]}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium leading-tight`,title:o,children:o}),f&&(0,J.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,title:a,children:a}),d&&(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[u.includes(50)&&(0,J.jsx)(K,{variant:`outline`,className:`text-[10px]`,children:`NIP-50`}),u.includes(42)&&(0,J.jsx)(K,{variant:`outline`,className:`text-[10px]`,children:`NIP-42`}),l&&(0,J.jsxs)(K,{variant:`secondary`,className:`gap-1 text-[10px]`,children:[(0,J.jsx)(Xe,{className:`size-2.5`}),(0,J.jsx)(dn,{id:`relayList.auth`,defaultMessage:`Auth`})]}),c&&(0,J.jsxs)(K,{variant:`secondary`,className:`gap-1 text-[10px]`,children:[(0,J.jsx)(Ke,{className:`size-2.5`}),(0,J.jsx)(dn,{id:`relayList.paid`,defaultMessage:`Paid`})]})]})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 text-[10px]`,children:[e.read&&(0,J.jsx)(`span`,{className:`rounded bg-green-500/10 px-1.5 py-0.5 font-medium text-green-600 dark:text-green-400`,children:(0,J.jsx)(dn,{id:`relayList.read`,defaultMessage:`Read`})}),e.write&&(0,J.jsx)(`span`,{className:`rounded bg-blue-500/10 px-1.5 py-0.5 font-medium text-blue-600 dark:text-blue-400`,children:(0,J.jsx)(dn,{id:`relayList.write`,defaultMessage:`Write`})})]})]})}var mc=5,hc=5;function gc({event:e,expanded:t}){let n=(0,q.useMemo)(()=>Si(e),[e]);return n.length===0?(0,J.jsx)(`div`,{className:`mt-2 rounded-xl border border-dashed border-border px-3 py-6 text-center`,children:(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(dn,{id:`relayList.empty`,defaultMessage:`This relay list is empty.`})})}):(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsx)(_c,{count:n.length}),t?(0,J.jsx)(vc,{relays:n}):(0,J.jsx)(Ft,{relays:n,maxVisible:hc})]})}function _c({count:e}){return(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-1`,children:[(0,J.jsx)(Te,{className:`size-4 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:(0,J.jsx)(dn,{id:`relayList.count`,defaultMessage:`{count, plural, one {# relay} other {# relays}}`,values:{count:e}})})]})}function vc({relays:e}){let[t,n]=(0,q.useState)(!1),r=e.slice(0,mc),i=e.slice(mc);return(0,J.jsxs)(`div`,{className:`divide-y divide-border/60 overflow-hidden rounded-xl border border-border`,children:[r.map(e=>(0,J.jsx)(pc,{entry:e,fetchInfo:!0},e.url)),i.length>0&&!t&&(0,J.jsx)(V,{variant:`ghost`,className:`h-auto w-full justify-center rounded-none py-2.5 text-xs font-medium text-muted-foreground hover:bg-muted/40 hover:text-foreground`,onClick:()=>n(!0),children:(0,J.jsx)(dn,{id:`relayList.showMore`,defaultMessage:`{count, plural, one {# more relay} other {# more relays}}`,values:{count:i.length}})}),i.length>0&&t&&(0,J.jsx)(`div`,{className:`p-3`,children:(0,J.jsx)(yc,{relays:i})})]})}function yc({relays:e}){return(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,J.jsx)(H,{to:`/r/${encodeURIComponent(e.url)}`,onClick:e=>e.stopPropagation(),title:e.url,className:`max-w-full truncate rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:Ci(e.url)},e.url))})}function bc(e,t){return e.find(([e])=>e===t)?.[1]}function xc(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function Sc(e){let t=bc(e,`a`);if(!t)return;let n=t.split(`:`);if(n.length<3)return;let[r,i,...a]=n,o=Number(r);if(!(!o||!bn(i)))return{kind:o,pubkey:i,identifier:a.join(`:`)}}function Cc({event:e}){let t=e.content,n=xc(e.tags,`image`).filter(e=>e.trim()!==``),r=!!bc(e.tags,`verification`),i=(0,q.useMemo)(()=>Sc(e.tags),[e.tags]),{data:a,isLoading:o}=_i(i),s=a?.tags.find(([e])=>e===`name`)?.[1],c=(0,q.useMemo)(()=>{if(i)return`/${I.naddrEncode({kind:i.kind,pubkey:i.pubkey,identifier:i.identifier})}`},[i]);return(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-2`,children:[o?(0,J.jsx)(G,{className:`h-5 w-32`}):s&&c?(0,J.jsxs)(H,{to:c,className:`flex items-center gap-1.5 text-sm font-medium text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ia,{className:`size-3.5`}),s]}):i?(0,J.jsx)(K,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:i.identifier}):null,r&&(0,J.jsxs)(K,{variant:`secondary`,className:`text-[11px] gap-1 font-medium text-green-600 dark:text-green-400`,children:[(0,J.jsx)($e,{className:`size-3`}),`Verified`]})]}),t&&(0,J.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-4`,children:t}),n.length>0&&(0,J.jsx)(`div`,{className:`mt-3 rounded-2xl overflow-hidden`,children:(0,J.jsx)(`img`,{src:n[0],alt:`Found log`,className:`w-full max-h-[300px] object-cover`,loading:`lazy`,decoding:`async`})})]})}function wc(e,t){return e.find(([e])=>e===t)?.[1]}function Tc(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function Ec({value:e,max:t=5}){return(0,J.jsx)(`div`,{className:`flex gap-0.5`,children:Array.from({length:t}).map((t,n)=>(0,J.jsx)(`div`,{className:B(`size-2 rounded-full`,n{let t=e<=`Z`?65:97;return String.fromCharCode((e.charCodeAt(0)-t+13)%26+t)})}var Oc={micro:`Micro`,small:`Small`,regular:`Regular`,large:`Large`,other:`Other`},kc={traditional:`Traditional`,multi:`Multi-cache`,mystery:`Mystery`};function Ac({event:e}){let t=wc(e.tags,`name`),n=Number(wc(e.tags,`D`)??1),r=Number(wc(e.tags,`T`)??1),i=wc(e.tags,`S`)??`other`,a=wc(e.tags,`t`)??`traditional`,o=Tc(e.tags,`g`).reduce((e,t)=>e===void 0||t.length>e.length?t:e,void 0)?.slice(0,5),s=wc(e.tags,`hint`),c=Tc(e.tags,`image`).filter(e=>e.trim()!==``),l=e.content,[u,d]=(0,q.useState)(!1),p=(0,q.useMemo)(()=>s?Dc(s):``,[s]);return(0,J.jsxs)(`div`,{className:`mt-2`,children:[t&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,J.jsx)(ia,{className:`size-4 text-primary mt-0.5 shrink-0`}),(0,J.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:t})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,J.jsx)(K,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:kc[a]??a}),(0,J.jsxs)(K,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:[(0,J.jsx)(k,{className:`size-3`}),Oc[i]??i]}),o&&(0,J.jsx)(H,{to:`/g/${o}`,onClick:e=>e.stopPropagation(),children:(0,J.jsxs)(K,{variant:`secondary`,className:`text-[11px] gap-1 font-medium hover:bg-secondary/80 transition-colors`,children:[(0,J.jsx)(Je,{className:`size-3`}),o]})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4 mb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(qe,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`D`}),(0,J.jsx)(Ec,{value:n}),(0,J.jsx)(`span`,{className:`text-xs font-medium tabular-nums`,children:n})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(f,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`T`}),(0,J.jsx)(Ec,{value:r}),(0,J.jsx)(`span`,{className:`text-xs font-medium tabular-nums`,children:r})]})]}),l&&(0,J.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-4`,children:l}),c.length>0&&(0,J.jsx)(jt,{images:c}),s&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),d(!u)},className:`flex items-center gap-1.5 mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[u?(0,J.jsx)(xe,{className:`size-3.5`}):(0,J.jsx)(Qe,{className:`size-3.5`}),u?p:`Show hint`]})]})}var jc=/^https:\/\/www\.wikidata\.org\/entity\/(Q\d+)$/;function Mc(e){for(let t of e){if(t[0]!==`i`)continue;let e=t[1];if(typeof e!=`string`)continue;let n=e.match(jc);if(n)return{id:n[1],url:e}}return null}function Nc(e){let t=e.find(([e])=>e===`alt`)?.[1];if(!t)return null;let n=t.match(/^[^:]*:\s*([^()]+?)\s*(?:\(([^)]+)\))?\s*$/);return n?{common:n[1]?.trim(),scientific:n[2]?.trim()}:{common:t}}function Pc(e,t){let n=e.find(([e])=>e===`n`)?.[1];return typeof n==`string`&&n.trim()?n.trim():t}function Fc({event:e,className:t}){let n=(0,q.useMemo)(()=>Mc(e.tags),[e.tags]),r=(0,q.useMemo)(()=>Nc(e.tags),[e.tags]),i=(0,q.useMemo)(()=>Pc(e.tags,r?.scientific),[e.tags,r?.scientific]),a=e.content.trim(),{data:o,isLoading:s}=ii(n?.id??null),c=o?.wikipediaTitle??null,{data:l,isLoading:u}=ai(c),d=s||u,f=l?.title??r?.common??`Unknown species`,p=l?.extract,m=L(l?.thumbnail?.source),h=n?`/i/${encodeURIComponent(n.url)}`:void 0,g=new Date(e.created_at*1e3).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return n?(0,J.jsxs)(`div`,{className:B(`mt-2`,t),children:[(0,J.jsx)(H,{to:h??`#`,onClick:e=>e.stopPropagation(),className:`block overflow-hidden rounded-2xl border border-border bg-card shadow-sm transition-shadow hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,J.jsxs)(`div`,{className:`flex`,children:[(0,J.jsxs)(`div`,{className:`relative w-32 shrink-0 bg-gradient-to-br from-emerald-100 via-sky-100 to-amber-100 sm:w-40 dark:from-indigo-950 dark:via-indigo-900 dark:to-amber-900/40`,children:[d?(0,J.jsx)(G,{className:`h-full w-full`}):m?(0,J.jsx)(`img`,{src:m,alt:f,className:`h-full w-full object-cover`,loading:`lazy`,decoding:`async`}):(0,J.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,J.jsx)(De,{"aria-hidden":!0,strokeWidth:1.5,className:`size-10 text-emerald-700/60 dark:text-amber-300/60`})}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-black/40 to-transparent`}),(0,J.jsx)(`div`,{className:`absolute bottom-1.5 left-2 font-mono text-[10px] uppercase tracking-wider text-white/85`,children:g})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 p-3.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`truncate text-[15px] font-semibold leading-tight`,children:f}),i&&(0,J.jsx)(`p`,{className:`mt-0.5 truncate text-xs italic text-muted-foreground`,children:i})]}),d?(0,J.jsxs)(`div`,{className:`space-y-1.5 pt-0.5`,children:[(0,J.jsx)(G,{className:`h-3 w-full`}),(0,J.jsx)(G,{className:`h-3 w-5/6`}),(0,J.jsx)(G,{className:`h-3 w-2/3`})]}):p?(0,J.jsx)(`p`,{className:`line-clamp-3 text-[13px] leading-relaxed text-muted-foreground`,children:p}):(0,J.jsxs)(`p`,{className:`text-xs italic text-muted-foreground/70`,children:[`Heard at `,new Date(e.created_at*1e3).toLocaleString(),`.`]})]}),c&&(0,J.jsx)(`div`,{onClick:e=>{e.stopPropagation(),e.preventDefault()},className:`shrink-0`,children:(0,J.jsx)(ti,{title:c,ariaLabel:`${f} recording`})})]})]})}),a&&(0,J.jsx)(`p`,{className:`mt-2 text-[15px] leading-relaxed whitespace-pre-wrap break-words`,children:a})]}):(0,J.jsx)(`div`,{className:B(`mt-2 rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground`,t),children:`Bird detection with no species reference.`})}function Ic({species:e,className:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(()=>new Map(e.map(e=>[e.entityId,`loading`])));(0,q.useEffect)(()=>{a(t=>{let n=new Map;for(let r of e)n.set(r.entityId,t.get(r.entityId)??`loading`);return n})},[e]);let o=(0,q.useCallback)((e,t)=>{a(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),s=(0,q.useMemo)(()=>Array.from(i.values()).some(e=>e===`loading`),[i]),c=(0,q.useMemo)(()=>Array.from(i.values()).filter(e=>e===`ready`).length,[i]),l=!s&&c===0,u=!l&&s&&c===0;return(0,J.jsxs)(J.Fragment,{children:[l?null:u?(0,J.jsx)(G,{className:B(`size-10 shrink-0 rounded-full`,t),"aria-hidden":!0}):(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-pressed":n,"aria-label":n?`Pause dawn chorus of ${c} species`:`Play dawn chorus of ${c} species`,className:B(`group inline-flex size-10 shrink-0 items-center justify-center rounded-full`,`bg-emerald-500 text-white shadow-md ring-1 ring-emerald-400/40`,`transition-[transform,background-color,box-shadow] duration-200`,`hover:bg-emerald-600 hover:shadow-lg active:scale-95`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/60 focus-visible:ring-offset-2`,`focus-visible:ring-offset-background`,`dark:bg-emerald-400 dark:text-emerald-950 dark:hover:bg-emerald-300`,t),children:n?(0,J.jsx)(Lc,{}):(0,J.jsx)(Le,{className:`size-4 translate-x-px fill-current`,"aria-hidden":!0})}),e.map(e=>(0,J.jsx)(Rc,{entityId:e.entityId,isPlaying:n,onStateChange:o},e.entityId))]})}function Lc(){return(0,J.jsx)(`span`,{className:`flex h-4 items-end gap-[2px]`,"aria-hidden":!0,children:[`0ms`,`120ms`,`60ms`,`180ms`].map((e,t)=>(0,J.jsx)(`span`,{className:B(`block w-[2px] rounded-full bg-current`,`h-full origin-bottom motion-safe:animate-equaliser-bar`,`motion-reduce:scale-y-75`),style:{animationDelay:e}},t))})}function Rc({entityId:e,isPlaying:t,onStateChange:n}){let{data:r,isLoading:i,isError:a}=ii(e),o=r?.wikipediaTitle??null,{data:s,isLoading:c,isError:l}=si(o),u=(0,q.useRef)(null),d=s?.audioUrl??null;return(0,q.useEffect)(()=>{if(a||!i&&!o){n(e,`missing`);return}if(i||c){n(e,`loading`);return}if(l||!d){n(e,`missing`);return}n(e,`ready`)},[e,a,i,o,c,l,d,n]),(0,q.useEffect)(()=>{let e=u.current;if(!(!e||!d))if(t)e.play().catch(()=>{});else{e.pause();try{e.currentTime=0}catch{}}},[t,d]),d?(0,J.jsx)(`audio`,{ref:u,src:d,preload:`auto`,loop:!0,className:`hidden`,"aria-hidden":!0}):null}function zc({entityUri:e,entityId:t,scientificName:n,className:r,nonInteractive:i}){let{data:a,isLoading:o}=ii(t),{data:s,isLoading:c}=ai(a?.wikipediaTitle??null),l=o||c,u=s?.title??(n||`Unknown species`),d=L(s?.thumbnail?.source),f=(0,J.jsxs)(`div`,{className:B(`group relative aspect-square overflow-hidden rounded-xl bg-gradient-to-br from-emerald-100 via-sky-100 to-amber-100 shadow-sm`,`dark:from-indigo-950 dark:via-indigo-900 dark:to-amber-900/40`,!i&&`transition-shadow hover:shadow-md focus-visible:shadow-md`,r),children:[l?(0,J.jsx)(G,{className:`absolute inset-0 h-full w-full`}):d?(0,J.jsx)(`img`,{src:d,alt:u,className:B(`absolute inset-0 h-full w-full object-cover`,!i&&`motion-safe:transition-transform motion-safe:duration-300 motion-safe:group-hover:scale-[1.03]`),loading:`lazy`,decoding:`async`}):(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(De,{"aria-hidden":!0,strokeWidth:1.5,className:`size-8 text-emerald-700/60 dark:text-amber-300/60`})}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/75 via-black/40 to-transparent pt-6`,children:(0,J.jsxs)(`div`,{className:`px-2 pb-1.5`,children:[(0,J.jsx)(`p`,{className:`truncate text-[11px] font-semibold leading-tight text-white drop-shadow sm:text-xs`,children:l&&!n?`\xA0`:u}),n&&n!==u&&(0,J.jsx)(`p`,{className:`truncate text-[10px] italic leading-tight text-white/80`,children:n})]})})]});return i?f:(0,J.jsx)(H,{to:`/i/${encodeURIComponent(e)}`,onClick:e=>e.stopPropagation(),className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-xl`,"aria-label":u,children:f})}var Bc=/^https:\/\/www\.wikidata\.org\/entity\/(Q\d+)$/;function Vc(e){let t=new Set,n=[],r=e.tags;for(let e=0;eVc(e),[e]);if(r.length===0)return(0,J.jsxs)(`div`,{className:B(`mt-2 flex items-center gap-2 rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground`,n),children:[(0,J.jsx)(De,{className:`size-4`,"aria-hidden":!0}),`Empty Birdex — no confirmed species yet.`]});if(t)return(0,J.jsxs)(`div`,{className:B(`mt-2`,n),children:[(0,J.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(De,{className:`size-4 shrink-0 text-emerald-600 dark:text-amber-300`,"aria-hidden":!0}),(0,J.jsxs)(`h3`,{className:`truncate text-[15px] font-semibold leading-tight`,children:[`Birdex`,(0,J.jsxs)(`span`,{className:`ml-1.5 text-sm font-normal text-muted-foreground`,children:[r.length,` species`]})]})]}),(0,J.jsx)(Ic,{species:r.map(({entityId:e})=>({entityId:e})),className:`shrink-0`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`,children:r.map(e=>(0,J.jsx)(zc,{entityUri:e.entityUri,entityId:e.entityId,scientificName:e.scientificName||void 0},e.entityUri))})]});let i=r.length>Hc,a=i?Hc-1:r.length,o=r.slice(-a),s=r.length-a;return(0,J.jsxs)(`div`,{className:B(`mt-2`,n),children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(De,{className:`size-4 shrink-0 text-emerald-600 dark:text-amber-300`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-[15px] font-semibold leading-tight`,children:`Birdex`}),(0,J.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`· `,r.length,` species`]})]}),(0,J.jsx)(`div`,{onClick:e=>{e.stopPropagation(),e.preventDefault()},className:`shrink-0`,children:(0,J.jsx)(Ic,{species:r.map(({entityId:e})=>({entityId:e}))})})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-4 gap-1.5 sm:grid-cols-6 md:grid-cols-8`,children:[o.map(e=>(0,J.jsx)(zc,{entityUri:e.entityUri,entityId:e.entityId,scientificName:e.scientificName||void 0},e.entityUri)),i&&(0,J.jsx)(Wc,{count:s})]})]})}function Wc({count:e}){return(0,J.jsx)(`div`,{className:`flex aspect-square items-center justify-center overflow-hidden rounded-xl border border-border bg-muted/60 text-muted-foreground`,"aria-label":`${e} more species`,children:(0,J.jsxs)(`span`,{className:`text-xs font-semibold sm:text-sm`,children:[`+`,e]})})}var Gc=(0,q.lazy)(()=>F(()=>import(`./ConstellationStarMap-BWOJ8Zrc.js`).then(e=>({default:e.ConstellationStarMap})),__vite__mapDeps([45,1,2,3,12])));function Kc(e){let t=e.tags.find(([e])=>e===`title`)?.[1]??e.tags.find(([e])=>e===`d`)?.[1]??`Untitled constellation`,n=[];for(let t of e.tags){if(t[0]!==`edge`||t.length<3)continue;let e=Number(t[1]),r=Number(t[2]);!Number.isInteger(e)||e<=0||!Number.isInteger(r)||r<=0||n.push([e,r])}return{title:t,description:e.content.trim(),edges:n}}function qc({event:e,className:t}){let{title:n,description:r,edges:i}=(0,q.useMemo)(()=>Kc(e),[e]),a=(0,q.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)try{return`https://birdstar.app/${I.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}`}catch{return}},[e]);return(0,J.jsx)(`div`,{className:B(`mt-2`,t),children:(0,J.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border bg-card shadow-sm transition-shadow hover:shadow-md`,children:[(0,J.jsx)(`div`,{className:`aspect-[4/3] w-full`,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(G,{className:`size-full`}),children:(0,J.jsx)(Gc,{edges:i,title:n})})}),(0,J.jsxs)(`div`,{className:`space-y-1.5 p-3.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-amber-500`}),(0,J.jsx)(`h3`,{className:`truncate text-[15px] font-semibold leading-tight`,children:n}),a&&(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),mn(a)},className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[`View on Birdstar`,(0,J.jsx)(ze,{"aria-hidden":!0,className:`size-3`})]})]}),r&&(0,J.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-muted-foreground`,children:r})]})]})})}var Jc=class e{pubkey;identifier;relay;constructor(e){this.pubkey=e.pubkey,this.identifier=e.identifier,this.relay=e.relay}static fromEvent(t){let n=t.tags.find(([e])=>e===`d`)?.[1]??``,r=t.tags.find(([e])=>e===`relays`)?.[1];return new e({pubkey:t.pubkey,identifier:n,relay:r})}static fromNaddr(t){let n=I.decode(t);if(n.type!==`naddr`)throw Error(`Invalid naddr: must be an addressable event pointer`);let r=n.data;return new e({pubkey:r.pubkey,identifier:r.identifier,relay:r.relays?.[0]})}toString(){let e=I.npubEncode(this.pubkey);if(this.relay)try{return`nostr://${e}/${new URL(this.relay).hostname}/${this.identifier}`}catch{}return`nostr://${e}/${this.identifier}`}toNaddr(){let e={kind:30617,pubkey:this.pubkey,identifier:this.identifier};return this.relay&&(e.relays=[this.relay]),I.naddrEncode(e)}toJSON(){return{pubkey:this.pubkey,identifier:this.identifier,relay:this.relay}}};function Yc(e){try{return`${new URL(e).origin}/favicon.ico`}catch{return}}function Xc({event:e}){let t=e.tags.find(([e])=>e===`name`)?.[1],n=e.tags.find(([e])=>e===`description`)?.[1],r=e.tags.filter(([e])=>e===`web`).map(([,e])=>L(e)).filter(e=>!!e),i=e.tags.some(([e,t])=>e===`t`&&t===`personal-fork`),a=e.tags.some(([e,t])=>e===`t`&&t===`shakespeare`),o=e.tags.find(([e])=>e===`d`)?.[1]??``,s=Jc.fromEvent(e),c=s.toString(),l=s.toNaddr(),u=a&&!!r[0],d=u?Yc(r[0]):void 0,f=t||o,[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),_=e=>{navigator.clipboard.writeText(e),g(!0),setTimeout(()=>g(!1),2e3)},v=`https://shakespeare.diy/clone?url=${encodeURIComponent(c)}`;return(0,J.jsx)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[u&&d&&!p?(0,J.jsx)(`img`,{src:d,alt:``,className:`size-5 rounded object-cover shrink-0`,loading:`lazy`,onError:()=>m(!0),decoding:`async`}):(0,J.jsx)(ye,{className:`size-4 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`font-semibold text-sm truncate leading-snug`,children:f}),i&&(0,J.jsx)(`span`,{className:`shrink-0 rounded-full border border-border px-2 py-0 text-[11px] text-muted-foreground leading-relaxed`,children:`Fork`})]}),n&&(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground line-clamp-2 leading-relaxed`,children:n}),(0,J.jsxs)(`div`,{className:`group/nostr flex items-center gap-2 rounded-lg bg-muted/50 px-2.5 py-1.5`,children:[(0,J.jsx)(`code`,{className:`flex-1 text-[11px] font-mono text-muted-foreground truncate select-all`,children:c}),(0,J.jsxs)(V,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 shrink-0 opacity-50 group-hover/nostr:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),_(c)},children:[h?(0,J.jsx)(We,{className:`size-3`}):(0,J.jsx)(_e,{className:`size-3`}),(0,J.jsx)(`span`,{className:`sr-only`,children:h?`Copied`:`Copy`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:[a&&(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90`,onClick:e=>{e.stopPropagation(),mn(v)},children:[(0,J.jsx)(Ce,{className:`size-3`}),`Edit with Shakespeare`]}),u&&(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full border border-border px-3 py-1.5 text-xs font-medium transition-colors hover:bg-secondary/60`,onClick:e=>{e.stopPropagation(),mn(r[0])},children:[(0,J.jsx)(ze,{className:`size-3`}),`Open App`]}),(0,J.jsx)(Oa,{nip19:l})]})]})})}function Zc({event:e,preview:t=!0}){let n=gr(e),r=Sr(e),i=r?.identifier??``,a=e.tags.find(([e])=>e===`c`)?.[1],o=e.tags.find(([e])=>e===`merge-base`)?.[1],s=[...n?.relay?[n.relay]:[],...r?.relay?[r.relay]:[],Sn],{data:c,isLoading:l}=vi(n?.id,s,r?.pubkey),u=c?_r(c):void 0,d=u??(n?`#${n.id.slice(0,8)}`:`a pull request`),f=n?pr({id:n.id,relays:n.relay?[n.relay]:[Sn],author:c?.pubkey}):void 0,p=pr({id:e.id,author:e.pubkey,relays:[Sn]});return(0,J.jsx)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,J.jsx)(ut,{className:`size-4 text-emerald-600 dark:text-emerald-400 shrink-0 mt-0.5`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l&&!u?(0,J.jsx)(G,{className:`h-4 w-3/4`}):(0,J.jsxs)(`span`,{className:`text-sm leading-snug`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Pushed an update to`}),` `,f?(0,J.jsx)(H,{to:`/${f}`,className:`font-semibold hover:underline break-words`,onClick:e=>e.stopPropagation(),children:d}):(0,J.jsx)(`span`,{className:`font-semibold break-words`,children:d})]}),i&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 font-mono`,children:i})]})]}),a&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-muted/50 px-2.5 py-1.5`,children:[(0,J.jsx)(O,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`New tip`}),(0,J.jsx)(`code`,{className:`ml-auto text-[11px] font-mono text-muted-foreground`,children:a.slice(0,12)})]}),!t&&o&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-muted/50 px-2.5 py-1.5`,children:[(0,J.jsx)(O,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Merge base`}),(0,J.jsx)(`code`,{className:`ml-auto text-[11px] font-mono text-muted-foreground`,children:o.slice(0,12)})]}),(0,J.jsx)(Oa,{nip19:p,className:`pt-0.5`})]})})}function Qc(e){let t=[],n=[],r;for(let[i,a]of e.tags)i===`HEAD`&&a?.startsWith(`ref: refs/heads/`)?r=a.slice(16):i.startsWith(`refs/heads/`)&&a?t.push({name:i.slice(11),commit:a}):i.startsWith(`refs/tags/`)&&a&&n.push({name:i.slice(10),commit:a});return t.sort((e,t)=>e.name===r?-1:t.name===r?1:e.name.localeCompare(t.name)),{branches:t,tags:n,headBranch:r}}function $c({event:e,preview:t=!0}){let n=e.tags.find(([e])=>e===`d`)?.[1]??``,{branches:r,tags:i,headBranch:a}=Qc(e),o=n?hr({kind:30617,pubkey:e.pubkey,identifier:n,relays:[Sn]}):void 0,s=t?4:1/0,c=r.slice(0,s),l=Math.max(0,r.length-c.length),u=t?i.slice(0,3):i,d=i.length-u.length;return(0,J.jsx)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(p,{className:`size-4 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`font-semibold text-sm truncate leading-snug font-mono`,children:n||`repository`})]}),c.length>0&&(0,J.jsxs)(`div`,{className:`rounded-lg bg-muted/50 divide-y divide-border/50 overflow-hidden`,children:[c.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,J.jsx)(p,{className:`size-3 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.name}),e.name===a&&(0,J.jsx)(K,{variant:`secondary`,className:`text-[10px] px-1.5 py-0 border-0 shrink-0`,children:`default`}),(0,J.jsx)(`code`,{className:`ml-auto text-[11px] font-mono text-muted-foreground shrink-0`,children:e.commit.slice(0,8)})]},e.name)),l>0&&(0,J.jsxs)(`div`,{className:`px-2.5 py-1.5 text-[11px] text-muted-foreground/70`,children:[`+`,l,` more`,` `,l===1?`branch`:`branches`]})]}),u.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,J.jsx)(E,{className:`size-3`}),e.name]},e.name)),d>0&&(0,J.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:[`+`,d,` more`]})]}),(0,J.jsx)(Oa,{nip19:o,className:`pt-0.5`})]})})}function el(e,t){return e.find(([e])=>e===t)?.[1]}function tl({event:e,expanded:t=!1,className:n}){let{url:r,title:i,description:a,image:o,hashtags:s,comment:c}=(0,q.useMemo)(()=>{let t=L(el(e.tags,`r`)),n=el(e.tags,`d`),r=!t&&n?L(`https://${n.replace(/^\/\//,``)}`):void 0,i=new Set,a=[];for(let[t,n]of e.tags)t!==`t`||!n||i.has(n)||(i.add(n),a.push(n));return{url:t??r,title:el(e.tags,`title`)?.trim()||void 0,description:el(e.tags,`description`)?.trim()||void 0,image:L(el(e.tags,`image`)),hashtags:a,comment:e.content.trim()}},[e.tags,e.content]),l=r?ln(r):void 0;return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[c&&(0,J.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:(0,J.jsx)(Ut,{event:e,className:B(t?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`)})}),(0,J.jsxs)(`div`,{className:B(`group overflow-hidden rounded-xl border border-border`,r&&`cursor-pointer transition-colors hover:bg-secondary/40`),role:r?`link`:void 0,tabIndex:r?0:void 0,onClick:r?e=>{e.stopPropagation(),mn(r)}:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),mn(r))}:void 0,children:[o&&(0,J.jsx)(`div`,{className:`relative w-full overflow-hidden bg-muted/30`,style:{aspectRatio:`1.91`},children:(0,J.jsx)(`img`,{src:o,alt:``,loading:`lazy`,decoding:`async`,className:`absolute inset-0 size-full object-cover`})}),(0,J.jsxs)(`div`,{className:`space-y-1 px-3.5 py-3`,children:[l&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(er,{url:r,size:14,className:`shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:l}),r&&(0,J.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-muted-foreground group-hover:text-primary`,children:[(0,J.jsx)(ze,{className:`size-3`}),(0,J.jsx)(`span`,{children:`Open`})]})]}),i&&(0,J.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:i}),a&&(0,J.jsx)(`p`,{dir:`auto`,className:B(`text-xs text-muted-foreground leading-relaxed break-words`,t?`line-clamp-4`:`line-clamp-3`),children:a}),!i&&!a&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,J.jsx)(M,{className:`size-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:r??`Web bookmark`})]})]})]}),s.length>0&&(0,J.jsx)(`div`,{className:`flex flex-wrap gap-x-1.5 gap-y-0.5`,children:s.slice(0,t?8:5).map(e=>(0,J.jsxs)(H,{to:`/t/${encodeURIComponent(e)}`,className:`text-[13px] text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]})}function nl(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return}}function rl({event:e,expanded:t=!1,className:n}){let r=e.tags.find(([e])=>e===`d`)?.[1]??`general`,i=r===`music`,a=e.content.trim(),o=(0,q.useMemo)(()=>L(e.tags.find(([e])=>e===`r`)?.[1]),[e.tags]),s=(0,q.useMemo)(()=>{let t=e.tags.find(([e])=>e===`expiration`)?.[1];if(!t)return!1;let n=parseInt(t,10);return!Number.isNaN(n)&&Math.floor(Date.now()/1e3)>n},[e.tags]),c=i?ae:le,l=i?`Listening to`:r===`general`?`Status`:`${r} status`,u=!a||s;return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(c,{className:`size-3 shrink-0`}),l]}),u?(0,J.jsx)(`div`,{className:`rounded-xl border border-dashed border-border px-4 py-3 text-center text-sm text-muted-foreground`,children:s?`This status has expired`:`No status set`}):(0,J.jsx)(`p`,{dir:`auto`,className:B(`whitespace-pre-wrap break-words font-medium text-foreground`,t?`text-[22px] leading-snug`:`text-[17px] leading-snug`),children:(0,J.jsx)(U,{tags:e.tags,children:a})}),!u&&o&&(t?(0,J.jsx)(At,{url:o,showActions:!1}):(0,J.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer nofollow ugc`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ze,{className:`size-3 shrink-0`}),nl(o)??o]}))]})}var il=30312;function al(e,t){return e.find(([e])=>e===t)?.[1]}function ol(e){switch(e){case`live`:return{label:`LIVE`,className:`bg-red-600/90 text-white border-red-600`,pulse:!0};case`open`:return{label:`OPEN`,className:`bg-green-600/90 text-white border-green-600`,pulse:!0};case`planned`:return{label:`PLANNED`,className:`bg-blue-600/90 text-white border-blue-600`,pulse:!1};case`private`:return{label:`PRIVATE`,className:`bg-amber-500/90 text-white border-amber-500`,pulse:!1};case`closed`:case`ended`:return{label:e.toUpperCase(),className:`bg-muted text-muted-foreground border-border`,pulse:!1};default:return{label:e.toUpperCase()||`UNKNOWN`,className:`bg-muted text-muted-foreground border-border`,pulse:!1}}}function sl({event:e,expanded:t}){let n=e.kind===il,r=al(e.tags,`title`)||al(e.tags,`room`)||(n?`Untitled Room`:`Untitled Meeting`),i=al(e.tags,`summary`),a=L(al(e.tags,`image`)),o=L(al(e.tags,`service`)),s=Ea(e),c=ol(s),l=al(e.tags,`current_participants`),u=al(e.tags,`starts`),d=(0,q.useMemo)(()=>{if(!u)return;let e=Number(u);if(!(!Number.isFinite(e)||e<=0))return new Date(e*1e3)},[u]),f=d&&s===`planned`,p=n?rt:Ee,{onClick:m}=ka(`/${(0,q.useMemo)(()=>{let t=al(e.tags,`d`)||``;return I.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e])}`);return(0,J.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,J.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-border`,children:a?(0,J.jsxs)(`div`,{className:`relative w-full aspect-video overflow-hidden bg-muted`,children:[(0,J.jsx)(`img`,{src:a,alt:``,className:`w-full h-full object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`}),(0,J.jsx)(`div`,{className:`absolute top-2 left-2`,children:(0,J.jsxs)(K,{variant:`outline`,className:B(`text-[10px]`,c.className),children:[c.pulse&&(0,J.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse mr-1`}),c.label]})}),l&&(0,J.jsxs)(`div`,{className:`absolute bottom-2 right-2 flex items-center gap-1 bg-black/60 text-white text-xs px-2 py-0.5 rounded`,children:[(0,J.jsx)(he,{className:`size-3`}),l]})]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 bg-muted/40`,children:[(0,J.jsx)(p,{className:`size-4 text-primary shrink-0`}),(0,J.jsxs)(K,{variant:`outline`,className:B(`text-[10px]`,c.className),children:[c.pulse&&(0,J.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse mr-1`}),c.label]}),l&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(he,{className:`size-3`}),l]})]})}),(0,J.jsxs)(`button`,{type:`button`,className:`flex items-start gap-2 text-left w-full group`,onClick:e=>{e.stopPropagation(),m()},children:[(0,J.jsx)(p,{className:`size-4 text-primary shrink-0 mt-0.5`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-sm leading-snug line-clamp-2 group-hover:underline`,children:r}),i&&(0,J.jsx)(`p`,{className:B(`text-xs text-muted-foreground mt-0.5`,t?``:`line-clamp-2`),children:i}),f&&(0,J.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground mt-1`,children:[(0,J.jsx)(Ee,{className:`size-3 shrink-0`}),d.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})]})]})]}),o&&s!==`closed`&&s!==`ended`&&(0,J.jsxs)(V,{size:`sm`,className:`w-full`,onClick:e=>{e.stopPropagation(),mn(o)},children:[(0,J.jsx)(ze,{className:`size-4 mr-1.5`}),`Join `,n?`room`:`meeting`]})]})}function cl(e){let{nostr:t}=gt(),n=Ji(e);return vt({queryKey:[`quiz-results`,e??``],queryFn:async n=>{let r=AbortSignal.any([n.signal,AbortSignal.timeout(5e3)]);return Xi((await t.query([{kinds:[Yi],"#a":[e],limit:100}],{signal:r})).filter(Wi))},enabled:!!e&&!!n,staleTime:60*1e3})}function ll(e){let{nostr:t}=gt(),{user:n}=z(),r=Ji(e);return vt({queryKey:[`quiz-my-result`,e??``,n?.pubkey??``],queryFn:async r=>{let i=AbortSignal.any([r.signal,AbortSignal.timeout(5e3)]);return Xi((await t.query([{kinds:[7849],"#a":[e],authors:[n.pubkey],limit:10}],{signal:i})).filter(Wi))[0]??null},enabled:!!e&&!!r&&!!n,staleTime:60*1e3})}function ul({quiz:e}){let{data:t,isLoading:n}=cl(e.address),{data:r}=xn(),{user:i}=z(),{friends:a,others:o}=(0,q.useMemo)(()=>{let e=new Set(r?.pubkeys??[]),n=[],a=[];for(let r of t??[])r.pubkey===i?.pubkey||e.has(r.pubkey)?n.push(r):a.push(r);return{friends:n,others:a}},[t,r?.pubkeys,i?.pubkey]);return n?(0,J.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Quiz results`,children:[(0,J.jsx)(dl,{}),Array.from({length:3}).map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border px-3 py-2.5`,children:[(0,J.jsx)(G,{className:`size-8 rounded-full`}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(G,{className:`h-3.5 w-28`}),(0,J.jsx)(G,{className:`h-3 w-20`})]})]},t))]}):!t||t.length===0?(0,J.jsxs)(`section`,{"aria-label":`Quiz results`,children:[(0,J.jsx)(dl,{}),(0,J.jsx)(`div`,{className:`mt-2 rounded-xl border border-dashed px-4 py-6 text-center text-sm text-muted-foreground`,children:`No one has shared a result yet. Be the first!`})]}):(0,J.jsxs)(`section`,{className:`space-y-3`,"aria-label":`Quiz results`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(dl,{count:t.length})}),a.length>0&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`People you follow`}),a.map(e=>(0,J.jsx)(fl,{event:e},e.id))]}),o.length>0&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[a.length>0&&(0,J.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Everyone else`}),o.map(e=>(0,J.jsx)(fl,{event:e},e.id))]})]})}function dl({count:e}){return(0,J.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold`,children:[(0,J.jsx)(he,{className:`size-4 text-muted-foreground`}),`Results`,e!==void 0&&(0,J.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,e,`)`]})]})}function fl({event:e}){let t=R(e.pubkey).data?.metadata,n=di(t,e.pubkey),r=ea(e),i=pr({id:e.id,author:e.pubkey});if(!r)return null;let a=r.outcomes.length>0?r.outcomes.map(e=>e.label).join(`, `):r.scores.map(e=>`${e.label??e.dimension}: ${e.value}`).join(` · `),o=r.outcomes.find(e=>e.image)?.image,s=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Dn,{shape:Tn(t),className:`size-8 shrink-0`,children:[(0,J.jsx)(En,{src:t?.picture,alt:n}),(0,J.jsx)(wn,{className:`bg-primary/20 text-xs text-primary`,children:n.slice(0,2).toUpperCase()})]}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n}),a&&(0,J.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:a})]}),o&&(0,J.jsx)(`img`,{src:o,alt:``,loading:`lazy`,className:`size-10 shrink-0 rounded-lg border object-cover`,decoding:`async`}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:ui(e.created_at)})]}),c=`flex w-full items-center gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors hover:bg-secondary/50`;return i?(0,J.jsx)(H,{to:`/${i}`,className:c,onClick:e=>e.stopPropagation(),children:s}):(0,J.jsx)(`div`,{className:c,children:s})}function pl(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function ml({scores:e,className:t}){if(e.length===0)return null;let n=Math.max(1,...e.map(e=>Math.abs(e.value)));return(0,J.jsx)(`div`,{className:B(`space-y-2`,t),children:e.map(e=>{let t=e.min??0,r=e.max??n,i=r-t,a=i>0?Math.min(100,Math.max(0,(e.value-t)/i*100)):100;return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.label??e.dimension}),(0,J.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:pl(e.value)})]}),(0,J.jsx)(`div`,{className:`mt-1 h-2 overflow-hidden rounded-full bg-secondary`,role:`meter`,"aria-valuenow":e.value,"aria-valuemin":t,"aria-valuemax":r,"aria-label":e.label??e.dimension,children:(0,J.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all motion-reduce:transition-none`,style:{width:`${a}%`}})})]},e.dimension)})})}var hl=`Progress`,gl=100,[_l,vl]=$n(hl),[yl,bl]=_l(hl),xl=q.forwardRef((e,t)=>{let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=wl,...o}=e;(i||i===0)&&!Dl(i)&&console.error(kl(`${i}`,`Progress`));let s=Dl(i)?i:gl;r!==null&&!Ol(r,s)&&console.error(Al(`${r}`,`Progress`));let c=Ol(r,s)?r:null,l=El(c)?a(c,s):void 0;return(0,J.jsx)(yl,{scope:n,value:c,max:s,children:(0,J.jsx)(nr.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":El(c)?c:void 0,"aria-valuetext":l,role:`progressbar`,"data-state":Tl(c,s),"data-value":c??void 0,"data-max":s,...o,ref:t})})});xl.displayName=hl;var Sl=`ProgressIndicator`,Cl=q.forwardRef((e,t)=>{let{__scopeProgress:n,...r}=e,i=bl(Sl,n);return(0,J.jsx)(nr.div,{"data-state":Tl(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:t})});Cl.displayName=Sl;function wl(e,t){return`${Math.round(e/t*100)}%`}function Tl(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}function El(e){return typeof e==`number`}function Dl(e){return El(e)&&!isNaN(e)&&e>0}function Ol(e,t){return El(e)&&!isNaN(e)&&e<=t&&e>=0}function kl(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${gl}\`.`}function Al(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${gl} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var jl=xl,Ml=Cl,Nl=q.forwardRef(({className:e,value:t,...n},r)=>(0,J.jsx)(jl,{ref:r,className:B(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,e),...n,children:(0,J.jsx)(Ml,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})}));Nl.displayName=jl.displayName;function Pl({quiz:e}){let{user:t}=z(),{data:n}=ll(e.address),[r,i]=(0,q.useState)({}),[a,o]=(0,q.useState)(0),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),d=()=>{i({}),o(0),c(!1),u(!0)};if(n&&!l&&!s){let t=ea(n);if(t)return(0,J.jsxs)(`section`,{"aria-label":`Your quiz result`,className:`rounded-2xl border bg-card p-4 sm:p-5`,children:[(0,J.jsx)(Il,{quiz:e,outcomes:t.outcomes.map(t=>e.outcomes.find(e=>e.id===t.id)??{...t,conditions:[]}),scores:t.scores}),(0,J.jsxs)(V,{variant:`outline`,size:`sm`,className:`mt-4`,onClick:d,children:[(0,J.jsx)(ct,{className:`size-4`}),`Retake quiz`]})]})}if(s)return(0,J.jsx)(Fl,{quiz:e,answers:r,isLoggedIn:!!t,onRetake:d});let f=e.questions[a],p=e.questions.length,m=r[f.id],h=a===p-1;return(0,J.jsxs)(`section`,{"aria-label":`Take this quiz`,className:`rounded-2xl border bg-card p-4 sm:p-5`,children:[(0,J.jsx)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs text-muted-foreground`,children:(0,J.jsxs)(`span`,{children:[`Question `,a+1,` of `,p]})}),(0,J.jsx)(Nl,{value:a/p*100,className:`mt-2 h-1.5`}),(0,J.jsx)(`h3`,{className:`mt-4 text-base font-semibold leading-snug`,children:f.text}),(0,J.jsx)(Ma,{value:m??``,onValueChange:e=>i(t=>({...t,[f.id]:e})),className:`mt-4 space-y-2`,children:f.options.map(t=>(0,J.jsxs)(Aa,{htmlFor:`${e.event.id}-${f.id}-${t.id}`,className:`flex cursor-pointer items-center gap-3 rounded-xl border px-4 py-3 text-sm font-normal transition-colors hover:bg-secondary/50 has-[[data-state=checked]]:border-primary has-[[data-state=checked]]:bg-primary/5`,children:[(0,J.jsx)(ja,{id:`${e.event.id}-${f.id}-${t.id}`,value:t.id}),(0,J.jsx)(`span`,{className:`break-words`,children:t.label})]},t.id))},f.id),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(V,{variant:`ghost`,size:`sm`,disabled:a===0,onClick:()=>o(e=>Math.max(0,e-1)),children:[(0,J.jsx)(st,{className:`size-4`}),`Back`]}),(0,J.jsxs)(V,{size:`sm`,disabled:!m,onClick:()=>h?c(!0):o(e=>e+1),children:[h?`See results`:`Next`,!h&&(0,J.jsx)(ge,{className:`size-4`})]})]})]})}function Fl({quiz:e,answers:t,isLoggedIn:n,onRetake:r}){let{mutate:i,isPending:a}=yn(),{user:o}=z(),{toast:s}=vn(),c=_t(),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),{scores:h,outcomes:g,resultScores:_}=(0,q.useMemo)(()=>{let n=qi(e,t);return{scores:n,outcomes:Qi(e,n),resultScores:Ll(e,n)}},[e,t]);return(0,J.jsxs)(`section`,{"aria-label":`Your quiz result`,className:`rounded-2xl border bg-card p-4 sm:p-5`,children:[(0,J.jsx)(Il,{quiz:e,outcomes:g,scores:_}),(0,J.jsxs)(`div`,{className:`mt-4 space-y-3 border-t pt-4`,children:[p?(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your result is published — your friends can see it on this quiz.`}):n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Jr,{value:l,onChange:e=>u(e.target.value),placeholder:`Add a comment to your result (optional)`,rows:2,className:`resize-none`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(Aa,{htmlFor:`include-answers-${e.event.id}`,className:`text-xs font-normal text-muted-foreground`,children:`Include my answers (lets others verify your result)`}),(0,J.jsx)(Na,{id:`include-answers-${e.event.id}`,checked:d,onCheckedChange:f})]}),(0,J.jsxs)(V,{className:`w-full`,onClick:()=>{i({kind:Yi,content:l.trim(),tags:Zi(e,h,g,{includeAnswers:d,answers:t})},{onSuccess:()=>{m(!0),s({title:`Result shared`,description:`Your quiz result has been published.`}),c.invalidateQueries({queryKey:[`quiz-results`,e.address]}),c.invalidateQueries({queryKey:[`quiz-my-result`,e.address,o?.pubkey??``]})},onError:()=>{s({title:`Failed to share result`,variant:`destructive`})}})},disabled:a,children:[(0,J.jsx)(Be,{className:`size-4`}),a?`Sharing…`:`Share result`]}),(0,J.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:`Nothing is published until you share.`})]}):(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Log in to share your result with friends.`}),(0,J.jsxs)(V,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:r,children:[(0,J.jsx)(ct,{className:`size-4`}),`Retake quiz`]})]})]})}function Il({quiz:e,outcomes:t,scores:n}){return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(h,{className:`size-3`}),`Your result`]}),t.length>0&&(0,J.jsx)(`div`,{className:`mt-2 space-y-3`,children:t.map(e=>(0,J.jsxs)(`div`,{children:[e.image&&(0,J.jsx)(`img`,{src:e.image,alt:e.label,className:`mb-2 max-h-56 w-full rounded-xl border object-cover`,decoding:`async`}),(0,J.jsx)(`p`,{className:`text-xl font-bold text-foreground`,children:e.label}),e.description&&(0,J.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:e.description})]},e.id))}),(0,J.jsx)(ml,{scores:n,className:`mt-4`}),e.scoring===`scores`&&t.length===0&&n.length===0&&(0,J.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`No scores to display.`})]})}function Ll(e,t){let n=Ki(e);return e.dimensions.map(e=>({dimension:e.id,value:t[e.id]??0,label:e.label,min:n[e.id].min,max:n[e.id].max}))}function Rl({event:e,expanded:t=!1,className:n}){let i=(0,q.useMemo)(()=>Gi(e),[e]),a=(0,q.useMemo)(()=>`/${gi(e)}`,[e]);if(!i)return(0,J.jsx)(`p`,{className:B(`mt-2 text-sm italic text-muted-foreground`,n),children:ta(e)??`This quiz could not be displayed.`});let o=i.questions.length,s=(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(r,{className:`size-3.5`}),(0,J.jsxs)(`span`,{children:[o,` `,o===1?`question`:`questions`]})]});return t?(0,J.jsxs)(`div`,{className:B(`mt-3 space-y-4`,n),children:[i.image&&(0,J.jsx)(`img`,{src:i.image,alt:``,className:`max-h-80 w-full rounded-xl border object-cover`,decoding:`async`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-xl font-bold leading-snug`,children:i.title}),i.summary&&(0,J.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:i.summary}),(0,J.jsx)(`div`,{className:`mt-2`,children:s})]}),i.description&&(0,J.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[15px] leading-relaxed text-foreground`,children:i.description}),(0,J.jsx)(Pl,{quiz:i}),(0,J.jsx)(ul,{quiz:i})]}):(0,J.jsxs)(`div`,{className:B(`mt-2 space-y-3`,n),children:[i.image&&(0,J.jsx)(`img`,{src:i.image,alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-xl border object-cover`,decoding:`async`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-bold leading-snug`,children:i.title}),(i.summary||i.description)&&(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:i.summary||i.description})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[s,(0,J.jsx)(V,{asChild:!0,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(H,{to:a,children:`Take quiz`})})]})]})}function zl({event:e,expanded:t=!1,className:n}){let r=(0,q.useMemo)(()=>ea(e),[e]),{data:i}=_i(r?{kind:$i,pubkey:r.quizPubkey,identifier:r.quizIdentifier}:void 0),a=(0,q.useMemo)(()=>i?Gi(i):null,[i]);if(!r)return(0,J.jsx)(`p`,{className:B(`mt-2 text-sm italic text-muted-foreground`,n),children:`This quiz result could not be displayed.`});let o=hr({kind:$i,pubkey:r.quizPubkey,identifier:r.quizIdentifier});return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[r.comment&&(0,J.jsx)(`p`,{dir:`auto`,className:B(`whitespace-pre-wrap break-words text-foreground`,t?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`),children:r.comment}),(0,J.jsxs)(`div`,{className:`rounded-2xl border bg-card p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(b,{className:`size-3`}),`Quiz result`,a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,children:`·`}),o?(0,J.jsx)(H,{to:`/${o}`,className:`truncate normal-case tracking-normal hover:underline`,onClick:e=>e.stopPropagation(),children:a.title}):(0,J.jsx)(`span`,{className:`truncate normal-case tracking-normal`,children:a.title})]})]}),r.outcomes.length>0&&(0,J.jsx)(`div`,{className:`mt-2 space-y-3`,children:r.outcomes.map(e=>{let n=a?.outcomes.find(t=>t.id===e.id),r=e.image??n?.image;return(0,J.jsxs)(`div`,{children:[r&&(0,J.jsx)(`img`,{src:r,alt:e.label,loading:`lazy`,className:B(`mb-2 w-full rounded-xl border object-cover`,t?`max-h-64`:`max-h-44`),decoding:`async`}),(0,J.jsx)(`p`,{className:B(`font-bold text-foreground`,t?`text-xl`:`text-lg`),children:e.label}),t&&n?.description&&(0,J.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:n.description})]},e.id)})}),r.scores.length>0&&(0,J.jsx)(ml,{scores:t||r.outcomes.length===0?r.scores:r.scores.slice(0,4),className:`mt-3`}),o&&(0,J.jsx)(V,{asChild:!0,variant:`outline`,size:`sm`,className:`mt-4`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(H,{to:`/${o}`,children:`Take this quiz`})})]})]})}function Bl(e){let{config:t}=nn(),{esploraApis:n}=t,r=e?.wallets.onchain?.value,{data:i,isLoading:a}=vt({queryKey:[`bitcoin-balance`,`campaign`,n,r??``],queryFn:({signal:e})=>Fi(r,n,e),enabled:!!r,staleTime:3e4,refetchInterval:3e4}),{data:o,isLoading:s}=vt({queryKey:[`btc-price`,n],queryFn:({signal:e})=>Ii(n,e),refetchInterval:6e4,staleTime:3e4});return{totalSats:r?i?.totalReceived??0:0,btcPrice:o,isLoading:!!r&&(a||s)}}var Vl=(0,q.lazy)(()=>F(()=>import(`./ArticleContent-DKyv8QKH.js`).then(e=>({default:e.ArticleContent})),__vite__mapDeps([46,2,1,3,47,27,48,10,4,5,6,7,18,19,49,50,8,9,11,51,52,17,53,54,55,12,13,14,15,16,56,57,58,59,21,60,20,61,62,63,64,65,28,29,66,30,40,31,67,68,69,70,71,72,32,33,34,35,73,74,24,75,76,77,78,79,25,26,36,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113])));function Hl({event:e,expanded:t=!1,className:n}){let r=(0,q.useMemo)(()=>Vi(e),[e]),{totalSats:i,btcPrice:a}=Bl(r??void 0);if(!r)return null;let o=L(r.banner),s=Bi(r.deadline),l=Ri(r),u=!r.wallets.onchain,d={...e,tags:e.tags.filter(([e])=>e!==`title`&&e!==`image`)};return(0,J.jsxs)(`div`,{className:B(t?`mt-3 space-y-4`:`mt-2 space-y-3`,n),children:[(0,J.jsx)(`div`,{className:B(`relative w-full overflow-hidden rounded-xl border border-border/70 bg-gradient-to-br from-primary/15 via-primary/5 to-secondary`,t?`aspect-[16/8]`:`aspect-[16/9]`),children:o?(0,J.jsx)(`img`,{src:o,alt:``,loading:`lazy`,decoding:`async`,className:`absolute inset-0 size-full object-cover`}):(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(c,{className:`size-12 text-primary/40`})})}),(0,J.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-medium uppercase tracking-wide text-primary`,children:[(0,J.jsx)(c,{className:`size-3`}),`Fundraiser`]})}),(0,J.jsx)(`h3`,{dir:`auto`,className:B(`font-bold leading-tight tracking-tight break-words`,t?`text-2xl sm:text-3xl`:`text-lg`),children:r.title}),r.summary&&(0,J.jsx)(`p`,{dir:`auto`,className:B(`text-muted-foreground whitespace-pre-wrap break-words`,t?`text-base`:`text-sm line-clamp-3`),children:r.summary}),u?(0,J.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)($e,{className:`size-3.5`}),(0,J.jsx)(`span`,{children:`Private campaign — totals are not public`})]}),r.goalUsd&&r.goalUsd>0&&(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Target: `,zi(r.goalUsd)]})]}):r.goalUsd&&r.goalUsd>0||i>0?(0,J.jsx)(Gl,{raisedSats:i,goalUsd:r.goalUsd,btcPrice:a}):null,(l||s)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[l&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(Je,{className:`size-3.5`}),l]}),s&&(0,J.jsxs)(`span`,{className:B(`inline-flex items-center gap-1.5`,s.isPast&&`text-destructive`),children:[(0,J.jsx)(Ee,{className:`size-3.5`}),s.label]})]})]}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wl,{event:e,wallets:r.wallets,title:r.title}),r.story.trim()&&(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(Kl,{}),children:(0,J.jsx)(Vl,{event:d,className:`text-base`})})})]})]})}function Ul(e){let{onchain:t,sp:n}=e;return t&&n?`bitcoin:${t.value}?sp=${n.value}`:t?`bitcoin:${t.value}`:n?`bitcoin:?sp=${n.value}`:``}function Wl({event:e,wallets:t,title:n}){let r=(0,q.useMemo)(()=>Ul(t),[t]),{toast:i}=vn(),{user:a}=z(),{canSignPsbt:o}=Fa(),[s,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),m=(0,q.useCallback)(async()=>{if(r)try{await mn(r)}catch{i({title:`Could not open wallet`,description:`Scan the QR code or copy the address.`,variant:`destructive`})}},[r,i]),h=(0,q.useCallback)(async()=>{try{await navigator.clipboard.writeText(r),l(!0),i({title:`Copied`,description:`Payment address copied to clipboard`}),setTimeout(()=>l(!1),2e3)}catch{i({title:`Copy failed`,description:`Please copy manually.`,variant:`destructive`})}},[r,i]),g=!!a&&o,_=(0,q.useCallback)(()=>{d(!1),requestAnimationFrame(()=>p(!0))},[]);return r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(qr,{open:u,onOpenChange:d,children:[(0,J.jsx)(Hr,{asChild:!0,children:(0,J.jsxs)(V,{type:`button`,size:`lg`,className:`w-full`,children:[(0,J.jsx)(c,{className:`size-4`}),`Donate`]})}),(0,J.jsxs)(Ur,{className:`sm:max-w-md`,children:[(0,J.jsxs)(Br,{children:[(0,J.jsxs)(Vr,{children:[`Donate to `,n]}),(0,J.jsx)(Gr,{children:g?`Zap from Ditto, open in a native wallet, or scan the QR.`:`Open in a native wallet or scan the QR.`})]}),(0,J.jsx)(`div`,{className:`flex justify-center min-w-0`,children:(0,J.jsx)(`div`,{className:`bg-white p-3 rounded-xl`,"aria-label":`Bitcoin payment QR for ${n}`,children:(0,J.jsx)(ha,{value:r,size:240,level:`M`,className:`block`})})}),(0,J.jsxs)(`button`,{type:`button`,onClick:h,className:`group flex w-full min-w-0 items-center gap-2 rounded-lg border border-border bg-secondary/40 px-3 py-2 text-left text-xs font-mono hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background`,"aria-label":`Copy payment address`,children:[(0,J.jsx)(`span`,{className:`truncate min-w-0 flex-1 text-foreground`,children:r}),s?(0,J.jsx)(We,{className:`size-4 shrink-0 text-primary`}):(0,J.jsx)(_e,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-foreground`})]}),g&&(0,J.jsxs)(V,{type:`button`,onClick:_,className:`w-full`,size:`lg`,children:[(0,J.jsx)(Ke,{className:`size-4`}),`Zap`]}),(0,J.jsxs)(V,{type:`button`,onClick:m,variant:g?`outline`:`default`,className:`w-full`,size:`lg`,children:[(0,J.jsx)(ze,{className:`size-4`}),`Open native wallet`]}),t.sp&&(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)($e,{className:`size-3.5 shrink-0 mt-0.5`}),(0,J.jsx)(`p`,{children:`Silent-payment donations are unlinkable by design and are not reflected in any public donation total.`})]})]})]}),(0,J.jsx)(Pa,{target:e,open:f,onOpenChange:p})]}):null}function Gl({raisedSats:e,goalUsd:t,btcPrice:n}){let r=!!t&&t>0,i=Ui(e,n),a=r&&i!==void 0?Math.min(100,Math.round(i/t*100)):0;return(0,J.jsxs)(`div`,{className:`space-y-1.5 text-sm`,children:[r&&(0,J.jsx)(Nl,{value:a,className:`h-2`}),(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`font-semibold`,children:[Hi(e,n),!r&&(0,J.jsx)(`span`,{className:`ml-1 font-normal text-muted-foreground`,children:`raised`})]}),r&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(_,{className:`size-3.5`}),`of `,zi(t),` goal`]})]})]})}function Kl(){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(G,{className:`h-4 w-full`}),(0,J.jsx)(G,{className:`h-4 w-5/6`}),(0,J.jsx)(G,{className:`h-4 w-4/5`})]})}function ql({event:e,recipientPubkey:t}){let n=e.kind===8333,r=Zt(n?e:void 0),i=n&&r===void 0,a=n&&r===null,o=(0,q.useMemo)(()=>n?Pt(e):[],[e,n]),s=n&&o.length>1,c=(0,q.useMemo)(()=>{if(n){if(r?.amountSats)return r.amountSats;let t=e.tags.find(([e])=>e===`amount`),n=t?.[1]?parseInt(t[1],10):0;return Number.isFinite(n)&&n>0?n:0}return Math.floor(xr(e)/1e3)},[e,n,r]),l=n?e.content.trim():yr(e),{format:u}=Yt();return(0,J.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[s?(0,J.jsx)(Yl,{pubkeys:o}):t&&bn(t)?(0,J.jsx)(Jl,{pubkey:t}):null,c>0&&(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2 flex-wrap`,children:[(0,J.jsx)(`span`,{className:`text-3xl font-bold text-amber-500 tabular-nums`,children:u(c)}),a?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`unverified`}):i?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`verifying…`}):null]}),l&&(0,J.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:l})]})}function Jl({pubkey:e}){let t=R(e),n=t.data?.metadata,r=n?.name??n?.display_name??`Anonymous`,i=(0,q.useMemo)(()=>I.npubEncode(e),[e]);return(0,J.jsxs)(`div`,{className:`flex items-center gap-x-1 text-sm text-muted-foreground min-w-0 overflow-hidden`,children:[(0,J.jsx)(Ke,{className:`size-3.5 text-amber-500 shrink-0`}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`Zapped`}),(0,J.jsx)(W,{pubkey:e,asChild:!0,children:(0,J.jsxs)(H,{to:`/${i}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,t.data?.event?(0,J.jsx)(U,{tags:t.data.event.tags,children:r}):r]})})]})}function Yl({pubkeys:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground min-w-0`,children:[(0,J.jsx)(Ke,{className:`size-3.5 text-amber-500 shrink-0`}),(0,J.jsxs)(`span`,{className:`shrink-0`,children:[`Zapped `,e.length,` `,e.length===1?`person`:`people`]}),(0,J.jsx)(Jt,{pubkeys:e,size:`sm`,maxVisible:5})]})}var Xl=`nostr:nsite-permissions`;function Zl(){try{let e=localStorage.getItem(Xl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Ql(e){localStorage.setItem(Xl,JSON.stringify(e)),window.dispatchEvent(new Event(`nsite-permissions-changed`))}function $l(e,t,n){return e.find(e=>e.siteId===t&&e.userPubkey===n)}function eu(e,t,n,r=null){let i=$l(Zl(),e,t);if(!i)return`ask`;let a=i.permissions.find(e=>e.type===n?n===`signEvent`?e.kind===r:!0:!1);return a?a.allowed?`allow`:`deny`:`ask`}function tu(e,t,n,r,i,a){let o=Zl(),s=$l(o,e,t);s||(s={siteId:e,siteName:n,userPubkey:t,permissions:[],createdAt:Date.now()},o.push(s));let c=s.permissions.findIndex(e=>e.type===r?r===`signEvent`?e.kind===i:!0:!1),l={type:r,kind:i,allowed:a};c>=0?s.permissions[c]=l:s.permissions.push(l),Ql(o)}function nu(e,t,n,r){let i=Zl(),a=$l(i,e,t);if(a){if(a.permissions=a.permissions.filter(e=>e.type===n?n===`signEvent`?e.kind!==r:!1:!0),a.permissions.length===0){let e=i.indexOf(a);e>=0&&i.splice(e,1)}Ql(i)}}function ru(e,t){Ql(Zl().filter(n=>!(n.siteId===e&&n.userPubkey===t)))}function iu(e,t){return $l(Zl(),e,t)}function au(e,t){switch(e){case`signEvent`:return t===null?`Sign event`:`Sign: ${gn(t)}`;case`nip04.encrypt`:return`Encrypt (NIP-04)`;case`nip04.decrypt`:return`Decrypt (NIP-04)`;case`nip44.encrypt`:return`Encrypt (NIP-44)`;case`nip44.decrypt`:return`Decrypt (NIP-44)`}}var ou=`nostr:nsite-permissions`;function su(e){let t=t=>{t.key===ou&&e()};window.addEventListener(`storage`,t);let n=()=>e();return window.addEventListener(`nsite-permissions-changed`,n),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(`nsite-permissions-changed`,n)}}var cu=null;function lu(){let e=localStorage.getItem(ou);return e!==cu&&(cu=e),cu}function uu({siteId:e}){let{user:t}=z();(0,q.useSyncExternalStore)(su,lu);let n=(t?iu(e,t.pubkey):void 0)?.permissions??[],r=(0,q.useCallback)(n=>{t&&nu(e,t.pubkey,n.type,n.kind)},[e,t]),i=(0,q.useCallback)(()=>{t&&ru(e,t.pubkey)},[e,t]);if(!t)return null;let a=n.length>0;return(0,J.jsxs)(cr,{children:[(0,J.jsx)(or,{asChild:!0,children:(0,J.jsx)(V,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 ${a?`text-primary`:``}`,title:`Site permissions`,children:(0,J.jsx)(Xe,{className:`size-3.5`})})}),(0,J.jsxs)(sr,{align:`end`,className:`w-80 p-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium truncate`,children:`Permissions`}),a&&(0,J.jsx)(V,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive`,onClick:i,children:`Revoke all`})]}),(0,J.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:a?(0,J.jsx)(`div`,{className:`divide-y`,children:n.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-sm flex-1 min-w-0 truncate`,children:au(e.type,e.kind)}),(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 text-muted-foreground hover:text-destructive transition-colors`,onClick:()=>r(e),title:`Remove`,children:(0,J.jsx)(pe,{className:`size-3.5`})})]},`${e.type}-${e.kind}`))}):(0,J.jsxs)(`div`,{className:`px-4 py-6 text-center`,children:[(0,J.jsx)(Xe,{className:`size-8 text-muted-foreground/30 mx-auto mb-2`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No permissions granted`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`Permissions will appear here when the app requests them.`})]})})]})]})}function du(e){switch(e){case`signEvent`:return(0,J.jsx)(ee,{className:`size-5 text-amber-500`});case`nip04.encrypt`:case`nip44.encrypt`:return(0,J.jsx)(Ue,{className:`size-5 text-blue-500`});case`nip04.decrypt`:case`nip44.decrypt`:return(0,J.jsx)(fe,{className:`size-5 text-violet-500`})}}function fu(e,t){switch(e){case`signEvent`:return t===null?`Sign event`:`Sign: ${gn(t)}`;case`nip04.encrypt`:return`Encrypt message (NIP-04)`;case`nip04.decrypt`:return`Decrypt message (NIP-04)`;case`nip44.encrypt`:return`Encrypt message (NIP-44)`;case`nip44.decrypt`:return`Decrypt message (NIP-44)`}}function pu(e){switch(e){case`signEvent`:return`This app wants to sign a Nostr event on your behalf.`;case`nip04.encrypt`:case`nip44.encrypt`:return`This app wants to encrypt a message using your keys.`;case`nip04.decrypt`:case`nip44.decrypt`:return`This app wants to decrypt a message using your keys.`}}function mu(e,t){return e.length<=t?e:e.slice(0,t)+`…`}function hu({appPicture:e,appName:t,siteUrl:n,prompt:r,onResolve:i}){let[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),l=()=>i({allowed:!0,remember:a}),u=()=>i({allowed:!1,remember:a}),d=du(r.type),f=fu(r.type,r.kind),p=pu(r.type),m=r.event?.content,h=r.event?JSON.stringify(r.event,null,2):null;return(0,J.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm p-4`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border bg-card shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-200`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 px-5 pt-5 pb-3`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-muted`,children:(0,J.jsx)(er,{url:n,size:22,fallback:(0,J.jsx)(Se,{className:`size-5 text-muted-foreground`})})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-semibold truncate`,children:t}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Permission request`})]}),e&&(0,J.jsx)(`img`,{src:e,alt:t,className:`size-8 rounded-md object-cover shrink-0`,decoding:`async`})]}),(0,J.jsxs)(`div`,{className:`px-5 pb-4 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg bg-muted/50`,children:[(0,J.jsx)(`div`,{className:`shrink-0 mt-0.5`,children:d}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:f}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:p})]})]}),r.type===`signEvent`&&m&&(0,J.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-3`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Content`}),(0,J.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:mu(m,280)})]}),h&&(0,J.jsxs)(ar,{open:s,onOpenChange:c,children:[(0,J.jsx)(ir,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:s?`Hide details`:`Show details`})}),(0,J.jsx)(rr,{children:(0,J.jsx)(`pre`,{className:`mt-2 rounded-lg border bg-muted/30 p-3 text-xs font-mono max-h-40 overflow-auto whitespace-pre-wrap break-all`,children:h})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,J.jsx)(Ia,{id:`nsite-remember`,checked:a,onCheckedChange:e=>o(e===!0)}),(0,J.jsx)(Aa,{htmlFor:`nsite-remember`,className:`text-xs text-muted-foreground cursor-pointer select-none`,children:`Remember for this site`})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-2 px-5 pb-5`,children:[(0,J.jsxs)(V,{variant:`outline`,className:`flex-1 gap-1.5`,onClick:u,children:[(0,J.jsx)(pe,{className:`size-3.5`}),`Deny`]}),(0,J.jsxs)(V,{className:`flex-1 gap-1.5`,onClick:l,children:[(0,J.jsx)(We,{className:`size-3.5`}),`Allow`]})]})]})})}function gu({siteId:e,siteName:t}){let{user:n}=z(),[r,i]=(0,q.useState)(null),a=(0,q.useRef)(null),o=(0,q.useCallback)(e=>new Promise((t,n)=>{a.current={resolve:t,reject:n},i(e)}),[]),s=(0,q.useCallback)(e=>{a.current&&=(a.current.resolve(e),null),i(null)},[]),c=(0,q.useCallback)(async(r,i,a)=>{if(!n)throw Error(`Not logged in`);let s=eu(e,n.pubkey,r,i);if(s===`allow`)return;if(s===`deny`)throw Error(`User rejected`);let c=await o(a);if(c.remember&&tu(e,n.pubkey,t,r,i,c.allowed),!c.allowed)throw Error(`User rejected`)},[e,t,n,o]);return{onRpc:(0,q.useCallback)(async(e,t)=>{if(!n)throw Error(`Not logged in`);let r=n.signer,i=t??{};switch(e){case`nostr.getPublicKey`:return n.pubkey;case`nostr.signEvent`:{let e=i.event;if(!e||typeof e.kind!=`number`)throw Error(`Invalid event`);let t=e.kind;await c(`signEvent`,t,{type:`signEvent`,kind:t,event:e});let n={kind:e.kind,content:e.content??``,tags:e.tags??[],created_at:e.created_at??Math.floor(Date.now()/1e3)};return await r.signEvent(n)}case`nostr.nip04.encrypt`:{if(!r.nip04)throw Error(`Signer does not support NIP-04`);let e=i.pubkey,t=i.plaintext;if(!e||typeof t!=`string`)throw Error(`Invalid params`);return await c(`nip04.encrypt`,null,{type:`nip04.encrypt`,kind:null}),await r.nip04.encrypt(e,t)}case`nostr.nip04.decrypt`:{if(!r.nip04)throw Error(`Signer does not support NIP-04`);let e=i.pubkey,t=i.ciphertext;if(!e||typeof t!=`string`)throw Error(`Invalid params`);return await c(`nip04.decrypt`,null,{type:`nip04.decrypt`,kind:null}),await r.nip04.decrypt(e,t)}case`nostr.nip44.encrypt`:{if(!r.nip44)throw Error(`Signer does not support NIP-44`);let e=i.pubkey,t=i.plaintext;if(!e||typeof t!=`string`)throw Error(`Invalid params`);return await c(`nip44.encrypt`,null,{type:`nip44.encrypt`,kind:null}),await r.nip44.encrypt(e,t)}case`nostr.nip44.decrypt`:{if(!r.nip44)throw Error(`Signer does not support NIP-44`);let e=i.pubkey,t=i.ciphertext;if(!e||typeof t!=`string`)throw Error(`Invalid params`);return await c(`nip44.decrypt`,null,{type:`nip44.decrypt`,kind:null}),await r.nip44.decrypt(e,t)}default:throw Error(`Method not found: ${e}`)}},[n,c]),pendingPrompt:r,resolvePrompt:s}}function _u(e){return`(function() { 'use strict'; // ------------------------------------------------------------------ // Serial queue — one RPC at a time to avoid concurrent prompts // ------------------------------------------------------------------ var _queue = []; var _running = false; function enqueue(fn) { return new Promise(function(resolve, reject) { _queue.push({ fn: fn, resolve: resolve, reject: reject }); drain(); }); } function drain() { if (_running || _queue.length === 0) return; _running = true; var item = _queue.shift(); item.fn().then( function(v) { _running = false; item.resolve(v); drain(); }, function(e) { _running = false; item.reject(e); drain(); } ); } // ------------------------------------------------------------------ // JSON-RPC transport over postMessage // ------------------------------------------------------------------ var _nextId = 1; var _pending = {}; window.addEventListener('message', function(event) { var msg = event.data; if (!msg || typeof msg !== 'object' || msg.jsonrpc !== '2.0') return; if (msg.id === undefined || msg.id === null) return; var cb = _pending[msg.id]; if (!cb) return; delete _pending[msg.id]; if (msg.error) { cb.reject(new Error(msg.error.message || 'RPC error')); } else { cb.resolve(msg.result); } }); function rpc(method, params) { return enqueue(function() { return new Promise(function(resolve, reject) { var id = _nextId++; _pending[id] = { resolve: resolve, reject: reject }; window.parent.postMessage({ jsonrpc: '2.0', id: id, method: method, params: params || {} }, '*'); }); }); } // ------------------------------------------------------------------ // NIP-07 provider // ------------------------------------------------------------------ var pubkey = ${JSON.stringify(e)}; window.nostr = { getPublicKey: function() { return Promise.resolve(pubkey); }, signEvent: function(event) { return rpc('nostr.signEvent', { event: event }); }, getRelays: function() { return Promise.resolve({}); }, nip04: { encrypt: function(pubkey, plaintext) { return rpc('nostr.nip04.encrypt', { pubkey: pubkey, plaintext: plaintext }); }, decrypt: function(pubkey, ciphertext) { return rpc('nostr.nip04.decrypt', { pubkey: pubkey, ciphertext: ciphertext }); } }, nip44: { encrypt: function(pubkey, plaintext) { return rpc('nostr.nip44.encrypt', { pubkey: pubkey, plaintext: plaintext }); }, decrypt: function(pubkey, ciphertext) { return rpc('nostr.nip44.decrypt', { pubkey: pubkey, ciphertext: ciphertext }); } } }; // Signal availability to the nsite. try { window.dispatchEvent(new Event('nostr:ready')); } catch(e) {} })();`}function vu(){return`(function() { 'use strict'; if (window.location.pathname === '/index.html') { history.replaceState(null, '', '/'); } })();`}function yu(e){let[t,n]=(0,q.useState)(null);return(0,q.useEffect)(()=>{if(!e){n(null);return}let t=()=>{let t=e.getBoundingClientRect();n({left:t.left,top:t.top,width:t.width,height:t.height})};t();let r=new ResizeObserver(t);return r.observe(e),window.addEventListener(`resize`,t),()=>{r.disconnect(),window.removeEventListener(`resize`,t)}},[e]),t}function bu(e){let t=new Map;for(let n of e.tags)n[0]===`path`&&n[1]&&n[2]&&t.set(n[1],n[2]);return t}function xu(e,t){let n=e.tags.filter(([e])=>e===`server`).map(([,e])=>e).filter(e=>{try{return new URL(e),!0}catch{return!1}});return n.length>0?n:t}var Su=null;async function Cu(e,t){let n;async function r(t){let r=`${t.replace(/\/+$/,``)}/${e}`;try{let e=await fetch(r);if(e.ok)return Su=t,e}catch(e){n=e}return null}if(Su&&t.includes(Su)){let e=await r(Su);if(e)return e}for(let e of t){if(e===Su)continue;let t=await r(e);if(t)return t}throw n??Error(`Failed to fetch blob ${e} from all servers`)}function wu({event:e,appName:t,appPicture:n,open:r,onOpenChange:i}){let a=fa(),o=yu(r?a:null),{config:s}=nn(),{user:c}=z(),{toast:l}=vn(),u=Er(e),d=`https://${u}.nsite.lol`,f=(0,q.useMemo)(()=>St(s.appId,`nsite`,u),[s.appId,u]),p=(0,q.useCallback)(()=>{navigator.clipboard.writeText(d).then(()=>l({title:`Link copied to clipboard`})).catch(()=>l({title:`Could not copy link`,variant:`destructive`}))},[d,l]),m=(0,q.useCallback)(()=>{mn(d)},[d]),h=gu({siteId:u,siteName:t}),g=(0,q.useRef)(new Map),_=(0,q.useRef)([]);(0,q.useEffect)(()=>{g.current=bu(e);let t=dr(s.blossomServerMetadata,s.useAppBlossomServers??!0);_.current=xu(e,t.length>0?t:fr.servers)},[e,s.blossomServerMetadata,s.useAppBlossomServers]);let v=(0,q.useMemo)(()=>{let e=[{path:`__injected__/preview.js`,content:vu()}];return c&&e.push({path:`__injected__/nostr-provider.js`,content:_u(c.pubkey)}),e},[c]),y=(0,q.useCallback)(async e=>{let t=g.current.get(e),n=e;if(t||(t=g.current.get(`/index.html`),n=`/index.html`),!t)return null;let r=await(await Cu(t,_.current)).arrayBuffer(),i=new Uint8Array(r);return{status:200,contentType:Ht(n),body:i}},[]);if(!r||!a||!o)return null;let b=Math.max(0,o.top),x=window.innerHeight-b;return(0,Za.createPortal)((0,J.jsxs)(`div`,{className:`fixed z-50 flex flex-col bg-background`,style:{left:o.left,top:b,width:o.width,height:x},children:[(0,J.jsx)(`div`,{className:`min-h-11 border-b bg-muted/30 shrink-0 safe-area-top`,children:(0,J.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 w-full`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[n?(0,J.jsx)(`img`,{src:n,alt:t,className:`size-6 rounded-md object-cover shrink-0`,decoding:`async`}):(0,J.jsx)(`div`,{className:`size-6 rounded-md bg-primary/10 flex items-center justify-center shrink-0`,children:(0,J.jsx)(er,{url:d,size:18,fallback:(0,J.jsx)(k,{className:`size-3.5 text-primary/50`})})}),(0,J.jsx)(`span`,{className:`text-sm font-medium truncate`,children:t})]}),(0,J.jsx)(V,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:p,title:`Copy link`,children:(0,J.jsx)(_e,{className:`size-3.5`})}),(0,J.jsx)(V,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:m,title:`Open in browser`,children:(0,J.jsx)(ze,{className:`size-3.5`})}),c&&(0,J.jsx)(uu,{siteId:u}),(0,J.jsx)(V,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:()=>i(!1),title:`Close`,children:(0,J.jsx)(pe,{className:`size-3.5`})})]})}),(0,J.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative`,children:[(0,J.jsx)(Ot,{id:f,resolveFile:y,onRpc:c?h.onRpc:void 0,injectedScripts:v,className:`w-full h-full border-0`,title:`${t} preview`},`${f}-${r}`),h.pendingPrompt&&(0,J.jsx)(hu,{appPicture:n,appName:t,siteUrl:d,prompt:h.pendingPrompt,onResolve:h.resolvePrompt})]})]}),document.body)}function Tu({event:e,autoPlayKey:t}){let n=e.tags.find(([e])=>e===`title`)?.[1],r=e.tags.find(([e])=>e===`description`)?.[1],a=e.tags.find(([e])=>e===`d`)?.[1],o=L(e.tags.find(([e])=>e===`source`)?.[1]),s=e.tags.filter(([e])=>e===`path`),c=e.tags.filter(([e])=>e===`server`),l=e.kind===35128&&!!a,u=e.kind===wr,d=Er(e),f=`https://${d}.nsite.lol`,p=n||(l?a:u?`Snapshot`:`Root Site`),m=u?Cr(e):void 0,h=u?Dr(e):null,g=h?`/${I.naddrEncode({kind:h.kind,pubkey:h.pubkey,identifier:h.identifier})}`:void 0,{addToSidebar:_,removeFromSidebar:y,orderedItems:b}=ga(),x=`nsite://${d}`,S=b.includes(x),{data:C,isLoading:w}=yi(f),ee=C?.thumbnail_url,T=C?.title,{activeSubdomain:E,setActiveSubdomain:te}=$a(),[ne,D]=(0,q.useState)(!!t),O=(0,q.useRef)(E);O.current=E;let ie=(0,q.useCallback)(()=>{S?(y(x),_n({title:`Removed from sidebar`})):(_(x),_n({title:`Added to sidebar`}))},[x,S,_,y]),k=(0,q.useCallback)(e=>{D(e),te(e?d:null)},[d,te]);return(0,q.useEffect)(()=>{t&&k(!0)},[t,k]),(0,q.useEffect)(()=>(ne&&te(d),()=>{O.current===d&&te(null)}),[]),w?(0,J.jsx)(Eu,{}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:B(`group mt-2 rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors`),onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`block`,onClick:e=>e.stopPropagation(),children:[ee&&(0,J.jsx)(`div`,{className:`w-full overflow-hidden bg-muted`,children:(0,J.jsx)(`img`,{src:ee,alt:``,className:`w-full h-[180px] object-cover transition-transform duration-300 group-hover:scale-[1.02]`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),(0,J.jsxs)(`div`,{className:`px-3.5 pt-2.5 pb-1.5 space-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(er,{url:f,size:16,className:`shrink-0`}),(0,J.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:T||p}),u&&(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-secondary px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Snapshot`})]}),(r||C?.author_name)&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:r||C?.author_name}),(s.length>0||c.length>0||!!m)&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3 pt-0.5 text-[11px] text-muted-foreground`,children:[u&&m&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:m,children:[(0,J.jsx)(re,{className:`size-3`}),m.slice(0,8)]}),s.length>0&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(Ye,{className:`size-3`}),s.length,` `,s.length===1?`file`:`files`]}),c.length>0&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(Te,{className:`size-3`}),c.length,` `,c.length===1?`server`:`servers`]})]})]})]}),(0,J.jsxs)(`div`,{className:`px-3.5 pb-2.5 flex items-center gap-2`,children:[(0,J.jsxs)(V,{size:`sm`,className:`h-7 text-xs`,onClick:e=>{e.stopPropagation(),k(!0)},children:[(0,J.jsx)(Le,{className:`size-3 mr-1`}),`Run`]}),o?(0,J.jsx)(V,{asChild:!0,size:`sm`,variant:`secondary`,className:`h-7 text-xs`,children:(0,J.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(v,{className:`size-3 mr-1`}),`Source`]})}):(0,J.jsx)(V,{asChild:!0,size:`sm`,variant:`secondary`,className:`h-7 text-xs`,children:(0,J.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ze,{className:`size-3 mr-1`}),`Visit`]})}),g&&(0,J.jsx)(V,{asChild:!0,size:`sm`,variant:`secondary`,className:`h-7 text-xs`,children:(0,J.jsxs)(H,{to:g,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(ve,{className:`size-3 mr-1`}),`Site`]})}),(0,J.jsxs)(V,{size:`sm`,variant:`ghost`,className:`h-7 text-xs ml-auto text-muted-foreground`,onClick:e=>{e.stopPropagation(),ie()},children:[S?(0,J.jsx)(Pe,{className:`size-3 mr-1`}):(0,J.jsx)(i,{className:`size-3 mr-1`}),S?`Unpin`:`Pin`]})]})]}),(0,J.jsx)(wu,{event:e,appName:T||p||`nsite`,appPicture:void 0,open:ne,onOpenChange:k})]})}function Eu(){return(0,J.jsxs)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:[(0,J.jsx)(G,{className:`w-full h-[180px] rounded-none`}),(0,J.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-1.5`,children:[(0,J.jsx)(G,{className:`h-3 w-28`}),(0,J.jsx)(G,{className:`h-4 w-3/4`}),(0,J.jsx)(G,{className:`h-3 w-full`}),(0,J.jsx)(G,{className:`h-3 w-32`})]})]})}function Du(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ou(e){return Du(e)||Array.isArray(e)}function ku(){return!!(typeof window<`u`&&window.document&&window.document.createElement)}function Au(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length||JSON.stringify(Object.keys(e.breakpoints||{}))!==JSON.stringify(Object.keys(t.breakpoints||{}))?!1:n.every(n=>{let r=e[n],i=t[n];return typeof r==`function`?`${r}`==`${i}`:!Ou(r)||!Ou(i)?r===i:Au(r,i)})}function ju(e){return e.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function Mu(e,t){if(e.length!==t.length)return!1;let n=ju(e),r=ju(t);return n.every((e,t)=>{let n=r[t];return Au(e,n)})}function Nu(e){return typeof e==`number`}function Pu(e){return typeof e==`string`}function Fu(e){return typeof e==`boolean`}function Iu(e){return Object.prototype.toString.call(e)===`[object Object]`}function Z(e){return Math.abs(e)}function Lu(e){return Math.sign(e)}function Ru(e,t){return Z(e-t)}function zu(e,t){return e===0||t===0||Z(e)<=Z(t)?0:Z(Ru(Z(e),Z(t))/e)}function Bu(e){return Math.round(e*100)/100}function Vu(e){return Ku(e).map(Number)}function Hu(e){return e[Uu(e)]}function Uu(e){return Math.max(0,e.length-1)}function Wu(e,t){return t===Uu(e)}function Gu(e,t=0){return Array.from(Array(e),(e,n)=>t+n)}function Ku(e){return Object.keys(e)}function qu(e,t){return[e,t].reduce((e,t)=>(Ku(t).forEach(n=>{let r=e[n],i=t[n];e[n]=Iu(r)&&Iu(i)?qu(r,i):i}),e),{})}function Ju(e,t){return t.MouseEvent!==void 0&&e instanceof t.MouseEvent}function Yu(e,t){let n={start:r,center:i,end:a};function r(){return 0}function i(e){return a(e)/2}function a(e){return t-e}function o(r,i){return Pu(e)?n[e](r):e(t,r,i)}return{measure:o}}function Xu(){let e=[];function t(t,n,i,a={passive:!0}){let o;if(`addEventListener`in t)t.addEventListener(n,i,a),o=()=>t.removeEventListener(n,i,a);else{let e=t;e.addListener(i),o=()=>e.removeListener(i)}return e.push(o),r}function n(){e=e.filter(e=>e())}let r={add:t,clear:n};return r}function Zu(e,t,n,r){let i=Xu(),a=1e3/60,o=null,s=0,c=0;function l(){i.add(e,`visibilitychange`,()=>{e.hidden&&m()})}function u(){p(),i.clear()}function d(e){if(!c)return;o||(o=e,n(),n());let i=e-o;for(o=e,s+=i;s>=a;)n(),s-=a;r(s/a),c&&=t.requestAnimationFrame(d)}function f(){c||=t.requestAnimationFrame(d)}function p(){t.cancelAnimationFrame(c),o=null,s=0,c=0}function m(){o=null,s=0}return{init:l,destroy:u,start:f,stop:p,update:n,render:r}}function Qu(e,t){let n=t===`rtl`,r=e===`y`,i=r?`y`:`x`,a=r?`x`:`y`,o=!r&&n?-1:1,s=u(),c=d();function l(e){let{height:t,width:n}=e;return r?t:n}function u(){return r?`top`:n?`right`:`left`}function d(){return r?`bottom`:n?`left`:`right`}function f(e){return e*o}return{scroll:i,cross:a,startEdge:s,endEdge:c,measureSize:l,direction:f}}function $u(e=0,t=0){let n=Z(e-t);function r(t){return tt}function a(e){return r(e)||i(e)}function o(n){return a(n)?r(n)?e:t:n}function s(e){return n?e-n*Math.ceil((e-t)/n):e}return{length:n,max:t,min:e,constrain:o,reachedAny:a,reachedMax:i,reachedMin:r,removeOffset:s}}function ed(e,t,n){let{constrain:r}=$u(0,e),i=e+1,a=o(t);function o(e){return n?Z((i+e)%i):r(e)}function s(){return a}function c(e){return a=o(e),d}function l(e){return u().set(s()+e)}function u(){return ed(e,s(),n)}let d={get:s,set:c,add:l,clone:u};return d}function td(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let{cross:y,direction:b}=e,x=[`INPUT`,`SELECT`,`TEXTAREA`],S={passive:!1},C=Xu(),w=Xu(),ee=$u(50,225).constrain(p.measure(20)),T={mouse:300,touch:400},E={mouse:500,touch:600},te=m?43:25,ne=!1,re=0,D=0,O=!1,ie=!1,k=!1,A=!1;function ae(e){if(!v)return;function n(t){(Fu(v)||v(e,t))&&de(t)}let r=t;C.add(r,`dragstart`,e=>e.preventDefault(),S).add(r,`touchmove`,()=>void 0,S).add(r,`touchend`,()=>void 0).add(r,`touchstart`,n).add(r,`mousedown`,n).add(r,`touchcancel`,j).add(r,`contextmenu`,j).add(r,`click`,pe,!0)}function oe(){C.clear(),w.clear()}function se(){let e=A?n:t;w.add(e,`touchmove`,fe,S).add(e,`touchend`,j).add(e,`mousemove`,fe,S).add(e,`mouseup`,j)}function ce(e){let t=e.nodeName||``;return x.includes(t)}function le(){return(m?E:T)[A?`mouse`:`touch`]}function ue(e,t){let n=d.add(Lu(e)*-1),r=u.byDistance(e,!m).distance;return m||Z(e)=2,!(t&&e.button!==0)&&(ce(e.target)||(O=!0,a.pointerDown(e),l.useFriction(0).useDuration(0),i.set(o),se(),re=a.readPoint(e),D=a.readPoint(e,y),f.emit(`pointerDown`)))}function fe(e){if(!Ju(e,r)&&e.touches.length>=2)return j(e);let t=a.readPoint(e),n=a.readPoint(e,y),o=Ru(t,re),c=Ru(n,D);if(!ie&&!A&&(!e.cancelable||(ie=o>c,!ie)))return j(e);let u=a.pointerMove(e);o>h&&(k=!0),l.useFriction(.3).useDuration(.75),s.start(),i.add(b(u)),e.preventDefault()}function j(e){let t=u.byDistance(0,!1).index!==d.get(),n=a.pointerUp(e)*le(),r=ue(b(n),t),i=zu(n,r),o=te-10*i,s=_+i/50;ie=!1,O=!1,w.clear(),l.useDuration(o).useFriction(s),c.distance(r,!m),A=!1,f.emit(`pointerUp`)}function pe(e){k&&=(e.stopPropagation(),e.preventDefault(),!1)}function M(){return O}return{init:ae,destroy:oe,pointerDown:M}}function nd(e,t){let n,r;function i(e){return e.timeStamp}function a(n,r){let i=`client${(r||e.scroll)===`x`?`X`:`Y`}`;return(Ju(n,t)?n:n.touches[0])[i]}function o(e){return n=e,r=e,a(e)}function s(e){let t=a(e)-a(r),o=i(e)-i(n)>170;return r=e,o&&(n=e),t}function c(e){if(!n||!r)return 0;let t=a(r)-a(n),o=i(e)-i(n),s=i(e)-i(r)>170,c=t/o;return o&&!s&&Z(c)>.1?c:0}return{pointerDown:o,pointerMove:s,pointerUp:c,readPoint:a}}function rd(){function e(e){let{offsetTop:t,offsetLeft:n,offsetWidth:r,offsetHeight:i}=e;return{top:t,right:n+r,bottom:t+i,left:n,width:r,height:i}}return{measure:e}}function id(e){function t(t){return t/100*e}return{measure:t}}function ad(e,t,n,r,i,a,o){let s=[e].concat(r),c,l,u=[],d=!1;function f(e){return i.measureSize(o.measure(e))}function p(i){if(!a)return;l=f(e),u=r.map(f);function o(n){for(let a of n){if(d)return;let n=a.target===e,o=r.indexOf(a.target),s=n?l:u[o];if(Z(f(n?e:r[o])-s)>=.5){i.reInit(),t.emit(`resize`);break}}}c=new ResizeObserver(e=>{(Fu(a)||a(i,e))&&o(e)}),n.requestAnimationFrame(()=>{s.forEach(e=>c.observe(e))})}function m(){d=!0,c&&c.disconnect()}return{init:p,destroy:m}}function od(e,t,n,r,i,a){let o=0,s=0,c=i,l=a,u=e.get(),d=0;function f(){let t=r.get()-e.get(),i=!c,a=0;return i?(o=0,n.set(r),e.set(r),a=t):(n.set(e),o+=t/c,o*=l,u+=o,e.add(o),a=u-d),s=Lu(a),d=u,x}function p(){return Z(r.get()-t.get())<.001}function m(){return c}function h(){return s}function g(){return o}function _(){return y(i)}function v(){return b(a)}function y(e){return c=e,x}function b(e){return l=e,x}let x={direction:h,duration:m,velocity:g,seek:f,settled:p,useBaseFriction:v,useBaseDuration:_,useFriction:b,useDuration:y};return x}function sd(e,t,n,r,i){let a=i.measure(10),o=i.measure(50),s=$u(.1,.99),c=!1;function l(){return!(c||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function u(i){if(!l())return;let c=Z(e[e.reachedMin(t.get())?`min`:`max`]-t.get()),u=n.get()-t.get(),d=s.constrain(c/o);n.subtract(u*d),!i&&Z(u){let{min:r,max:i}=a,o=a.constrain(e),s=!t,c=Wu(n,t);return s?i:c||l(r,o)?r:l(i,o)?i:o}).map(e=>parseFloat(e.toFixed(3)))}function f(){if(t<=e+i)return[a.max];if(r===`keepSnaps`)return o;let{min:n,max:c}=s;return o.slice(n,c)}return{snapsContained:c,scrollContainLimit:s}}function ld(e,t,n){let r=t[0];return{limit:$u(n?r-e:Hu(t),r)}}function ud(e,t,n,r){let i=.1,{reachedMin:a,reachedMax:o}=$u(t.min+i,t.max+i);function s(e){return e===1?o(n.get()):e===-1?a(n.get()):!1}function c(t){if(!s(t))return;let n=t*-1*e;r.forEach(e=>e.add(n))}return{loop:c}}function dd(e){let{max:t,length:n}=e;function r(e){let r=e-t;return n?r/-n:0}return{get:r}}function fd(e,t,n,r,i){let{startEdge:a,endEdge:o}=e,{groupSlides:s}=i,c=d().map(t.measure),l=f(),u=p();function d(){return s(r).map(e=>Hu(e)[o]-e[0][a]).map(Z)}function f(){return r.map(e=>n[a]-e[a]).map(e=>-Z(e))}function p(){return s(l).map(e=>e[0]).map((e,t)=>e+c[t])}return{snaps:l,snapsAligned:u}}function pd(e,t,n,r,i,a){let{groupSlides:o}=i,{min:s,max:c}=r,l=u();function u(){let r=o(a),i=!e||t===`keepSnaps`;return n.length===1?[a]:i?r:r.slice(s,c).map((e,t,n)=>{let r=!t,i=Wu(n,t);return r?Gu(Hu(n[0])+1):i?Gu(Uu(a)-Hu(n)[0]+1,Hu(n)[0]):e})}return{slideRegistry:l}}function md(e,t,n,r,i){let{reachedAny:a,removeOffset:o,constrain:s}=r;function c(e){return e.concat().sort((e,t)=>Z(e)-Z(t))[0]}function l(n){let r=e?o(n):s(n),{index:i}=t.map((e,t)=>({diff:u(e-r,0),index:t})).sort((e,t)=>Z(e.diff)-Z(t.diff))[0];return{index:i,distance:r}}function u(t,r){let i=[t,t+n,t-n];if(!e)return t;if(!r)return c(i);let a=i.filter(e=>Lu(e)===r);return a.length?c(a):Hu(i)-n}function d(e,n){return{index:e,distance:u(t[e]-i.get(),n)}}function f(n,r){let o=i.get()+n,{index:s,distance:c}=l(o),d=!e&&a(o);return!r||d?{index:s,distance:n}:{index:s,distance:n+u(t[s]-c,0)}}return{byDistance:f,byIndex:d,shortcut:u}}function hd(e,t,n,r,i,a,o){function s(i){let s=i.distance,c=i.index!==t.get();a.add(s),s&&(r.duration()?e.start():(e.update(),e.render(1),e.update())),c&&(n.set(t.get()),t.set(i.index),o.emit(`select`))}function c(e,t){s(i.byDistance(e,t))}function l(e,n){let r=t.clone().set(e);s(i.byIndex(r.get(),n))}return{distance:c,index:l}}function gd(e,t,n,r,i,a,o,s){let c={passive:!0,capture:!0},l=0;function u(u){if(!s)return;function f(t){if(new Date().getTime()-l>10)return;o.emit(`slideFocusStart`),e.scrollLeft=0;let a=n.findIndex(e=>e.includes(t));Nu(a)&&(i.useDuration(0),r.index(a,0),o.emit(`slideFocus`))}a.add(document,`keydown`,d,!1),t.forEach((e,t)=>{a.add(e,`focus`,e=>{(Fu(s)||s(u,e))&&f(t)},c)})}function d(e){e.code===`Tab`&&(l=new Date().getTime())}return{init:u}}function _d(e){let t=e;function n(){return t}function r(e){t=o(e)}function i(e){t+=o(e)}function a(e){t-=o(e)}function o(e){return Nu(e)?e:e.get()}return{get:n,set:r,add:i,subtract:a}}function vd(e,t){let n=e.scroll===`x`?o:s,r=t.style,i=null,a=!1;function o(e){return`translate3d(${e}px,0px,0px)`}function s(e){return`translate3d(0px,${e}px,0px)`}function c(t){if(a)return;let o=Bu(e.direction(t));o!==i&&(r.transform=n(o),i=o)}function l(e){a=!e}function u(){a||(r.transform=``,t.getAttribute(`style`)||t.removeAttribute(`style`))}return{clear:u,to:c,toggleActive:l}}function yd(e,t,n,r,i,a,o,s,c){let l=.5,u=Vu(i),d=Vu(i).reverse(),f=_().concat(v());function p(e,t){return e.reduce((e,t)=>e-i[t],t)}function m(e,t){return e.reduce((e,n)=>p(e,t)>0?e.concat([n]):e,[])}function h(e){return a.map((n,i)=>({start:n-r[i]+l+e,end:n+t-l+e}))}function g(t,r,i){let a=h(r);return t.map(t=>{let r=i?0:-n,o=i?n:0,l=i?`end`:`start`,u=a[t][l];return{index:t,loopPoint:u,slideLocation:_d(-1),translate:vd(e,c[t]),target:()=>s.get()>u?r:o}})}function _(){let e=o[0];return g(m(d,e),n,!1)}function v(){let e=t-o[0]-1;return g(m(u,e),-n,!0)}function y(){return f.every(({index:e})=>p(u.filter(t=>t!==e),t)<=.1)}function b(){f.forEach(e=>{let{target:t,translate:n,slideLocation:r}=e,i=t();i!==r.get()&&(n.to(i),r.set(i))})}function x(){f.forEach(e=>e.translate.clear())}return{canLoop:y,clear:x,loop:b,loopPoints:f}}function bd(e,t,n){let r,i=!1;function a(a){if(!n)return;function o(e){for(let n of e)if(n.type===`childList`){a.reInit(),t.emit(`slidesChanged`);break}}r=new MutationObserver(e=>{i||(Fu(n)||n(a,e))&&o(e)}),r.observe(e,{childList:!0})}function o(){r&&r.disconnect(),i=!0}return{init:a,destroy:o}}function xd(e,t,n,r){let i={},a=null,o=null,s,c=!1;function l(){s=new IntersectionObserver(e=>{c||(e.forEach(e=>{let n=t.indexOf(e.target);i[n]=e}),a=null,o=null,n.emit(`slidesInView`))},{root:e.parentElement,threshold:r}),t.forEach(e=>s.observe(e))}function u(){s&&s.disconnect(),c=!0}function d(e){return Ku(i).reduce((t,n)=>{let r=parseInt(n),{isIntersecting:a}=i[r];return(e&&a||!e&&!a)&&t.push(r),t},[])}function f(e=!0){if(e&&a)return a;if(!e&&o)return o;let t=d(e);return e&&(a=t),e||(o=t),t}return{init:l,destroy:u,get:f}}function Sd(e,t,n,r,i,a){let{measureSize:o,startEdge:s,endEdge:c}=e,l=n[0]&&i,u=m(),d=h(),f=n.map(o),p=g();function m(){if(!l)return 0;let e=n[0];return Z(t[s]-e[s])}function h(){if(!l)return 0;let e=a.getComputedStyle(Hu(r));return parseFloat(e.getPropertyValue(`margin-${c}`))}function g(){return n.map((e,t,n)=>{let r=!t,i=Wu(n,t);return r?f[t]+u:i?f[t]+d:n[t+1][s]-e[s]}).map(Z)}return{slideSizes:f,slideSizesWithGaps:p,startGap:u,endGap:d}}function Cd(e,t,n,r,i,a,o,s,c){let{startEdge:l,endEdge:u,direction:d}=e,f=Nu(n);function p(e,t){return Vu(e).filter(e=>e%t===0).map(n=>e.slice(n,n+t))}function m(e){return e.length?Vu(e).reduce((n,f,p)=>{let m=Hu(n)||0,h=m===0,g=f===Uu(e),_=i[l]-a[m][l],v=i[l]-a[f][u],y=!r&&h?d(o):0,b=Z(v-(!r&&g?d(s):0)-(_+y));return p&&b>t+c&&n.push(f),g&&n.push(e.length),n},[]).map((t,n,r)=>{let i=Math.max(r[n-1]||0);return e.slice(i,t)}):[]}function h(e){return f?p(e,n):m(e)}return{groupSlides:h}}function wd(e,t,n,r,i,a,o){let{align:s,axis:c,direction:l,startIndex:u,loop:d,duration:f,dragFree:p,dragThreshold:m,inViewThreshold:h,slidesToScroll:g,skipSnaps:_,containScroll:v,watchResize:y,watchSlides:b,watchDrag:x,watchFocus:S}=a,C=rd(),w=C.measure(t),ee=n.map(C.measure),T=Qu(c,l),E=T.measureSize(w),te=id(E),ne=Yu(s,E),re=!d&&!!v,{slideSizes:D,slideSizesWithGaps:O,startGap:ie,endGap:k}=Sd(T,w,ee,n,d||!!v,i),A=Cd(T,E,g,d,w,ee,ie,k,2),{snaps:ae,snapsAligned:oe}=fd(T,ne,w,ee,A),se=-Hu(ae)+Hu(O),{snapsContained:ce,scrollContainLimit:le}=cd(E,se,oe,v,2),ue=re?ce:oe,{limit:de}=ld(se,ue,d),fe=ed(Uu(ue),u,d),j=fe.clone(),pe=Vu(n),M=({dragHandler:e,scrollBody:t,scrollBounds:n,options:{loop:r}})=>{r||n.constrain(e.pointerDown()),t.seek()},me=({scrollBody:e,translate:t,location:n,offsetLocation:r,previousLocation:i,scrollLooper:a,slideLooper:o,dragHandler:s,animation:c,eventHandler:l,scrollBounds:u,options:{loop:d}},f)=>{let p=e.settled(),m=!u.shouldConstrain(),h=d?p:p&&m,g=h&&!s.pointerDown();g&&c.stop();let _=n.get()*f+i.get()*(1-f);r.set(_),d&&(a.loop(e.direction()),o.loop()),t.to(r.get()),g&&l.emit(`settle`),h||l.emit(`scroll`)},he=Zu(r,i,()=>M(Ae),e=>me(Ae,e)),ge=.68,_e=ue[fe.get()],ve=_d(_e),ye=_d(_e),be=_d(_e),xe=_d(_e),Se=od(ve,be,ye,xe,f,ge),Ce=md(d,ue,se,de,xe),we=hd(he,fe,j,Se,Ce,xe,o),Te=dd(de),Ee=Xu(),De=xd(t,n,o,h),{slideRegistry:Oe}=pd(re,v,ue,le,A,pe),ke=gd(e,n,Oe,we,Se,Ee,o,S),Ae={ownerDocument:r,ownerWindow:i,eventHandler:o,containerRect:w,slideRects:ee,animation:he,axis:T,dragHandler:td(T,e,r,i,xe,nd(T,i),ve,he,we,Se,Ce,fe,o,te,p,m,_,ge,x),eventStore:Ee,percentOfView:te,index:fe,indexPrevious:j,limit:de,location:ve,offsetLocation:be,previousLocation:ye,options:a,resizeHandler:ad(t,o,i,n,T,y,C),scrollBody:Se,scrollBounds:sd(de,be,xe,Se,te),scrollLooper:ud(se,de,be,[ve,be,ye,xe]),scrollProgress:Te,scrollSnapList:ue.map(Te.get),scrollSnaps:ue,scrollTarget:Ce,scrollTo:we,slideLooper:yd(T,E,se,D,O,ae,ue,be,n),slideFocus:ke,slidesHandler:bd(t,o,b),slidesInView:De,slideIndexes:pe,slideRegistry:Oe,slidesToScroll:A,target:xe,translate:vd(T,t)};return Ae}function Td(){let e={},t;function n(e){t=e}function r(t){return e[t]||[]}function i(e){return r(e).forEach(n=>n(t,e)),c}function a(t,n){return e[t]=r(t).concat([n]),c}function o(t,n){return e[t]=r(t).filter(e=>e!==n),c}function s(){e={}}let c={init:n,emit:i,off:o,on:a,clear:s};return c}var Ed={align:`center`,axis:`x`,container:null,slides:null,containScroll:`trimSnaps`,direction:`ltr`,slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Dd(e){function t(e,t){return qu(e,t||{})}function n(n){let r=n.breakpoints||{};return t(n,Ku(r).filter(t=>e.matchMedia(t).matches).map(e=>r[e]).reduce((e,n)=>t(e,n),{}))}function r(t){return t.map(e=>Ku(e.breakpoints||{})).reduce((e,t)=>e.concat(t),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:r}}function Od(e){let t=[];function n(n,r){return t=r.filter(({options:t})=>e.optionsAtMedia(t).active!==!1),t.forEach(t=>t.init(n,e)),r.reduce((e,t)=>Object.assign(e,{[t.name]:t}),{})}function r(){t=t.filter(e=>e.destroy())}return{init:n,destroy:r}}function kd(e,t,n){let r=e.ownerDocument,i=r.defaultView,a=Dd(i),o=Od(a),s=Xu(),c=Td(),{mergeOptions:l,optionsAtMedia:u,optionsMediaQueries:d}=a,{on:f,off:p,emit:m}=c,h=E,g=!1,_,v=l(Ed,kd.globalOptions),y=l(v),b=[],x,S,C;function w(){let{container:t,slides:n}=y;S=(Pu(t)?e.querySelector(t):t)||e.children[0];let r=Pu(n)?S.querySelectorAll(n):n;C=[].slice.call(r||S.children)}function ee(t){let n=wd(e,S,C,r,i,t,c);return t.loop&&!n.slideLooper.canLoop()?ee(Object.assign({},t,{loop:!1})):n}function T(e,t){g||(v=l(v,e),y=u(v),b=t||b,w(),_=ee(y),d([v,...b.map(({options:e})=>e)]).forEach(e=>s.add(e,`change`,E)),y.active&&(_.translate.to(_.location.get()),_.animation.init(),_.slidesInView.init(),_.slideFocus.init(M),_.eventHandler.init(M),_.resizeHandler.init(M),_.slidesHandler.init(M),_.options.loop&&_.slideLooper.loop(),S.offsetParent&&C.length&&_.dragHandler.init(M),x=o.init(M,b)))}function E(e,t){let n=oe();te(),T(l({startIndex:n},e),t),c.emit(`reInit`)}function te(){_.dragHandler.destroy(),_.eventStore.clear(),_.translate.clear(),_.slideLooper.clear(),_.resizeHandler.destroy(),_.slidesHandler.destroy(),_.slidesInView.destroy(),_.animation.destroy(),o.destroy(),s.clear()}function ne(){g||(g=!0,s.clear(),te(),c.emit(`destroy`),c.clear())}function re(e,t,n){!y.active||g||(_.scrollBody.useBaseFriction().useDuration(t===!0?0:y.duration),_.scrollTo.index(e,n||0))}function D(e){re(_.index.add(1).get(),e,-1)}function O(e){re(_.index.add(-1).get(),e,1)}function ie(){return _.index.add(1).get()!==oe()}function k(){return _.index.add(-1).get()!==oe()}function A(){return _.scrollSnapList}function ae(){return _.scrollProgress.get(_.offsetLocation.get())}function oe(){return _.index.get()}function se(){return _.indexPrevious.get()}function ce(){return _.slidesInView.get()}function le(){return _.slidesInView.get(!1)}function ue(){return x}function de(){return _}function fe(){return e}function j(){return S}function pe(){return C}let M={canScrollNext:ie,canScrollPrev:k,containerNode:j,internalEngine:de,destroy:ne,off:p,on:f,emit:m,plugins:ue,previousScrollSnap:se,reInit:h,rootNode:fe,scrollNext:D,scrollPrev:O,scrollProgress:ae,scrollSnapList:A,scrollTo:re,selectedScrollSnap:oe,slideNodes:pe,slidesInView:ce,slidesNotInView:le};return T(t,n),setTimeout(()=>c.emit(`init`),0),M}kd.globalOptions=void 0;function Ad(e={},t=[]){let n=(0,q.useRef)(e),r=(0,q.useRef)(t),[i,a]=(0,q.useState)(),[o,s]=(0,q.useState)(),c=(0,q.useCallback)(()=>{i&&i.reInit(n.current,r.current)},[i]);return(0,q.useEffect)(()=>{Au(n.current,e)||(n.current=e,c())},[e,c]),(0,q.useEffect)(()=>{Mu(r.current,t)||(r.current=t,c())},[t,c]),(0,q.useEffect)(()=>{if(ku()&&o){kd.globalOptions=Ad.globalOptions;let e=kd(o,n.current,r.current);return a(e),()=>e.destroy()}else a(void 0)},[o,a]),[s,i]}Ad.globalOptions=void 0;var jd=q.createContext(null);function Md(){let e=q.useContext(jd);if(!e)throw Error(`useCarousel must be used within a `);return e}var Nd=q.forwardRef(({orientation:e=`horizontal`,opts:t,setApi:n,plugins:r,className:i,children:a,...o},s)=>{let[c,l]=Ad({...t,axis:e===`horizontal`?`x`:`y`},r),[u,d]=q.useState(!1),[f,p]=q.useState(!1),m=q.useCallback(e=>{e&&(d(e.canScrollPrev()),p(e.canScrollNext()))},[]),h=q.useCallback(()=>{l?.scrollPrev()},[l]),g=q.useCallback(()=>{l?.scrollNext()},[l]),_=q.useCallback(e=>{e.key===`ArrowLeft`?(e.preventDefault(),h()):e.key===`ArrowRight`&&(e.preventDefault(),g())},[h,g]);return q.useEffect(()=>{!l||!n||n(l)},[l,n]),q.useEffect(()=>{if(l)return m(l),l.on(`reInit`,m),l.on(`select`,m),()=>{l?.off(`select`,m)}},[l,m]),(0,J.jsx)(jd.Provider,{value:{carouselRef:c,api:l,opts:t,orientation:e||(t?.axis===`y`?`vertical`:`horizontal`),scrollPrev:h,scrollNext:g,canScrollPrev:u,canScrollNext:f},children:(0,J.jsx)(`div`,{ref:s,onKeyDownCapture:_,className:B(`relative`,i),role:`region`,"aria-roledescription":`carousel`,...o,children:a})})});Nd.displayName=`Carousel`;var Pd=q.forwardRef(({className:e,...t},n)=>{let{carouselRef:r,orientation:i}=Md();return(0,J.jsx)(`div`,{ref:r,className:`overflow-hidden`,children:(0,J.jsx)(`div`,{ref:n,className:B(`flex`,i===`horizontal`?`-ml-4`:`-mt-4 flex-col`,e),...t})})});Pd.displayName=`CarouselContent`;var Fd=q.forwardRef(({className:e,...t},n)=>{let{orientation:r}=Md();return(0,J.jsx)(`div`,{ref:n,role:`group`,"aria-roledescription":`slide`,className:B(`min-w-0 shrink-0 grow-0 basis-full`,r===`horizontal`?`pl-4`:`pt-4`,e),...t})});Fd.displayName=`CarouselItem`;var Id=q.forwardRef(({className:e,variant:t=`outline`,size:n=`icon`,...r},i)=>{let{orientation:a,scrollPrev:o,canScrollPrev:s}=Md();return(0,J.jsxs)(V,{ref:i,variant:t,size:n,className:B(`absolute h-8 w-8 rounded-full`,a===`horizontal`?`-left-12 top-1/2 -translate-y-1/2`:`-top-12 left-1/2 -translate-x-1/2 rotate-90`,e),disabled:!s,onClick:o,...r,children:[(0,J.jsx)(st,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Previous slide`})]})});Id.displayName=`CarouselPrevious`;var Ld=q.forwardRef(({className:e,variant:t=`outline`,size:n=`icon`,...r},i)=>{let{orientation:a,scrollNext:o,canScrollNext:s}=Md();return(0,J.jsxs)(V,{ref:i,variant:t,size:n,className:B(`absolute h-8 w-8 rounded-full`,a===`horizontal`?`-right-12 top-1/2 -translate-y-1/2`:`-bottom-12 left-1/2 -translate-x-1/2 rotate-90`,e),disabled:!s,onClick:o,...r,children:[(0,J.jsx)(ge,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Next slide`})]})});Ld.displayName=`CarouselNext`;function Rd(e,t){return e.find(([e])=>e===t)?.[1]}function zd(e){if(!e)return;let[t,n]=e.split(`x`).map(Number);if(!(!t||!n||isNaN(t)||isNaN(n)))return t/n}function Bd(e){return Math.min(Math.max(e,4/5),1.91)}function Vd({event:e,variant:t=`feed`,fullBleed:n=!1}){let r=un(),i=(0,q.useMemo)(()=>sa(e.tags),[e.tags]),a=Rd(e.tags,`title`),o=e.content.trim(),s=(0,q.useMemo)(()=>{let t=new Set,n=o.toLowerCase(),r=[];for(let[i,a]of e.tags)i!==`t`||!a||t.has(a)||(t.add(a),!n.includes(`#${a.toLowerCase()}`)&&r.push(a));return r},[e.tags,o]),[c,l]=(0,q.useState)(null),[u,f]=(0,q.useState)(),[p,m]=(0,q.useState)(0),[h,g]=(0,q.useState)(void 0);(0,q.useEffect)(()=>{if(!u)return;let e=()=>m(u.selectedScrollSnap());return e(),u.on(`select`,e),()=>{u.off(`select`,e)}},[u]);let _=(0,q.useMemo)(()=>i.map(e=>({dim:e.dim,blurhash:e.blurhash,encryption:e.encryption})),[i]);if(i.length===0)return null;let v=Bd(zd(i[0].dim)??h??1),y=i.length>1,b=y?(0,J.jsx)(Nd,{opts:{align:`start`},setApi:f,className:`w-full`,children:(0,J.jsx)(Pd,{className:`ml-0`,children:i.map((e,t)=>(0,J.jsx)(Fd,{className:`pl-0`,children:(0,J.jsx)(Hd,{entry:e,aspectRatio:v,onOpen:()=>l(t),onProbeRatio:t===0?g:void 0})},`${e.url}-${t}`))})}):(0,J.jsx)(Hd,{entry:i[0],aspectRatio:v,onOpen:()=>l(0),onProbeRatio:g});return(0,J.jsxs)(`div`,{className:B(`mt-2`,n&&`-mx-4`),children:[(0,J.jsxs)(`div`,{className:`relative bg-muted/30`,children:[b,y&&(0,J.jsxs)(`div`,{className:`absolute top-3 right-3 rounded-full bg-black/60 px-2.5 py-0.5 text-xs font-medium text-white pointer-events-none`,children:[p+1,`/`,i.length]}),y&&p>0&&(0,J.jsx)(`button`,{type:`button`,className:`absolute left-2 top-1/2 -translate-y-1/2 hidden sm:flex items-center justify-center size-8 rounded-full bg-white/90 text-black shadow-md hover:bg-white transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r.formatMessage({id:`photoPost.prev`,defaultMessage:`Previous photo`}),onClick:e=>{e.preventDefault(),e.stopPropagation(),u?.scrollPrev()},children:(0,J.jsx)(d,{className:`size-5`})}),y&&p