// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later // @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ArticleContent-DVjKsyqS.js","assets/lucide-icons-BdRF0moN.js","assets/rolldown-runtime-QTnfLwEv.js","assets/jsx-runtime-By8HlURe.js","assets/EmbeddedNote-BKfkvcrg.js","assets/react-dom-YCZzGcHh.js","assets/ErrorBoundary-DAm6b_mx.js","assets/preload-helper-CZgWQFsJ.js","assets/dist-DQ82bf9M.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useQuery-rCAlChE8.js","assets/useMutation-CgsR0O-3.js","assets/useAppContext-Ughdk2-Z.js","assets/useTheme-B8n3R7ig.js","assets/useEncryptedSettings-DPGHcvzd.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-C6OJJlWo.js","assets/dist-DQ_zK-Nr.js","assets/fontLoader-C8ZADbrS.js","assets/sanitizeUrl-Bk5f35GN.js","assets/useNostrPublish-CrMjnYm4.js","assets/react-intl-eZirkCBg.js","assets/encryptedFile-DKFYUsvG.js","assets/downloadFile-kpATXaJi.js","assets/utils-BFSTDHdM.js","assets/button-Cs26nq0r.js","assets/dist-CrweAx5r.js","assets/dist-BI-be9Ir.js","assets/dist-DEYuuXMO.js","assets/nostrId-DuqQCAdJ.js","assets/useFollowActions-cve70R08.js","assets/letterTypes-BLLFWtiN.js","assets/appBlossom-CsMDSd4h.js","assets/useBlossomFallback-DY_46Uqi.js","assets/avatar--oX_CTF4.js","assets/chunk-62JRHF6Z-yJW_vgm4.js","assets/customEmoji-kpim4Htm.js","assets/hashtag-DjDKS0mr.js","assets/CustomEmoji-DRcU63lJ.js","assets/useProfileUrl-DoFhqUUR.js","assets/useNip05Resolve-B9x4kFtR.js","assets/profileUrl-DpJiPx2H.js","assets/BioContent-BjUPDB1O.js","assets/dist-Bz2abD7M.js","assets/dist-BMrfXngQ.js","assets/dist-CxepVuy2.js","assets/dist-D9YQw-T8.js","assets/dist-wmZSqlsD.js","assets/dist-DTSySAaw.js","assets/FallbackImage-Dlnc8809.js","assets/ExternalFavicon-BWUhHW7H.js","assets/useUserStatus-Bgu4AAxG.js","assets/haptics-Cp_uF-bV.js","assets/parseAddr-BmO3JZWT.js","assets/collapsible-C12_mOsk.js","assets/dist-B6j_mgMi.js","assets/dist-CxcvWxxD.js","assets/dist-CpRh64jj.js","assets/dist-CX38Lmo0.js","assets/dist-BeEGgqo9.js","assets/skeleton-CVls4GW9.js","assets/useAuthors-DHw1W6Un.js","assets/storageKey-Hu6452Ya.js","assets/safeNip19-CtQLwPmS.js","assets/useEventInteractions-Buyvdv_T.js","assets/nsiteSubdomain-DmdGxq_K.js","assets/tooltip-Ba63GpbC.js","assets/dialog-C3CFmras.js","assets/dist-DW2GM_Ig.js","assets/Combination-C1QBaE03.js","assets/timeAgo-BXjjbyXp.js","assets/getDisplayName-B6lnEGRj.js","assets/letterUtils-ByLgglzi.js","assets/optimisticEvent-1jcgWuWv.js","assets/useLinkPreview-CqNF97jn.js","assets/appRelays-Clm5NPIe.js","assets/packUtils-BzqQUARG.js","assets/relayList-BL1oPXvf.js","assets/memorycard-BpAZd6ha.js","assets/EmbeddedArticleCard-DTHHB3Yi.js","assets/articleHelpers-Dhr_Z8YP.js","assets/EmbeddedPublicationCard-DiFfM9Jf.js","assets/bitcoinMoney-CQsGrYK3.js","assets/esplora-CScU9uce.js","assets/countries-Du6BjHuX.js","assets/campaign-DRgHWLio.js","assets/quiz-kCjrdDeU.js","assets/extraKinds-BydAXtVV.js","assets/sidebarItems-BFr7FKBa.js","assets/WikipediaIcon-Dvm9f9D4.js","assets/BlueskyIcon-BZ9o1lYL.js","assets/badge-eEdLlpTp.js","assets/cards-DDSmTmb2.js","assets/TarotReadingSection-DRLtYoI5.js","assets/card-CthSADjg.js","assets/TarotReadingSection-DBSfhNtE.css","assets/formatNumber-D1ols1S-.js","assets/browser-B_X_RtOd.js","assets/imeta-83Lqxs5-.js","assets/formatTime-CT4ZmnVr.js","assets/browser-C1AyMpfR.js","assets/LayoutContext-CjQBLGO-.js","assets/useInView-DAJQSIvc.js","assets/useCustomEmojis-BRL1hilD.js","assets/EmbeddedNote-C_xrnWud.css","assets/lib-D6JeXc-v.js","assets/lib-DhF-PQbN.js","assets/articleSmartypants-Bcj3a4SM.js","assets/markdownComponents-BiuuXc15.js","assets/ClassifiedListingContent-CI3jo0I8.js","assets/BlobbiStateCard-BzIlF1sW.js","assets/blobbi-CLChx8JU.js","assets/index-CYEZWNq6.js","assets/useInfiniteQuery-BFtb_-3K.js","assets/useLocalStorage-DLDvi0Ge.js","assets/useLanguage-yd3vEXqu.js","assets/credentialManager-Dv_8gYNN.js","assets/NewPostsPill-BQIcBVZE.js","assets/input-CM5Fnyvy.js","assets/dropdown-menu-ug3FLSAW.js","assets/dist-B2RAV5d5.js","assets/dist-BsC49GML.js","assets/usePortalContainer-mvErHojv.js","assets/popover-Dw5E1auH.js","assets/ProfileCard-Baz_I7BX.js","assets/useMuteList-uFe-Ok2F.js","assets/useLoginActions-CynKtWLl.js","assets/LoginFlow-Bd1W7T2S.js","assets/qrcode-DVi38FWW.js","assets/useIsMobile-B6g4lnSy.js","assets/useShareOrigin-04gGNDPW.js","assets/alert-CY7M1xVR.js","assets/useUploadFile-BpPXwoE0.js","assets/ComposeDialogContent-YxhSZA-Y.js","assets/musicHelpers-B271Bg0t.js","assets/textarea-B93xm6Zg.js","assets/EmbeddedPost-Bb-ngBHS.js","assets/dist-D7z3WTXi.js","assets/useSearchProfiles-uU0NOVhy.js","assets/useFeedSettings-DkFDaYIY.js","assets/birthday-DHyHAOFk.js","assets/resizeImage-LOlp-rx5.js","assets/DecryptedImage-DLbW5kmn.js","assets/wikimedia-CCPyM-j2.js","assets/NoteCard-COwLfrJJ.js","assets/NoteMoreMenu-FwlS01AC.js","assets/label-BBIj2Nkw.js","assets/radio-group-DRkm3Stx.js","assets/dist-BEZkw2Ia.js","assets/dist-DjUhKbpW.js","assets/alert-dialog-n1eT_Aa8.js","assets/separator-CWY6Ovdb.js","assets/scroll-area-D2CmkWvj.js","assets/dist-C2J943E6.js","assets/useUserLists-zSWA8dQn.js","assets/useInteractionReaction-03diUK1e.js","assets/colorMomentUtils-VGseiWMP.js","assets/contentWarning-CNDzjeMP.js","assets/ContentWarningGuard-BQGV-Ggw.js","assets/useRelayInfo-CT_UT7Yl.js","assets/GitSiteLinks-CnSU1vGl.js","assets/TarotStars-D-jATuHd.js","assets/useOpenPost-DKpHsp1A.js","assets/switch-B6lxwP1L.js","assets/useRepostStatus-KJZve8_M.js","assets/useBitcoinSigner-CheBjN_q.js","assets/checkbox-CM1MZiSJ.js","assets/RepostMenu-CULlcQsd.js","assets/useTrending-DsL3v2RN.js","assets/vineGlobalMute-Du-DhONT.js","assets/SubHeaderBar-BYwNp4Nc.js","assets/useFeed-DtXzJkqY.js","assets/useMutedAuthorFilter-CTggZCaG.js","assets/usePageRefresh-BuJEOs2u.js","assets/index-poUxjvrc.css","assets/blobbi-shop-items-gin9pdH4.js","assets/BlobbiStageVisual-Cyhy_5-y.js","assets/purify.es-DCh266OY.js","assets/BlobbiStageVisual-ZqmrGSeZ.css","assets/useBlobbiInteractions-BR0C9tjk.js","assets/FloatingSocialHearts-ChoPyJfb.js","assets/BlobbiSocialActions-KZzO03jP.js","assets/blobbi-action-utils-CeIPzrFd.js","assets/ItemCarousel-DJoTWUZ6.js","assets/CustomNipCard-CzHkVLHj.js","assets/GitStatusCard-CICszc49.js","assets/IssueCard-B6Hx1GnM.js","assets/PullRequestCard-D_w7GJkC.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,A as n,An as r,At as i,Bt as a,C as o,Dt as s,Et as c,F as l,Fn as u,Fr as d,Ft as f,Gn as p,Gt as m,Ht as h,In as g,It as _,J as v,Jt as y,Kn as b,Kr as x,Kt as S,Ln as C,Lt as w,M as T,Mr as E,Mt as D,Ni as O,Nt as ee,O as te,Oi as ne,Pt as k,Q as re,Ri as A,Rn as ie,S as j,Sn as ae,Sr as oe,T as se,Tr as ce,V as le,Wr as ue,Yt as M,Zr as de,Zt as fe,_ as pe,_n as N,a as me,ai as he,b as ge,br as _e,bt as ve,ci as ye,dn as be,fn as xe,gi as Se,hr as Ce,ht as we,jr as Te,jt as Ee,ki as De,li as Oe,ln as ke,mi as Ae,oi as je,on as Me,qi as Ne,r as Pe,ri as Fe,ur as Ie,v as Le,vi as Re,wi as ze,xn as Be,xr as Ve,yn as He,yt as Ue}from"./lucide-icons-BdRF0moN.js";import{t as We}from"./react-dom-YCZzGcHh.js";import{t as Ge}from"./useNip05Resolve-B9x4kFtR.js";import{t as Ke}from"./jsx-runtime-By8HlURe.js";import{t as qe}from"./ErrorBoundary-DAm6b_mx.js";import{t as Je}from"./preload-helper-CZgWQFsJ.js";import{t as P}from"./dist-DQ82bf9M.js";import{u as F}from"./esm-CRVqHnq2.js";import{h as Ye,t as I}from"./useQuery-rCAlChE8.js";import{t as Xe}from"./useMutation-CgsR0O-3.js";import{t as Ze}from"./useInfiniteQuery-BFtb_-3K.js";import{$ as Qe,C as $e,D as et,N as tt,X as nt,Y as L,Z as rt,_t as it,a as at,bt as ot,c as R,dt as st,et as ct,gt as lt,ht as ut,i as dt,it as ft,l as pt,mt,n as ht,nt as gt,o as _t,ot as vt,pt as yt,r as bt,s as xt,t as St,ut as Ct,vt as wt,xt as Tt}from"./EmbeddedNote-BKfkvcrg.js";import{t as Et}from"./useLocalStorage-DLDvi0Ge.js";import{t as Dt}from"./useAppContext-Ughdk2-Z.js";import{A as z,O as Ot,_ as kt,a as At,c as jt,d as Mt,h as Nt,m as Pt,o as Ft,p as It,t as Lt,u as Rt}from"./useTheme-B8n3R7ig.js";import{r as zt}from"./useEncryptedSettings-DPGHcvzd.js";import{c as Bt,l as Vt,n as Ht,t as Ut}from"./fontLoader-C8ZADbrS.js";import{r as Wt}from"./sanitizeUrl-Bk5f35GN.js";import{o as Gt}from"./react-intl-eZirkCBg.js";import{t as Kt}from"./dist-DQ_zK-Nr.js";import{a as qt}from"./downloadFile-kpATXaJi.js";import{i as Jt,l as Yt,o as Xt,p as Zt,r as Qt,s as B,t as $t}from"./useCurrentUser-C6OJJlWo.js";import{t as V}from"./utils-BFSTDHdM.js";import{t as H}from"./button-Cs26nq0r.js";import{t as en}from"./useNostrPublish-CrMjnYm4.js";import{t as tn}from"./nostrId-DuqQCAdJ.js";import{n as nn,t as rn}from"./useFollowActions-cve70R08.js";import{t as an}from"./useBlossomFallback-DY_46Uqi.js";import{c as on,i as sn,n as U,o as W,r as G,t as K}from"./avatar--oX_CTF4.js";import{c as cn,n as q,s as ln,u as un}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{i as dn,r as fn}from"./customEmoji-kpim4Htm.js";import{r as pn}from"./hashtag-DjDKS0mr.js";import{i as mn,n as hn,r as gn,t as J}from"./CustomEmoji-DRcU63lJ.js";import{t as _n}from"./useProfileUrl-DoFhqUUR.js";import{a as vn,b as yn,c as bn,f as xn,g as Sn,h as Cn,i as wn,o as Tn,r as En,t as Dn,y as On}from"./BioContent-BjUPDB1O.js";import{r as Y}from"./dist-Bz2abD7M.js";import{t as kn}from"./dist-BMrfXngQ.js";import{t as An}from"./FallbackImage-Dlnc8809.js";import{t as jn}from"./ExternalFavicon-BWUhHW7H.js";import{t as Mn}from"./useUserStatus-Bgu4AAxG.js";import{i as Nn,n as Pn,r as Fn}from"./haptics-Cp_uF-bV.js";import{t as In}from"./parseAddr-BmO3JZWT.js";import{t as Ln}from"./input-CM5Fnyvy.js";import{t as Rn}from"./dist-CxcvWxxD.js";import{t as zn}from"./dist-CpRh64jj.js";import{t as Bn}from"./dist-CX38Lmo0.js";import{t as Vn}from"./dist-BeEGgqo9.js";import{n as Hn,r as Un,t as Wn}from"./collapsible-C12_mOsk.js";import{a as Gn,i as Kn,n as qn,r as Jn,t as Yn}from"./dropdown-menu-ug3FLSAW.js";import{t as Xn}from"./dist-B2RAV5d5.js";import{t as Zn}from"./usePortalContainer-mvErHojv.js";import{i as Qn,r as $n,t as er}from"./popover-Dw5E1auH.js";import{t as X}from"./skeleton-CVls4GW9.js";import{t as tr}from"./ProfileCard-Baz_I7BX.js";import{t as nr}from"./useAuthors-DHw1W6Un.js";import{t as rr}from"./storageKey-Hu6452Ya.js";import{r as ir}from"./useMuteList-uFe-Ok2F.js";import{t as ar}from"./useUploadFile-BpPXwoE0.js";import{n as or,r as sr,t as cr}from"./safeNip19-CtQLwPmS.js";import{i as lr,n as ur,r as dr,t as fr}from"./useEventInteractions-Buyvdv_T.js";import{l as pr}from"./nsiteSubdomain-DmdGxq_K.js";import{a as mr,f as hr}from"./ComposeDialogContent-YxhSZA-Y.js";import{i as gr,n as _r,t as vr}from"./tooltip-Ba63GpbC.js";import{a as yr,i as br,n as Z,r as xr,s as Sr,t as Cr}from"./musicHelpers-B271Bg0t.js";import{a as wr,c as Tr,i as Er,l as Dr,n as Or,r as kr,t as Ar}from"./dialog-C3CFmras.js";import{t as jr}from"./textarea-B93xm6Zg.js";import{D as Mr,E as Nr,M as Pr,O as Fr,a as Ir,d as Lr,j as Rr,k as zr,o as Br,r as Vr,u as Hr}from"./EmbeddedPost-Bb-ngBHS.js";import{t as Ur}from"./timeAgo-BXjjbyXp.js";import{t as Wr}from"./getDisplayName-B6lnEGRj.js";import{r as Gr}from"./optimisticEvent-1jcgWuWv.js";import{i as Kr,n as qr,r as Jr}from"./useLinkPreview-CqNF97jn.js";import{n as Yr,r as Xr,t as Zr}from"./packUtils-BzqQUARG.js";import{c as Qr,i as $r,l as ei,o as ti,r as ni,s as ri,u as ii}from"./EmbeddedPublicationCard-DiFfM9Jf.js";import{_ as ai,a as oi,d as si,f as ci,n as li,r as ui,s as di,t as fi,v as pi}from"./bitcoinMoney-CQsGrYK3.js";import{n as mi,t as hi}from"./quiz-kCjrdDeU.js";import{p as gi}from"./extraKinds-BydAXtVV.js";import{y as _i}from"./sidebarItems-BFr7FKBa.js";import{t as vi}from"./badge-eEdLlpTp.js";import{i as yi}from"./cards-DDSmTmb2.js";import{n as bi,t as xi}from"./card-CthSADjg.js";import{t as Si}from"./formatNumber-D1ols1S-.js";import{t as Ci}from"./browser-B_X_RtOd.js";import{t as wi}from"./imeta-83Lqxs5-.js";import{t as Ti}from"./formatTime-CT4ZmnVr.js";import{c as Ei}from"./LayoutContext-CjQBLGO-.js";import{t as Di}from"./useInView-DAJQSIvc.js";import{$ as Oi,A as ki,B as Ai,C as ji,D as Mi,E as Ni,F as Pi,G as Fi,H as Ii,I as Li,K as Ri,L as zi,M as Bi,N as Vi,O as Hi,P as Ui,Q as Wi,R as Gi,S as Ki,T as qi,U as Ji,V as Yi,W as Xi,X as Zi,Z as Qi,_ as $i,a as ea,at as ta,b as na,c as ra,d as ia,et as aa,f as oa,g as sa,h as ca,i as la,j as ua,k as da,l as fa,m as pa,n as ma,nt as ha,o as ga,p as _a,q as va,r as ya,s as ba,t as xa,tt as Sa,u as Ca,v as wa,w as Ta,x as Ea,y as Da,z as Oa}from"./NoteCard-COwLfrJJ.js";import{t as ka}from"./useSearchProfiles-uU0NOVhy.js";import{a as Aa,o as ja,r as Ma,t as Na}from"./NoteMoreMenu-FwlS01AC.js";import{t as Pa}from"./useShareOrigin-04gGNDPW.js";import{t as Fa}from"./useFeedSettings-DkFDaYIY.js";import{n as Ia,t as La}from"./SubHeaderBar-BYwNp4Nc.js";import{n as Ra,r as za}from"./birthday-DHyHAOFk.js";import{n as Ba,t as Va}from"./useInteractionReaction-03diUK1e.js";import{t as Ha}from"./DecryptedImage-DLbW5kmn.js";import{t as Ua}from"./ContentWarningGuard-BQGV-Ggw.js";import{t as Wa}from"./label-BBIj2Nkw.js";import{n as Ga,r as Ka,t as qa}from"./dist-BEZkw2Ia.js";import{t as Ja}from"./switch-B6lxwP1L.js";import{r as Ya}from"./useRepostStatus-KJZve8_M.js";import{n as Xa,r as Za,t as Qa}from"./useBitcoinSigner-CheBjN_q.js";import{t as $a}from"./checkbox-CM1MZiSJ.js";import{t as eo}from"./separator-CWY6Ovdb.js";import{t as to}from"./scroll-area-D2CmkWvj.js";import{i as no,n as ro,r as io,t as ao}from"./useUserLists-zSWA8dQn.js";import{n as oo,t as so}from"./RepostMenu-CULlcQsd.js";import{s as co,t as lo}from"./useTrending-DsL3v2RN.js";import{t as uo}from"./useMutedAuthorFilter-CTggZCaG.js";import{C as fo,F as po,H as mo,I as ho,L as go,N as _o,P as vo,R as yo,U as bo,W as xo,_ as So,b as Co,c as wo,g as To,h as Eo,j as Do,o as Oo,r as ko,v as Ao,w as jo,y as Mo,z as No}from"./index-CYEZWNq6.js";import{E as Po}from"./blobbi-CLChx8JU.js";import{n as Fo,r as Io,t as Lo}from"./BackgroundPicker-CGrDQsA2.js";import{t as Ro}from"./AmountField-ClpN8BEX.js";import{a as zo,r as Bo,s as Vo}from"./bitcoin-DQZnWjqL.js";import{t as Ho}from"./ClientMetrics-BJhtgm76.js";import{t as Uo}from"./PageHeader-CMi4aeE4.js";import{n as Wo,r as Go,t as Ko}from"./usePendingBadges-CKhZvj_-.js";import{n as qo}from"./bookstr-BBZy-aJu.js";import{a as Jo,c as Yo,i as Xo,n as Zo,o as Qo,s as $o,t as es}from"./SavedFeedFiltersEditor-BBv6Rhov.js";import{c as ts,r as ns,s as rs,t as is}from"./useEmojiPacks-NxGstnl1.js";import{a as as,i as os,n as ss,o as cs,r as ls}from"./ExternalContentPage-C1MghKoD.js";import{t as us}from"./FollowAllSplitButton-DhOswdlt.js";import{n as ds}from"./MusicTrackRow-uvgpU0Oz.js";import{a as fs,i as ps,n as ms,o as hs,r as gs,s as _s,t as vs}from"./ProfileRightSidebar-C6uARQNo.js";import{n as ys,t as bs}from"./MediaCollage-a5ntGRyP.js";import{n as xs,t as Ss}from"./usePublishProfileTabs-BSCCnTr9.js";var Q=e(Ne(),1),Cs=e(We(),1),$=Ke();function ws({pubkey:e,displayName:t,isFollowing:n,className:r,onLoved:i}){let{user:a}=$t(),{isLoved:o,addLove:s,removeLove:c}=lt(),{toast:l}=B(),u=o(e),d=s.isPending||c.isPending;return!a||a.pubkey===e||!n&&!u?null:(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:r??`rounded-full size-10 [&_svg]:size-5`,title:u?`Remove @${t} from Love List`:`Add @${t} to Love List`,"aria-pressed":u,disabled:d,onClick:()=>{Pn(),(u?c:s).mutate(e,{onSuccess:()=>{u||i?.(),l({title:u?`Removed @${t} from your Love List`:`@${t} is on your Love List ❤️`,description:u?void 0:`Find their posts in the Loved tab of your feed.`})},onError:()=>{l({title:`Failed to update Love List`,variant:`destructive`})}})},children:u?(0,$.jsx)(C,{}):(0,$.jsx)(g,{})})}function Ts({pubkey:e,displayName:t}){let n=Gt(),[r,i]=(0,Q.useState)(!1),{data:a}=qr((0,Q.useMemo)(()=>e?{kind:15128,pubkey:e,identifier:``}:void 0,[e])),o=!!a?.tags.some(([e])=>e===`path`);if(!a||!o)return null;let s=a.tags.find(([e])=>e===`title`)?.[1]||n.formatMessage({id:`profile.nsite.fallbackName`,defaultMessage:`{name}'s site`},{name:t}),c=n.formatMessage({id:`profile.nsite.view`,defaultMessage:`View website`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`rounded-full size-10`,title:c,"aria-label":c,onClick:()=>i(!0),children:(0,$.jsx)(b,{className:`size-5`})}),(0,$.jsx)(Ea,{event:a,appName:s,open:r,onOpenChange:i})]})}var Es=20;function Ds(e,t=!0){let{nostr:n}=P();return Ze({queryKey:[`profile-media`,e??``],queryFn:async({pageParam:t,signal:r})=>{if(!e)return{events:[],oldestTimestamp:void 0,count:0};let i=AbortSignal.any([r,AbortSignal.timeout(8e3)]),a={kinds:[1,20,21,22,34236,36787,34139,30054,30055],authors:[e],search:`media:true`,limit:Es};t&&(a.until=t);let o=await n.query([a],{signal:i}),s=Math.floor(Date.now()/1e3),c=o.filter(e=>e.created_at<=s).sort((e,t)=>t.created_at-e.created_at);return{events:c,oldestTimestamp:c.length>0?c[c.length-1].created_at:void 0,count:c.length}},getNextPageParam:e=>{if(!(e.count===0||e.oldestTimestamp===void 0))return e.oldestTimestamp-1},initialPageParam:void 0,enabled:!!e&&t,staleTime:30*1e3})}function Os(e,t){return e.filter(e=>e.kind===t).reduce((e,t)=>e&&e.created_at>t.created_at?e:t,void 0)}function ks(e){let{nostr:t}=P(),n=Ye();return I({queryKey:[`profile-supplementary`,e??``],queryFn:async()=>{if(!e)return{following:[],pinnedIds:[],loved:[],interests:[]};let r=await t.query([{kinds:[3],authors:[e],limit:1},{kinds:[10001],authors:[e],limit:1},{kinds:[mt],authors:[e],limit:1},{kinds:[10015],authors:[e],limit:1}],{signal:AbortSignal.timeout(8e3)}),i=Os(r,3),a=Os(r,10001),o=Os(r,mt),s=Os(r,10015);return n.setQueryData([`pinned-notes`,e],a??null),{following:i?i.tags.filter(([e])=>e===`p`).map(([,e])=>e):[],followingEvent:i,pinnedIds:a?a.tags.filter(([e])=>e===`e`).map(([,e])=>e):[],pinnedListEvent:a,loved:ut(o),loveListEvent:o,interests:(s?.tags??[]).filter(([e])=>e===`t`).map(([,e])=>pn(e)).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t).slice(0,200),interestsEvent:s}},enabled:!!e,staleTime:300*1e3})}var As=20;function js(e,t){let{nostr:n}=P(),{mutedPubkeys:r,mutedKey:i}=uo(),a=e?`0:${e}:`:``;return Ze({queryKey:[`wall-comments`,e??``,t?.length??0,i],queryFn:async({pageParam:i,signal:o})=>{if(!e||!t||t.length===0)return{comments:[],oldestTimestamp:void 0};let s=AbortSignal.any([o,AbortSignal.timeout(8e3)]),c=(t.includes(e)?t:[e,...t]).filter(t=>t===e||!r.has(t));if(c.length===0)return{comments:[],oldestTimestamp:void 0};let l={kinds:[1111,1244],"#A":[a],authors:c,limit:As};i&&(l.until=i);let u=[...await n.query([l],{signal:s})].sort((e,t)=>t.created_at-e.created_at);return{comments:u,oldestTimestamp:u.length>0?u[u.length-1].created_at:void 0}},getNextPageParam:e=>{if(!(e.comments.length===0||e.oldestTimestamp===void 0))return e.oldestTimestamp-1},initialPageParam:void 0,enabled:!!e&&!!t&&t.length>0,staleTime:30*1e3})}function Ms(e){let{nostr:t}=P();return I({queryKey:[`activeProfileTheme`,e],queryFn:async()=>{if(!e)return null;let n=await t.query([{kinds:[Ft],authors:[e],limit:1}],{signal:AbortSignal.timeout(5e3)});return n.length===0?null:jt(n[0])},enabled:!!e,staleTime:300*1e3,gcTime:600*1e3})}var Ns=`Tabs`,[Ps,Fs]=Y(Ns,[Ka]),Is=Ka(),[Ls,Rs]=Ps(Ns),zs=Q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Xn(s),[d,f]=kn({prop:r,onChange:i,defaultProp:a??``,caller:Ns});return(0,$.jsx)(Ls,{scope:n,baseId:Vn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,$.jsx)(zn.div,{dir:u,"data-orientation":o,...l,ref:t})})});zs.displayName=Ns;var Bs=`TabsList`,Vs=Q.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Rs(Bs,n),o=Is(n);return(0,$.jsx)(Ga,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,$.jsx)(zn.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Vs.displayName=Bs;var Hs=`TabsTrigger`,Us=Q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Rs(Hs,n),s=Is(n),c=Ks(o.baseId,r),l=qs(o.baseId,r),u=r===o.value;return(0,$.jsx)(qa,{asChild:!0,...s,focusable:!i,active:u,children:(0,$.jsx)(zn.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:Rn(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:Rn(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:Rn(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Us.displayName=Hs;var Ws=`TabsContent`,Gs=Q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Rs(Ws,n),c=Ks(s.baseId,r),l=qs(s.baseId,r),u=r===s.value,d=Q.useRef(u);return Q.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,$.jsx)(Bn,{present:i||u,children:({present:n})=>(0,$.jsx)(zn.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Gs.displayName=Ws;function Ks(e,t){return`${e}-trigger-${t}`}function qs(e,t){return`${e}-content-${t}`}var Js=zs,Ys=Vs,Xs=Us,Zs=Gs,Qs=Js,$s=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(Ys,{ref:n,className:V(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,e),...t}));$s.displayName=Ys.displayName;var ec=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(Xs,{ref:n,className:V(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,e),...t}));ec.displayName=Xs.displayName;var tc=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(Zs,{ref:n,className:V(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));tc.displayName=Zs.displayName;async function nc(e,t,n){let r=[],i=new Set;for await(let a of e.req(t,{signal:n})){if(a[0]===`EOSE`||a[0]===`CLOSED`)break;if(a[0]===`EVENT`){let e=a[2];i.has(e.id)||(i.add(e.id),r.push(e))}}return r}function rc(e){try{return JSON.parse(e)}catch{return}}function ic(e){return new Date(e*1e3).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ac(e){return`hsl(${e})`}function oc({event:e,isCurrent:t,onRestore:n,isRestoring:r}){let i=(0,Q.useMemo)(()=>rc(e.content),[e.content]),a=i?.name||i?.display_name||`Anonymous`,o=W(i);return(0,$.jsxs)(`div`,{className:V(`group relative rounded-xl border p-4 transition-all`,t?`border-primary/40 bg-primary/5`:`border-border hover:border-primary/20 hover:bg-secondary/30`),children:[(0,$.jsx)(`div`,{className:`absolute top-3 right-3`,children:t?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-xs font-medium text-primary`,children:[(0,$.jsx)(Oe,{className:`size-3.5`}),`Current`]}):(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-8 text-xs rounded-lg gap-1.5`,onClick:n,disabled:r,children:[r?(0,$.jsx)(N,{className:`size-3.5 animate-spin`}):(0,$.jsx)(c,{className:`size-3.5`}),`Restore`]})}),(0,$.jsxs)(`div`,{className:`flex items-start gap-3 pr-24`,children:[(0,$.jsxs)(K,{shape:o,className:`size-11 shrink-0 ring-2 ring-background`,children:[i?.picture?(0,$.jsx)(G,{src:i.picture,alt:a}):null,(0,$.jsx)(U,{className:`bg-primary/10 text-primary text-sm font-semibold`,children:a[0]?.toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-sm truncate`,children:a}),i?.nip05&&(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:i.nip05}),i?.about&&(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-2 leading-relaxed`,children:i.about}),(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 pt-0.5`,children:ic(e.created_at)})]})]})]})}function sc({event:e,isCurrent:t,onRestore:n,isRestoring:r}){let i=(0,Q.useMemo)(()=>jt(e),[e]),a=e.tags.find(([e])=>e===`title`)?.[1]??`Profile Theme`,o=(0,Q.useMemo)(()=>i?It(i.colors):null,[i]);return!i||!o?null:(0,$.jsxs)(`div`,{className:V(`group relative rounded-xl border overflow-hidden transition-all`,t?`border-primary/40 bg-primary/5`:`border-border hover:border-primary/20`),children:[(0,$.jsx)(`div`,{className:`absolute top-3 right-3 z-10`,children:t?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-xs font-medium text-primary bg-background/80 backdrop-blur-sm rounded-full px-2 py-0.5`,children:[(0,$.jsx)(Oe,{className:`size-3.5`}),`Current`]}):(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-8 text-xs rounded-lg gap-1.5 bg-background/80 backdrop-blur-sm`,onClick:n,disabled:r,children:[r?(0,$.jsx)(N,{className:`size-3.5 animate-spin`}):(0,$.jsx)(c,{className:`size-3.5`}),`Restore`]})}),(0,$.jsxs)(`div`,{className:`aspect-[3/1] relative`,style:{backgroundColor:ac(o.background)},children:[i.background?.url&&(0,$.jsx)(`img`,{src:i.background.url,alt:``,className:`absolute inset-0 w-full h-full object-cover opacity-40`,decoding:`async`}),(0,$.jsxs)(`div`,{className:`p-4 space-y-2 relative`,children:[(0,$.jsx)(`div`,{className:`h-2.5 w-3/4 rounded-full`,style:{backgroundColor:ac(o.foreground),opacity:.5}}),(0,$.jsx)(`div`,{className:`h-2.5 w-1/2 rounded-full`,style:{backgroundColor:ac(o.mutedForeground),opacity:.35}}),(0,$.jsx)(`div`,{className:`h-5 w-20 rounded`,style:{backgroundColor:ac(o.primary)}})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium truncate`,children:a}),(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:ic(e.created_at)})]})]})}function cc({event:e,isCurrent:t,onRestore:n,isRestoring:r}){let i=(0,Q.useMemo)(()=>e.tags.filter(([e,t])=>e===`p`&&typeof t==`string`&&/^[0-9a-f]{64}$/.test(t)).map(([,e])=>e).reverse(),[e.tags]),a=i.length;return(0,$.jsxs)(`div`,{className:V(`group relative rounded-xl border p-4 transition-all`,t?`border-primary/40 bg-primary/5`:`border-border hover:border-primary/20 hover:bg-secondary/30`),children:[(0,$.jsx)(`div`,{className:`absolute top-3 right-3`,children:t?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-xs font-medium text-primary`,children:[(0,$.jsx)(Oe,{className:`size-3.5`}),`Current`]}):(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-8 text-xs rounded-lg gap-1.5`,onClick:n,disabled:r,children:[r?(0,$.jsx)(N,{className:`size-3.5 animate-spin`}):(0,$.jsx)(c,{className:`size-3.5`}),`Restore`]})}),a>0?(0,$.jsx)(`div`,{className:`pr-24`,children:(0,$.jsx)(L,{pubkeys:i,maxVisible:8,size:`md`})}):(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground pr-24`,children:`No follows`}),(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-2`,children:ic(e.created_at)})]})}function lc({label:e}){return(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})})}function uc(){return(0,$.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,$.jsx)(`div`,{className:`rounded-xl border p-4 space-y-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-40`}),(0,$.jsx)(X,{className:`h-3 w-20`})]})]})},e))})}function dc({onClose:e}){let{nostr:t}=P(),{user:n}=$t(),{mutateAsync:r}=en(),{toast:i}=B(),a=Ye(),[o,s]=(0,Q.useState)(null),c=n?.pubkey,l=I({queryKey:[`profile-recovery`,`kind0`,c],queryFn:async()=>c?(await nc(t,[{kinds:[0],authors:[c]}],AbortSignal.timeout(1e4))).sort((e,t)=>t.created_at-e.created_at):[],enabled:!!c,staleTime:3e4}),u=l.data??[],d=u[0]?.id,f=async t=>{s(t.id);try{await r({kind:t.kind,content:t.content,tags:t.tags,created_at:Math.floor(Date.now()/1e3)}),i({title:`Profile restored`,description:`Successfully restored from ${ic(t.created_at)}.`}),a.invalidateQueries({queryKey:[`profile-recovery`,`kind0`,c]}),a.invalidateQueries({queryKey:[`author`,c]}),e()}catch(e){console.error(`Failed to restore event:`,e),i({title:`Restore failed`,description:`Could not republish the event. Please try again.`,variant:`destructive`})}finally{s(null)}};return l.isLoading?(0,$.jsx)(uc,{}):u.length===0?(0,$.jsx)(lc,{label:`No profile history found. Your relay may not store historical events.`}):(0,$.jsx)($.Fragment,{children:u.map(e=>(0,$.jsx)(oc,{event:e,isCurrent:e.id===d,onRestore:()=>f(e),isRestoring:o===e.id},e.id))})}function fc({onClose:e}){let{nostr:t}=P(),{user:n}=$t(),{mutateAsync:r}=en(),{toast:i}=B(),a=Ye(),[o,s]=(0,Q.useState)(null),c=n?.pubkey,l=I({queryKey:[`profile-recovery`,`kind16767`,c],queryFn:async()=>c?(await nc(t,[{kinds:[Ft],authors:[c]}],AbortSignal.timeout(1e4))).sort((e,t)=>t.created_at-e.created_at).filter(e=>jt(e)!==null):[],enabled:!!c,staleTime:3e4}),u=l.data??[],d=u[0]?.id,f=async t=>{s(t.id);try{await r({kind:t.kind,content:t.content,tags:t.tags,created_at:Math.floor(Date.now()/1e3)}),i({title:`Theme restored`,description:`Successfully restored from ${ic(t.created_at)}.`}),a.invalidateQueries({queryKey:[`profile-recovery`,`kind16767`,c]}),a.invalidateQueries({queryKey:[`activeProfileTheme`,c]}),e()}catch(e){console.error(`Failed to restore event:`,e),i({title:`Restore failed`,description:`Could not republish the event. Please try again.`,variant:`destructive`})}finally{s(null)}};return l.isLoading?(0,$.jsx)(uc,{}):u.length===0?(0,$.jsx)(lc,{label:`No theme history found. Your relay may not store historical events.`}):(0,$.jsx)($.Fragment,{children:u.map(e=>(0,$.jsx)(sc,{event:e,isCurrent:e.id===d,onRestore:()=>f(e),isRestoring:o===e.id},e.id))})}function pc({onClose:e}){let{nostr:t}=P(),{user:n}=$t(),{mutateAsync:r}=en(),{toast:i}=B(),a=Ye(),[o,s]=(0,Q.useState)(null),c=n?.pubkey,l=I({queryKey:[`profile-recovery`,`kind3`,c],queryFn:async()=>c?(await nc(t,[{kinds:[3],authors:[c]}],AbortSignal.timeout(1e4))).sort((e,t)=>t.created_at-e.created_at):[],enabled:!!c,staleTime:3e4}),u=l.data??[],d=u[0]?.id,f=async t=>{s(t.id);try{await r({kind:t.kind,content:t.content,tags:t.tags,created_at:Math.floor(Date.now()/1e3)}),i({title:`Follow list restored`,description:`Successfully restored from ${ic(t.created_at)}.`}),a.invalidateQueries({queryKey:[`profile-recovery`,`kind3`,c]}),a.invalidateQueries({queryKey:[`follow-list`]}),e()}catch(e){console.error(`Failed to restore event:`,e),i({title:`Restore failed`,description:`Could not republish the event. Please try again.`,variant:`destructive`})}finally{s(null)}};return l.isLoading?(0,$.jsx)(uc,{}):u.length===0?(0,$.jsx)(lc,{label:`No follow list history found. Your relay may not store historical events.`}):(0,$.jsx)($.Fragment,{children:u.map(e=>(0,$.jsx)(cc,{event:e,isCurrent:e.id===d,onRestore:()=>f(e),isRestoring:o===e.id},e.id))})}function mc({open:e,onOpenChange:t}){let n=()=>t(!1);return(0,$.jsx)(Ar,{open:e,onOpenChange:t,children:(0,$.jsxs)(Or,{className:`max-w-lg p-0 gap-0 rounded-2xl overflow-hidden`,children:[(0,$.jsx)(wr,{className:`px-6 pt-6 pb-2`,children:(0,$.jsx)(Tr,{className:`text-lg font-bold`,children:`Profile Recovery`})}),(0,$.jsxs)(Qs,{defaultValue:`profile`,className:`w-full`,children:[(0,$.jsx)(`div`,{className:`px-6`,children:(0,$.jsxs)($s,{className:`w-full`,children:[(0,$.jsxs)(ec,{value:`profile`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(o,{className:`size-3.5`}),`Profile`]}),(0,$.jsxs)(ec,{value:`follows`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(j,{className:`size-3.5`}),`Follows`]}),(0,$.jsxs)(ec,{value:`theme`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(S,{className:`size-3.5`}),`Theme`]})]})}),(0,$.jsx)(eo,{className:`mt-3`}),(0,$.jsxs)(to,{className:`h-[420px]`,children:[(0,$.jsx)(tc,{value:`profile`,className:`m-0 p-4 space-y-3`,children:(0,$.jsx)(dc,{onClose:n})}),(0,$.jsx)(tc,{value:`follows`,className:`m-0 p-4 space-y-3`,children:(0,$.jsx)(pc,{onClose:n})}),(0,$.jsx)(tc,{value:`theme`,className:`m-0 p-4 space-y-3`,children:(0,$.jsx)(fc,{onClose:n})})]})]})]})})}function hc({open:e,onOpenChange:t,recipientPubkey:n,recipientName:r}){let{user:i}=$t(),{nostr:a}=P(),{toast:o}=B(),{mutateAsync:s}=Go(),[c,l]=(0,Q.useState)(new Set),[u,d]=(0,Q.useState)(!1),{data:f,isLoading:p}=I({queryKey:[`my-created-badges`,i?.pubkey??``],queryFn:async({signal:e})=>i?a.query([{kinds:[bn],authors:[i.pubkey],limit:200}],{signal:e}):[],enabled:!!i&&e,staleTime:6e4}),{data:m,isLoading:h}=I({queryKey:[`badge-awards-from-to`,i?.pubkey??``,n],queryFn:async({signal:e})=>i?a.query([{kinds:[8],authors:[i.pubkey],"#p":[n],limit:500}],{signal:e}):[],enabled:!!i&&e,staleTime:3e4}),g=(0,Q.useMemo)(()=>{let e=new Set;if(!m)return e;for(let t of m){let n=t.tags.find(([e])=>e===`a`)?.[1];n&&e.add(n)}return e},[m]),_=(0,Q.useMemo)(()=>{if(!f)return[];let e=[];for(let t of f){let n=vn(t);n&&e.push({event:t,badge:n,aTag:xn(t)})}return e.sort((e,t)=>t.event.created_at-e.event.created_at)},[f]),v=p||h,y=(0,Q.useCallback)(e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,$.jsx)(Ar,{open:e,onOpenChange:e=>{e||l(new Set),t(e)},children:(0,$.jsxs)(Or,{className:`sm:max-w-md gap-0 p-0 overflow-hidden`,children:[(0,$.jsxs)(wr,{className:`px-4 pt-5 pb-3`,children:[(0,$.jsxs)(Tr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(O,{className:`size-5 text-primary`}),`Award Badges`]}),(0,$.jsxs)(kr,{className:`text-sm text-muted-foreground`,children:[`Select badges to award to `,(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),`.`]})]}),(0,$.jsx)(to,{style:{height:340},children:v?(0,$.jsx)(`div`,{className:`p-4 space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{className:`size-12 rounded-lg shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-32`}),(0,$.jsx)(X,{className:`h-3 w-48`})]})]},t))}):_.length>0?(0,$.jsx)(`div`,{children:_.map(e=>{let t=g.has(e.aTag),n=c.has(e.aTag);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>!t&&y(e.aTag),disabled:u||t,className:`group flex items-center gap-3 w-full px-4 py-3 text-left hover:bg-secondary/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,$.jsx)($a,{checked:n,onCheckedChange:()=>!t&&y(e.aTag),disabled:u||t,className:`shrink-0`,onClick:e=>e.stopPropagation()}),(0,$.jsx)(On,{badge:e.badge,size:48,className:`shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-sm block truncate`,children:e.badge.name}),t&&(0,$.jsxs)(vi,{variant:`outline`,className:`shrink-0 text-[10px] px-1.5 py-0 h-4 gap-1 text-amber-600 border-amber-300 dark:text-amber-400 dark:border-amber-600`,children:[(0,$.jsx)(Fe,{className:`size-2.5`}),`Already sent`]})]}),e.badge.description&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:e.badge.description})]}),(0,$.jsx)(`span`,{className:`shrink-0 ml-auto`,children:n?(0,$.jsx)(Oe,{className:`size-4 text-primary`}):null})]},e.aTag)})}):(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-muted-foreground text-sm`,children:[(0,$.jsx)(O,{className:`size-8 mb-2 opacity-30`}),(0,$.jsx)(`p`,{children:`You haven't created any badges yet.`}),(0,$.jsxs)(`p`,{className:`text-xs mt-1`,children:[`Create badges on the `,(0,$.jsx)(`a`,{href:`/badges`,className:`text-primary hover:underline`,children:`Badges page`}),`.`]})]})}),_.length>0&&(0,$.jsx)(Er,{className:`px-4 py-3`,children:(0,$.jsx)(H,{onClick:async()=>{if(c.size===0)return;d(!0);let e=_.filter(e=>c.has(e.aTag)),i=[],a=[];for(let t of e)try{await s({aTag:t.aTag,recipientPubkeys:[n]}),i.push(t.badge.name)}catch{a.push(t.badge.name)}if(i.length>0){let e=i.length<=3?i.map(e=>`"${e}"`).join(`, `):`${i.length} badges`;o({title:`Badges awarded!`,description:`${e} awarded to ${r}.`})}a.length>0&&o({title:`Failed to award ${a.length} badge${a.length>1?`s`:``}`,description:`Please try again.`,variant:`destructive`}),l(new Set),d(!1),a.length===0&&t(!1)},disabled:c.size===0||u,className:`w-full gap-2`,children:u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{className:`size-4 animate-spin`}),`Awarding...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`size-4`}),`Award `,c.size>0?`${c.size} badge${c.size>1?`s`:``}`:`badges`]})})})]})})}var gc=[`images`,`videos`,`none`],_c={images:`Images`,videos:`Videos`,none:`No media`},vc={images:r,videos:ge,none:T},yc=/\b(?:media|video):(?:true|false)\b/gi;function bc(e){let t=e.has(`images`),n=e.has(`videos`);return e.has(`none`)&&!t&&!n?[`media:false`]:t&&n?[`media:true`]:t&&!n?[`media:true`,`video:false`]:n&&!t?[`video:true`]:[]}function xc(e){let t=new Set,n=e.replace(yc,e=>(t.add(e.toLowerCase()),``)).replace(/\s+/g,` `).trim(),r=new Set;return t.has(`media:false`)?r.add(`none`):t.has(`media:true`)?(r.add(`images`),t.has(`video:false`)||r.add(`videos`)):t.has(`video:true`)&&r.add(`videos`),{categories:r,query:n}}function Sc(e,t){let n=[],r=e.trim();return r&&n.push(r),n.push(...bc(t)),n.length>0?n.join(` `):void 0}function Cc(e,t,n){switch(e){case`me`:return{authors:[t]};case`contacts`:return{authors:[`$follows`]};case`people`:return n.length>0?{authors:n}:{};case`global`:return{}}}function wc(e,t){let n=Array.isArray(e.authors)?e.authors:[];return n.length===1&&n[0]===t?`me`:n.includes(`$follows`)?`contacts`:n.length>0?`people`:`global`}function Tc(e,t){let n=Array.isArray(e.authors)?e.authors:[];return n.includes(`$follows`)||n.length===1&&n[0]===t?[]:n.filter(e=>e!==t&&!e.startsWith(`$`))}function Ec(e){return e.map(Number).filter(e=>!isNaN(e)&&e>0)}var Dc=[{value:`me`,label:`Me`,icon:o},{value:`contacts`,label:`Contacts`,icon:j},{value:`people`,label:`People`,icon:se},{value:`global`,label:`Global`,icon:b}];function Oc({open:e,onOpenChange:t,tab:n,ownerPubkey:r,onSave:i,isPending:a=!1}){let o=(0,Q.useMemo)(()=>$o(),[]),{lists:s}=ro(),{data:c=[]}=no(),l=!n,u=(0,Q.useMemo)(()=>n?n.filter:{authors:[r]},[n,r]),d=(0,Q.useMemo)(()=>xc(typeof u.search==`string`?u.search:``),[u.search]),[f,p]=(0,Q.useState)(n?.label??``),[m,h]=(0,Q.useState)(d.query),[g,_]=(0,Q.useState)(d.categories),[v,y]=(0,Q.useState)(wc(u,r)),[b,x]=(0,Q.useState)(Tc(u,r)),[S,C]=(0,Q.useState)(Yo(u)),[w,T]=(0,Q.useState)(void 0),E=ao(b),D=(0,Q.useCallback)(e=>{T(e??void 0)},[]),O=(0,Q.useCallback)(e=>{x(t=>t.includes(e)?t:[...t,e]),y(`people`)},[]),ee=(0,Q.useCallback)(e=>{x(t=>t.filter(t=>t!==e))},[]),te=(0,Q.useCallback)(e=>{y(e),e!==`people`&&x([])},[]),ne=(0,Q.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):e===`none`?(n.clear(),n.add(`none`)):(n.delete(`none`),n.add(e)),n})},[]);(0,Q.useEffect)(()=>{if(e){let e=n?n.filter:{authors:[r]},t=xc(typeof e.search==`string`?e.search:``);p(n?.label??``),h(t.query),_(t.categories),y(wc(e,r)),x(Tc(e,r)),C(Yo(e))}},[e,n,r]);let k=async()=>{if(!f.trim()||a)return;let e={...Cc(v,r,b)},n=Sc(m,g);n&&(e.search=n);let o=Ec(S);o.length>0&&(e.kinds=o),await i({label:f.trim(),filter:e}),t(!1)};return(0,$.jsx)(Ar,{open:e,onOpenChange:t,children:(0,$.jsx)(Or,{ref:D,className:`max-w-sm max-h-[90dvh] overflow-y-auto`,children:(0,$.jsxs)(Zn,{value:w,children:[(0,$.jsx)(wr,{children:(0,$.jsx)(Tr,{children:l?`Add profile tab`:`Edit tab`})}),(0,$.jsxs)(`div`,{className:`space-y-5 py-1`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Tab name`}),(0,$.jsx)(Ln,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()},placeholder:`e.g. My Art, Bitcoin posts...`,autoFocus:!0,className:`h-9`})]}),(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Content Kinds`}),(0,$.jsx)(Jo,{selectedKinds:S,options:o,onChange:C})]}),(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Media`}),(0,$.jsx)(`div`,{className:`rounded-lg border border-border overflow-hidden flex`,children:gc.map(e=>{let t=vc[e],n=g.has(e);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>ne(e),className:V(`flex-1 flex items-center justify-center gap-1.5 py-2 text-sm font-medium transition-colors`,n?`bg-primary text-primary-foreground`:`bg-secondary/40 text-muted-foreground hover:bg-secondary hover:text-foreground`),children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0`}),_c[e]]},e)})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:g.has(`none`)?`Only show posts without media.`:g.has(`images`)&&g.has(`videos`)?`Only show posts with media (images or videos).`:g.has(`images`)?`Only show posts with images.`:g.has(`videos`)?`Only show posts with videos.`:`Show all posts, with or without media.`})]}),(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Filter by Word`}),(0,$.jsx)(Ln,{value:m,onChange:e=>h(e.target.value),placeholder:`e.g. photography, travel...`,className:`bg-secondary/50 border-border focus-visible:ring-1 h-9 text-base md:text-sm`})]}),(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Authors`}),(0,$.jsx)(Qo,{value:v,options:Dc,onChange:te,size:`md`}),v===`people`?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[b.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:b.map(e=>(0,$.jsx)(es,{pubkey:e,onRemove:()=>ee(e)},e))}),(0,$.jsx)(Zo,{onCommit:e=>O(e)}),(0,$.jsx)(Xo,{lists:s,followPacks:c,value:E,onSelectPubkeys:e=>{x(e),e.length>0&&y(`people`)}})]}):(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[v===`me`&&`Only show your own posts.`,v===`contacts`&&`Show posts from people you follow.`,v===`global`&&`Show posts from everyone.`]})]})]}),(0,$.jsxs)(Er,{className:`flex-col gap-2 pt-3 sm:flex-col`,children:[(0,$.jsxs)(H,{className:`w-full gap-2`,onClick:k,disabled:!f.trim()||a,children:[a?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(Oe,{className:`size-4`}),l?`Add tab`:`Save changes`]}),(0,$.jsx)(H,{variant:`ghost`,className:`w-full`,onClick:()=>t(!1),disabled:a,children:`Cancel`})]})]})})})}var kc=.09,Ac=60/132,jc=.25,Mc=98,Nc=130.81,Pc=164.81,Fc=174.61,Ic=196,Lc=220,Rc=246.94,zc=261.63,Bc=293.66,Vc=349.23,Hc=392,Uc=440,Wc=493.88,Gc=523.25,Kc=587.33,qc=659.25,Jc=698.46,Yc=783.99,Xc=1046.5,Zc=[[Hc,.75],[Hc,.25],[Uc,1],[Hc,1],[Gc,1],[Wc,2],[Hc,.75],[Hc,.25],[Uc,1],[Hc,1],[Kc,1],[Gc,2],[Hc,.75],[Hc,.25],[Yc,1],[qc,1],[Gc,1],[Wc,1],[Uc,1],[Jc,.75],[Jc,.25],[qc,1],[Gc,1],[Kc,1],[Gc,2]],Qc=Zc.reduce((e,[,t])=>e+t,0),$c=[[Nc,[Pc,Ic],1],[Mc,[Rc,Bc],4],[Mc,[Rc,Bc],7],[Nc,[Pc,Ic],10],[Nc,[Pc,Ic],13],[Fc,[Lc,zc],16],[Mc,[Rc,Vc],19],[Nc,[Pc,Ic],22]],el=[[qc,22.5],[Yc,23],[Xc,23.5]],tl=Qc*Ac,nl=null;function rl(){if(nl)return nl;try{nl=new AudioContext}catch{nl=null}return nl}var il=!1;function al(){let e=rl();e&&e.state===`suspended`&&e.resume().catch(()=>{})}function ol(){if(il||typeof window>`u`)return;il=!0;let e=()=>{al(),window.removeEventListener(`pointerdown`,e),window.removeEventListener(`touchend`,e),window.removeEventListener(`keydown`,e),window.removeEventListener(`click`,e)};window.addEventListener(`pointerdown`,e),window.addEventListener(`touchend`,e),window.addEventListener(`keydown`,e),window.addEventListener(`click`,e)}ol();var sl=null;function cl(e,t){e.onended=()=>{try{for(let e of t)e.disconnect()}catch{}}}function ll(e,t,n,r){let{ac:i,leadBus:a}=e,o=r*Ac,s=Math.min(Math.max(o*.62,.1),.9),c=i.createGain();c.gain.setValueAtTime(1e-4,n),c.gain.linearRampToValueAtTime(.55,n+.006),c.gain.setValueAtTime(.42,n+s*.4),c.gain.exponentialRampToValueAtTime(1e-4,n+s),c.connect(a);let l=i.createOscillator();l.type=`square`,l.frequency.setValueAtTime(t,n),l.connect(c),l.start(n),l.stop(n+s+.03),e.nodes.push(c,l),cl(l,[l,c])}function ul(e,t,n){let{ac:r,leadBus:i}=e,a=.55,o=r.createGain();o.gain.setValueAtTime(1e-4,n),o.gain.linearRampToValueAtTime(.3,n+.004),o.gain.exponentialRampToValueAtTime(1e-4,n+a),o.connect(i);let s=r.createOscillator();s.type=`sine`,s.frequency.setValueAtTime(t*2,n),s.connect(o),s.start(n),s.stop(n+a+.03);let c=r.createGain();c.gain.setValueAtTime(1e-4,n),c.gain.linearRampToValueAtTime(.12,n+.003),c.gain.exponentialRampToValueAtTime(1e-4,n+.12),c.connect(i);let l=r.createOscillator();l.type=`sine`,l.frequency.setValueAtTime(t*2*2.76,n),l.connect(c),l.start(n),l.stop(n+.15),e.nodes.push(o,s,c,l),cl(s,[s,o,l,c])}function dl(e,t,n,r){let{ac:i,lowpass:a}=e,o=.32,s=i.createGain();s.gain.setValueAtTime(1e-4,n),s.gain.linearRampToValueAtTime(r,n+.008),s.gain.exponentialRampToValueAtTime(1e-4,n+o),s.connect(a);let c=i.createOscillator();c.type=`triangle`,c.frequency.setValueAtTime(t,n),c.connect(s),c.start(n),c.stop(n+o+.03),e.nodes.push(s,c),cl(c,[c,s])}function fl(e,t,n){let{ac:r,leadBus:i}=e,a=.28,o=r.createGain();o.gain.setValueAtTime(1e-4,n),o.gain.linearRampToValueAtTime(.4,n+.008),o.gain.exponentialRampToValueAtTime(1e-4,n+a),o.connect(i);let s=r.createOscillator();s.type=`sine`,s.frequency.setValueAtTime(t,n),s.connect(o),s.start(n),s.stop(n+a+.03),e.nodes.push(o,s),cl(s,[s,o])}function pl(e,t){if(e.stopped)return;let n=e=>t+e*Ac,r=0;for(let[t,i]of Zc)ll(e,t,n(r),i),ul(e,t,n(r)),r+=i;for(let[t,r,i]of $c){dl(e,t,n(i),.5);for(let t=0;t<2;t++)for(let a of r)dl(e,a,n(i+1+t),.16)}for(let[t,r]of el)fl(e,t,n(r));let i=t+tl,a=Math.max((i-e.ac.currentTime-jc)*1e3,0);e.timer=setTimeout(()=>pl(e,i),a)}function ml(e){e.stopped||pl(e,e.ac.currentTime+.1)}function hl(){if(!sl)try{let e=rl();if(!e)return;let t=e.createBiquadFilter();t.type=`lowpass`,t.frequency.value=3400,t.Q.value=.5;let n=e.createGain();n.gain.value=kc,t.connect(n),n.connect(e.destination);let r=e.createGain();r.gain.value=1,r.connect(t);let i=e.createDelay(1);i.delayTime.value=Ac*.75;let a=e.createGain();a.gain.value=.3;let o=e.createGain();o.gain.value=.22,r.connect(i),i.connect(a),a.connect(i),i.connect(o),o.connect(t);let s={ac:e,master:n,lowpass:t,leadBus:r,echoNodes:[i,a,o],nodes:[],timer:null,gestureCleanup:null,began:!1,stopped:!1};sl=s;let c=()=>{s.began||s.stopped||e.state!==`running`||(s.began=!0,s.gestureCleanup?.(),ml(s))};if(e.state===`suspended`){let t=()=>{e.resume().then(c).catch(()=>{})};window.addEventListener(`pointerdown`,t),window.addEventListener(`touchend`,t),window.addEventListener(`keydown`,t),window.addEventListener(`click`,t),s.gestureCleanup=()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`touchend`,t),window.removeEventListener(`keydown`,t),window.removeEventListener(`click`,t),s.gestureCleanup=null},e.resume().then(c).catch(()=>{})}else c()}catch{sl=null}}function gl(){let e=sl;if(e){sl=null,e.stopped=!0;try{e.timer!==null&&clearTimeout(e.timer),e.gestureCleanup?.();let t=e.ac.currentTime;e.master.gain.cancelScheduledValues(t),e.master.gain.setValueAtTime(e.master.gain.value,t),e.master.gain.linearRampToValueAtTime(1e-4,t+.15),setTimeout(()=>{try{for(let t of e.nodes)t.disconnect();for(let t of e.echoNodes)t.disconnect();e.leadBus.disconnect(),e.lowpass.disconnect(),e.master.disconnect()}catch{}},200)}catch{}}}var _l=e(Ci(),1);function vl(e){try{let t=JSON.parse(e);if(Array.isArray(t?.fields))return t.fields.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>({label:e[0],value:e[1]}))}catch{}return[]}function yl({pubkey:e,displayName:t,open:n,onOpenChange:r,isOwnProfile:i,authorEvent:a}){let{toast:o}=B(),{user:s}=$t(),u=cn(),d=Pa(),f=(0,Q.useMemo)(()=>F.npubEncode(e),[e]),{addMute:p,removeMute:h,isMuted:g}=ir(),_=g(`pubkey`,e),{addToSidebar:v,removeFromSidebar:y,orderedItems:b}=Fa(),S=`nostr:${f}`,C=b.includes(S),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(!1),[k,re]=(0,Q.useState)(!1),[A,ie]=(0,Q.useState)(!1),j=(0,Q.useRef)(null),[ae,oe]=(0,Q.useState)(!1),se=!i&&!!a,ce=()=>r(!1),le=e=>{ce(),setTimeout(()=>e(!0),150)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ar,{open:n,onOpenChange:r,children:(0,$.jsxs)(Or,{className:`max-w-md p-0 gap-0 rounded-2xl overflow-hidden [&>button]:hidden`,children:[(0,$.jsx)(Tr,{className:`sr-only`,children:`Profile options`}),(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsx)(bl,{icon:(0,$.jsx)(x,{className:`size-5`}),label:`Copy public key`,onClick:()=>{navigator.clipboard.writeText(f),o({title:`Public key copied to clipboard`}),ce()}}),(0,$.jsx)(bl,{icon:(0,$.jsx)(x,{className:`size-5`}),label:`Copy profile link`,onClick:()=>{let e=`${d}/${f}`;navigator.clipboard.writeText(e),o({title:`Profile link copied to clipboard`}),ce()}}),(0,$.jsx)(bl,{icon:(0,$.jsx)(He,{className:`size-5`}),label:`Add to list`,onClick:()=>le(D)}),(0,$.jsx)(bl,{icon:C?(0,$.jsx)(l,{className:`size-5`}):(0,$.jsx)(m,{className:`size-5`}),label:C?`Remove from sidebar`:`Add to sidebar`,onClick:()=>{C?(y(S),o({title:`Removed from sidebar`})):(v(S),o({title:`Added to sidebar`})),ce()}})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsx)(bl,{icon:(0,$.jsx)(ee,{className:`size-5`}),label:`Share follow link`,onClick:()=>le(ie)}),(0,$.jsx)(bl,{icon:(0,$.jsx)(c,{className:`size-5`}),label:`Profile recovery`,onClick:()=>le(ne)})]})]}),!i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(eo,{}),(0,$.jsxs)(`div`,{className:`py-1`,children:[se&&(0,$.jsx)(bl,{icon:(0,$.jsx)(Pe,{className:`size-5`}),label:`Zap`,onClick:()=>{ce(),oe(!0),setTimeout(()=>j.current?.click(),150)}}),s&&(0,$.jsx)(bl,{icon:(0,$.jsx)(O,{className:`size-5`}),label:`Award badge`,onClick:()=>le(re)}),s&&(0,$.jsx)(bl,{icon:(0,$.jsx)(xe,{className:`size-5`}),label:`Write a letter`,onClick:()=>{ce(),u(`/letters/compose?to=${f}`)}}),(0,$.jsx)(bl,{icon:(0,$.jsx)(pe,{className:`size-5`}),label:_?`Unmute @${t}`:`Mute @${t}`,onClick:()=>{let n={type:`pubkey`,value:e};(_?h:p).mutate(n,{onSuccess:()=>{o({title:_?`Unmuted @${t}`:`Muted @${t}`})},onError:()=>{o({title:_?`Failed to unmute user`:`Failed to mute user`,variant:`destructive`})}}),ce()}}),(0,$.jsx)(bl,{icon:(0,$.jsx)(Ie,{className:`size-5`}),label:`Report @${t}`,onClick:()=>le(T),destructive:!0})]})]}),(0,$.jsx)(eo,{}),(0,$.jsx)(`div`,{className:`py-1`,children:(0,$.jsx)(H,{variant:`ghost`,className:`w-full h-auto py-3 text-[15px] font-medium text-muted-foreground hover:bg-secondary/60 rounded-none`,onClick:ce,children:`Close`})})]})}),(0,$.jsx)(ja,{pubkey:e,open:w,onOpenChange:T}),E&&(0,$.jsx)(Aa,{pubkey:e,displayName:t,open:E,onOpenChange:D}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mc,{open:te,onOpenChange:ne}),(0,$.jsx)(_o,{open:A,onOpenChange:ie})]}),!i&&(0,$.jsx)(hc,{open:k,onOpenChange:re,recipientPubkey:e,recipientName:t}),se&&a&&ae&&(0,$.jsx)(Ya,{target:a,children:(0,$.jsx)(`span`,{ref:j,className:`hidden`})})]})}function bl({icon:e,label:t,onClick:n,destructive:r}){return(0,$.jsxs)(`button`,{onClick:n,className:V(`flex items-center gap-4 w-full px-5 py-3 text-[15px] transition-colors hover:bg-secondary/60`,r?`text-destructive`:`text-muted-foreground`),children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:e}),(0,$.jsx)(`span`,{children:t})]})}function xl({pubkey:e,onNavigate:t}){let n=Yt(e),r=n.data?.metadata,i=W(r),a=r?.name||r?.display_name||`Anonymous`;return(0,$.jsx)(q,{to:`/${(0,Q.useMemo)(()=>F.npubEncode(e),[e])}`,onClick:t,className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/40 transition-colors`,children:n.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-36`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{shape:i,className:`size-10 shrink-0`,children:[(0,$.jsx)(G,{src:r?.picture,alt:a}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:a[0]?.toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-bold text-sm truncate`,children:n.data?.event?(0,$.jsx)(hn,{tags:n.data.event.tags,children:a}):a}),r?.nip05&&(0,$.jsx)(ha,{nip05:r.nip05,pubkey:e,className:`text-xs text-muted-foreground truncate block`}),r?.about&&(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-1 mt-0.5`,children:r.about})]})]})})}function Sl({tab:e,active:t,onSelect:n,onRemove:r,onEdit:i}){let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=xo({id:e.label}),f=(0,Q.useRef)(null);return Ia(t,f),(0,$.jsxs)(`div`,{ref:e=>{c(e),f.current=e},style:{transform:l?vo.Transform.toString({...l,x:Math.round(l.x),y:Math.round(l.y)}):void 0,transition:u},className:V(`shrink-0 relative flex items-stretch group/chip px-1 text-sm font-medium select-none whitespace-nowrap`,t?`text-foreground`:`text-muted-foreground`,d&&`opacity-60 z-50`),...o,children:[(0,$.jsx)(`span`,{...s,className:`shrink-0 flex items-center cursor-grab active:cursor-grabbing touch-none pr-1`,"aria-label":`Drag to reorder`,children:(0,$.jsx)(p,{className:`size-4 text-muted-foreground/40`})}),(0,$.jsx)(`button`,{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),n()},className:`py-3.5 pr-1`,children:e.label}),t&&!e.isCore&&i&&(0,$.jsx)(`button`,{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),i()},className:`shrink-0 flex items-center justify-center py-3.5 px-1.5 text-muted-foreground/50 hover:text-primary transition-colors`,"aria-label":`Edit ${e.label}`,children:(0,$.jsx)(a,{className:`size-3.5`})}),t&&(0,$.jsx)(`button`,{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),r()},className:`shrink-0 flex items-center justify-center text-xl leading-none font-bold py-3.5 pl-1 pr-1 text-muted-foreground/50 hover:text-destructive transition-colors`,"aria-label":`Remove ${e.label}`,children:`×`})]})}function Cl({address:e}){let[t,n]=(0,Q.useState)(``),[r,i]=(0,Q.useState)(!1),{toast:a}=B();return(0,Q.useEffect)(()=>{_l.toDataURL(`bitcoin:${e}`,{width:280,margin:2,color:{dark:`#000000`,light:`#FFFFFF`}}).then(n).catch(console.error)},[e]),(0,$.jsx)(Or,{className:`sm:max-w-[360px] p-6 overflow-hidden rounded-2xl [&>button]:top-6 [&>button]:right-6`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(wr,{children:(0,$.jsxs)(Tr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`size-7 rounded-full bg-orange-500 flex items-center justify-center shrink-0`,children:(0,$.jsx)(ne,{className:`size-4 text-white`})}),(0,$.jsx)(`span`,{children:`Bitcoin`})]})}),(0,$.jsx)(`div`,{className:`flex justify-center my-5`,children:(0,$.jsx)(`div`,{className:`bg-white p-3 rounded-xl`,children:t?(0,$.jsx)(`img`,{src:t,alt:`Bitcoin QR`,className:`size-[220px]`,decoding:`async`}):(0,$.jsx)(`div`,{className:`size-[220px] bg-muted animate-pulse rounded`})})}),(0,$.jsxs)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(e),i(!0),a({title:`Copied`,description:`Bitcoin address copied to clipboard`}),setTimeout(()=>i(!1),2e3)},className:`flex items-center gap-2 w-full bg-secondary/60 hover:bg-secondary/80 transition-colors rounded-lg pl-3 pr-2.5 py-2.5 text-left cursor-pointer overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`min-w-0 font-mono text-xs truncate`,children:e}),(0,$.jsx)(`span`,{className:`shrink-0 ml-auto`,children:r?(0,$.jsx)(Oe,{className:`size-4 text-green-500`}):(0,$.jsx)(d,{className:`size-4 text-muted-foreground`})})]})]})})}var wl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Tl=RegExp(`^nostr:(note1|nevent1|naddr1|npub1|nprofile1)[023456789acdefghjklmnpqrstuvwxyz]+$`);function El(e){let t=e.trim();if(!Tl.test(t))return null;try{let e=t.slice(6),n=F.decode(e);switch(n.type){case`note`:return{type:`note`,eventId:n.data};case`nevent`:return{type:`nevent`,eventId:n.data.id,relays:n.data.relays,author:n.data.author};case`naddr`:return{type:`naddr`,addr:n.data};case`npub`:return{type:`profile`,pubkey:n.data};case`nprofile`:return{type:`profile`,pubkey:n.data.pubkey};default:return null}}catch{return null}}function Dl({field:e}){let[t,n]=(0,Q.useState)(!1),{toast:r}=B(),i=e.label===`$BTC`,a=Wt(e.value),o=!!a,s=async()=>{await navigator.clipboard.writeText(e.value),n(!0),r({title:`Copied`,description:`Bitcoin address copied to clipboard`}),setTimeout(()=>n(!1),2e3)};if(i)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`div`,{className:`size-5 rounded-full bg-orange-500 flex items-center justify-center shrink-0`,children:(0,$.jsx)(ne,{className:`size-3 text-white`})}),(0,$.jsx)(`span`,{className:`text-sm font-semibold shrink-0`,children:`Bitcoin`}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground font-mono truncate`,children:[e.value.slice(0,12),`…`,e.value.slice(-6)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:s,className:`p-1 rounded hover:bg-secondary transition-colors text-muted-foreground hover:text-primary`,title:`Copy address`,children:t?(0,$.jsx)(Oe,{className:`size-4 text-green-500`}):(0,$.jsx)(d,{className:`size-4`})}),(0,$.jsxs)(Ar,{children:[(0,$.jsx)(Dr,{asChild:!0,children:(0,$.jsx)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors text-muted-foreground hover:text-primary`,title:`Show QR code`,children:(0,$.jsx)(ee,{className:`size-4`})})}),(0,$.jsx)(Cl,{address:e.value})]}),(0,$.jsx)(`a`,{href:`https://mempool.space/address/${e.value}`,target:`_blank`,rel:`noopener noreferrer`,className:`p-1 rounded hover:bg-secondary transition-colors text-muted-foreground hover:text-primary`,title:`View on mempool.space`,children:(0,$.jsx)(oe,{className:`size-4`})})]})]});if(gs(e.label))return(0,$.jsx)(Ol,{value:e.value});let c=El(e.value);return c?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),c.type===`note`&&(0,$.jsx)(St,{eventId:c.eventId,className:`mt-1`}),c.type===`nevent`&&(0,$.jsx)(St,{eventId:c.eventId,relays:c.relays,authorHint:c.author,className:`mt-1`}),c.type===`naddr`&&(0,$.jsx)(Qe,{addr:c.addr,className:`mt-1`}),c.type===`profile`&&(0,$.jsxs)(q,{to:`/${F.npubEncode(c.pubkey)}`,className:`text-sm text-primary hover:underline`,children:[F.npubEncode(c.pubkey).slice(0,16),`...`]})]}):e.label.toLowerCase()===`email`&&wl.test(e.value)?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(xe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:e.label}),(0,$.jsx)(`a`,{href:`mailto:${e.value}`,className:`text-sm text-primary hover:underline truncate`,children:e.value})]}):o&&a&&ps(a)?(0,$.jsx)(_s,{src:a,label:e.label||void 0}):o&&a&&fs(a)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[e.label&&(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground mb-1`,children:e.label}),(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`block`,children:(0,$.jsx)(`img`,{src:a,alt:e.label||`Profile image`,className:`w-full max-w-sm rounded-lg object-cover`,loading:`lazy`,decoding:`async`})})]}):o&&a&&hs(a)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[e.label&&(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground mb-1`,children:e.label}),(0,$.jsx)(`div`,{className:`rounded-lg overflow-hidden max-w-sm`,children:(0,$.jsx)(tt,{src:a})})]}):o&&a?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(jn,{url:a,size:16,className:`shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:e.label}),(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-primary hover:underline truncate`,children:a.replace(/^https?:\/\//,``)})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:e.label}),(0,$.jsx)(`span`,{className:`text-sm truncate`,children:e.value})]})}function Ol({value:e}){return(0,$.jsx)(ms,{value:e,compact:!0})}function kl({isOwn:e,onUnpin:t}){return e?(0,$.jsxs)(`button`,{className:`group flex items-center gap-1.5 text-xs text-muted-foreground px-4 pt-3 pb-0 hover:text-destructive transition-colors`,onClick:e=>{e.stopPropagation(),t()},children:[(0,$.jsx)(w,{className:`size-3 rotate-45`}),(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:`Pinned`}),(0,$.jsx)(`span`,{className:`hidden group-hover:inline`,children:`Unpin?`})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground px-4 pt-3 pb-0`,children:[(0,$.jsx)(w,{className:`size-3 rotate-45`}),(0,$.jsx)(`span`,{children:`Pinned`})]})}function Al({imageUrl:e,onClose:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(0),c=(0,Q.useRef)(!1),l=`cubic-bezier(0.25, 0.46, 0.45, 0.94)`;(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,Q.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[]),et(t),(0,Q.useEffect)(()=>()=>{c.current=!1},[]);let u=(0,Q.useCallback)((e,t)=>{let n=i.current,r=a.current;if(!n||!r)return;let o=Math.min(Math.abs(e)/(window.innerHeight*.4),1);n.style.transition=t?`opacity ${t.split(` `).slice(1).join(` `)}`:`none`,n.style.opacity=String(1-o*.6),r.style.transition=t,r.style.transform=`translateY(${e}px)`},[]);return(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e=>{if(o.current===null||c.current||e.touches.length!==1)return;let t=e.touches[0].clientY-o.current;Math.abs(t)<4||(e.preventDefault(),s.current=t,u(t,`none`))};return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[u]),(0,Cs.createPortal)((0,$.jsxs)(`div`,{ref:i,className:`fixed inset-0 z-[100] flex items-center justify-center animate-in fade-in duration-200`,onClick:e=>{let n=e.target;n.tagName===`IMG`||n.closest(`button`)||n.closest(`[data-gallery-topbar]`)||(e.stopPropagation(),e.preventDefault(),t())},onTouchStart:e=>{c.current||e.touches.length>=2||(o.current=e.touches[0].clientY,u(0,`none`),s.current=0)},onTouchEnd:e=>{if(o.current===null||c.current){o.current=null;return}let n=e.changedTouches[0].clientY-o.current;if(o.current=null,Math.abs(n)>window.innerHeight*.15){c.current=!0;let e=n>0?window.innerHeight:-window.innerHeight;u(e,`transform 280ms ${l}`),setTimeout(()=>{s.current=0,t(),c.current=!1},280)}else u(0,`transform 280ms ${l}`),s.current=0},children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-md`}),(0,$.jsxs)(`div`,{ref:a,className:`absolute inset-0`,children:[(0,$.jsx)(`div`,{"data-gallery-topbar":!0,className:`absolute left-0 right-0 z-10 flex items-center justify-end px-4 py-3 safe-area-inset-top`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),t.preventDefault(),qt(e)},className:`p-2.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition-colors`,title:`Open original`,children:(0,$.jsx)(Te,{className:`size-5`})}),(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),e.preventDefault(),t()},className:`p-2.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition-colors`,title:`Close (Esc)`,children:(0,$.jsx)(me,{className:`size-5`})})]})}),(0,$.jsxs)(`div`,{className:`relative z-[1] flex items-center justify-center w-full h-full px-4 py-16 sm:px-16`,children:[!n&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsx)(`div`,{className:`size-8 border-2 border-white/20 border-t-white/80 rounded-full animate-spin`})}),(0,$.jsx)(`img`,{src:e,alt:``,className:V(`max-w-full max-h-full object-contain rounded-lg select-none transition-opacity duration-300`,n?`opacity-100`:`opacity-0`),onLoad:()=>r(!0),draggable:!1,decoding:`async`},e)]})]})]}),document.body)}var jl=[`Feed`,`Posts & replies`,`Media`,`Badges`,`Likes`,`Wall`],Ml=[`Feed`,`Posts & replies`,`Media`,`Likes`,`Wall`],Nl={Feed:`posts`,"Posts & replies":`replies`,Media:`media`,Badges:`badges`,Likes:`likes`,Wall:`wall`},Pl=Object.fromEntries(Object.entries(Nl).map(([e,t])=>[t,e])),Fl=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``);function Il(){let[e,t]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{t(!0)},[]),e?(0,$.jsx)(Ll,{}):(0,$.jsxs)(`main`,{className:`flex-1 min-w-0 relative`,children:[(0,$.jsx)(`div`,{className:`h-36 md:h-48 bg-secondary relative`,children:(0,$.jsx)(X,{className:`w-full h-full rounded-none`})}),(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`div`,{className:`relative -mt-12 mb-3`,children:(0,$.jsx)(X,{className:`size-24 rounded-full border-4 border-background`})}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{className:`h-6 w-40`}),(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-4 w-64`})]})]})]})}function Ll(){let{config:e}=Dt(),t=un(),n=t.npub??t.nip19,r=cn(),o=ln(),{nostr:s}=P(),{user:c}=$t(),{toast:p}=B(),{isMuted:m}=Mo(),h=Ye(),[g,_]=(0,Q.useState)(`posts`),[v,y]=(0,Q.useState)(null),[x,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,te]=(0,Q.useState)(!1),[ne,k]=(0,Q.useState)(!1),[re,A]=(0,Q.useState)(!1),[j,ae]=(0,Q.useState)(null),oe=(0,Q.useCallback)(()=>{window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||T(!0)},[]);(0,Q.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>T(!1),Xi);return()=>clearTimeout(e)},[w]);let se=(0,Q.useMemo)(()=>n?!!(n.includes(`@`)||n.includes(`.`)&&!n.startsWith(`npub1`)&&!n.startsWith(`nprofile1`)):!1,[n]),{data:le,isPending:ue}=Ge(se?n:void 0),M=(0,Q.useMemo)(()=>{if(n){if(se)return le??void 0;if(tn(n))return n;try{let e=F.decode(n);if(e.type===`npub`)return e.data;if(e.type===`nprofile`)return e.data.pubkey}catch{return}}return c?.pubkey},[n,c,se,le]),de=xs(M),fe=(0,Q.useMemo)(()=>de.isFetched?de.data??null:null,[de.data,de.isFetched]),he=(0,Q.useMemo)(()=>fe?.tabs??[],[fe]),ge=(0,Q.useMemo)(()=>fe?.vars??[],[fe]),{publishProfileTabs:ve,isPending:ye}=Ss(),[be,xe]=(0,Q.useState)(!1);function Se({tags:e}){let[t,n]=(0,Q.useState)(!1),r=t?e:e.slice(0,3),i=e.length-r.length;return(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5 mt-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(ie,{className:`size-3.5 shrink-0 mt-0.5 text-primary`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`min-w-0 break-words`,children:[`You both like`,` `,r.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(t===r.length-1&&i===0?` and `:`, `),(0,$.jsx)(q,{to:`/t/${encodeURIComponent(e)}`,className:`font-medium text-foreground hover:text-primary hover:underline`,children:e})]},e)),i>0&&(0,$.jsxs)($.Fragment,{children:[` `,`and`,` `,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`font-medium underline decoration-dotted underline-offset-2 hover:text-foreground transition-colors`,children:[i,` more`]})]})]})]})}function Ce({pubkey:e,open:t,onOpenChange:n,displayName:r}){let i=(0,Q.useCallback)(()=>n(!1),[n]),{nostr:a}=P(),{data:o,fetchNextPage:s,hasNextPage:c,isFetchingNextPage:l,isLoading:u}=Ze({queryKey:[`followers-list`,e],queryFn:async({pageParam:t,signal:n})=>{let r=AbortSignal.any([n,AbortSignal.timeout(8e3)]),i={kinds:[3],"#p":[e],limit:20,...t?{until:t}:{}},o=await a.query([i],{signal:r}),s=new Set,c=[],l=[...o].sort((e,t)=>t.created_at-e.created_at);for(let e of l)s.has(e.pubkey)||(s.add(e.pubkey),c.push(e));let u=l.length>0?l[l.length-1].created_at:void 0;return{pubkeys:c.map(e=>e.pubkey),oldestTimestamp:u}},getNextPageParam:e=>{if(!(e.pubkeys.length===0||e.oldestTimestamp===void 0))return e.oldestTimestamp-1},initialPageParam:void 0,enabled:t&&!!e,staleTime:60*1e3}),d=(0,Q.useMemo)(()=>{if(!o)return[];let e=new Set,t=[];for(let n of o.pages)for(let r of n.pubkeys)e.has(r)||(e.add(r),t.push(r));return t},[o]),{ref:f,inView:p}=Di({threshold:0});return(0,Q.useEffect)(()=>{p&&c&&!l&&s()},[p,c,l,s]),(0,$.jsx)(Ar,{open:t,onOpenChange:n,children:(0,$.jsxs)(Or,{className:`max-w-md p-0 gap-0 rounded-2xl overflow-hidden [&>button]:hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[(0,$.jsxs)(Tr,{className:`text-base font-bold`,children:[r,`'s followers`]}),(0,$.jsx)(H,{variant:`ghost`,size:`icon`,className:`rounded-full size-8`,onClick:()=>n(!1),children:(0,$.jsx)(me,{className:`size-4`})})]}),(0,$.jsx)(to,{className:`max-h-[60vh]`,children:u?(0,$.jsx)(`div`,{className:`py-12 flex justify-center`,children:(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})}):d.length===0?(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:`No followers found.`}):(0,$.jsxs)($.Fragment,{children:[d.map(e=>(0,$.jsx)(xl,{pubkey:e,onNavigate:i},e)),c&&(0,$.jsx)(`div`,{ref:f,className:`py-4 flex justify-center`,children:l&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]})})]})})}let[we,Te]=(0,Q.useState)([]),[Ee,De]=(0,Q.useState)(!1),[ke,Ae]=(0,Q.useState)(void 0),je=(0,Q.useMemo)(()=>fe===null?Ml.map(e=>({label:e,isCore:!0})):fe.tabs.map(e=>jl.includes(e.label)?{label:e.label,isCore:!0}:{label:e.label,isCore:!1,tab:e}),[fe]),Ne=(0,Q.useMemo)(()=>{if(je.length===0)return`posts`;let e=je[0];return Nl[e.label]??e.label},[je]),Pe=(0,Q.useMemo)(()=>{let e=o.hash.replace(/^#/,``);if(!e)return null;try{e=decodeURIComponent(e)}catch{}return Fl(e)||null},[o.hash]);(0,Q.useEffect)(()=>{if(!de.isFetched)return;let e=Pe?je.find(e=>Fl(e.label)===Pe):void 0,t=e?Nl[e.label]??e.label:Ne;_(e=>e===t?e:t)},[de.isFetched,Pe,je,Ne]);let Fe=(0,Q.useCallback)(e=>{_(e);let t=Pl[e]??e,n=e===Ne?``:Fl(t),i=window.location.hash.replace(/^#/,``);try{i=decodeURIComponent(i)}catch{}Fl(i)!==n&&r({hash:n?`#${n}`:``},{replace:!0,preventScrollReset:!0})},[Ne,r]),Ie=()=>{Te(je),xe(!0)},ze=e=>{let{active:t,over:n}=e;n&&t.id!==n.id&&Te(e=>No(e,e.findIndex(e=>e.label===t.id),e.findIndex(e=>e.label===n.id)))},Be=e=>{Te(t=>t.filter(t=>t.label!==e))},He=M?{Feed:{kinds:[1,6],authors:[M]},"Posts & replies":{authors:[M]},Media:{kinds:[1],authors:[M]},Badges:{kinds:[10008,30008],authors:[M]},Likes:{kinds:[7],authors:[M]},Wall:{kinds:[1111],"#A":[`0:${M}:`]}}:{},Ue=async()=>{let e=we.map(e=>e.tab??{label:e.label,filter:He[e.label]??{}});await ve({tabs:e,vars:ge});let t=we.map(e=>Nl[e.label]??e.label);t.includes(g)||Fe(t[0]??`posts`),xe(!1)},We=()=>{Ae(void 0),De(!0)},Ke=async e=>{if(be)Te(t=>ke?t.map(t=>t.label===ke.label?{label:e.label,isCore:!1,tab:e}:t):[...t,{label:e.label,isCore:!1,tab:e}]);else{let t=ke?he.map(t=>t.label===ke.label?e:t):[...he,e];await ve({tabs:t,vars:ge})}},qe=bo(mo(go),mo(ho,{coordinateGetter:void 0}));(0,Q.useEffect)(()=>{![`posts`,`replies`,`media`,`badges`,`likes`,`wall`].includes(g)&&!he.find(e=>e.label===g)&&Fe(Ne)},[he,Ne]);let Je=je.length>0,{data:Xe,isPending:Qe,fetchNextPage:$e,hasNextPage:et,isFetchingNextPage:tt}=To(M,[`posts`,`replies`,`media`,`likes`,`wall`,`badges`].includes(g)?g:`posts`,Je),nt=Yt(M),L=nt.data?.metadata,rt=W(L),it=!!rt&&on(rt),at=Mn(M);(0,Q.useEffect)(()=>{M&&h.refetchQueries({queryKey:[`author`,M]})},[M,h]);let ot=nt.data?.event,R=L?.name||L?.display_name||`Anonymous`,st=(0,Q.useMemo)(()=>za(ot?.content),[ot?.content]),ct=Ra(st),lt=ct?sr(M):void 0;(0,Q.useEffect)(()=>{if(!(!ct||E))return hl(),()=>gl()},[ct,E,M]),(0,Q.useEffect)(()=>{ct&&Bt(`Pacifico`)},[ct]);let{data:ut}=ks(M),dt=(0,Q.useMemo)(()=>ot?.content?vl(ot.content):[],[ot?.content]);jo({title:`${R} | ${e.appName}`,description:L?.about||`Nostr profile`});let{data:ft,isPending:pt,fetchNextPage:mt,hasNextPage:ht,isFetchingNextPage:gt}=Ds(M,Je&&g===`media`),{data:_t,isPending:vt,fetchNextPage:yt,hasNextPage:bt,isFetchingNextPage:xt}=So(M,Je&&g===`likes`),St=(0,Q.useMemo)(()=>ut?.following,[ut?.following]),{data:Ct,isPending:wt,fetchNextPage:Tt,hasNextPage:jt,isFetchingNextPage:Ft}=js(M,Je&&g===`wall`?St:void 0),Gt=(0,Q.useMemo)(()=>{if(M)return ot||{id:``,kind:0,pubkey:M,content:``,created_at:0,sig:``,tags:[]}},[M,ot]),[Kt,qt]=(0,Q.useState)(!1),[Jt,Xt]=(0,Q.useState)(0),{data:Zt}=nn(),{follow:Qt,unfollow:en,isPending:an}=rn(),dn=(0,Q.useMemo)(()=>{let e=ut?.following??[];return{pubkeys:e,count:e.length}},[ut?.following]),fn=ut?.loved.length??0,{data:mn}=co(M),gn=mn?.followers??0,J=c?.pubkey===M,_n=!J&&!!c&&(ut?.loved.includes(c.pubkey)??!1),{hashtags:vn}=Co(),yn=(0,Q.useMemo)(()=>{if(J||!c||vn.length===0)return[];let e=new Set(vn.map(e=>pn(e)).filter(Boolean));return(ut?.interests??[]).filter(t=>e.has(t)).sort()},[J,c,vn,ut?.interests]),bn=(0,Q.useMemo)(()=>!c?.pubkey||!St?!1:J?!0:St.includes(c.pubkey),[c?.pubkey,St,J]),{togglePin:xn}=Ma(J?M:void 0),{feedSettings:Sn}=Fa(),Cn=Sn.showCustomProfileThemes!==!1,En=Ms(M),Y=En.data,kn=!!Y?.colors,jn=Cn||J?Y?.colors:void 0,[Nn,Pn]=Et(rr(e.appId,`seen-profile-theme-info`),!1),[In,Ln]=(0,Q.useState)(!1),{updateFeedSettings:Rn}=Fa(),{updateSettings:zn}=zt(),{setActiveTheme:Bn,clearActiveTheme:Vn,isPending:Hn}=At(),[Un,Wn]=(0,Q.useState)(!1),[Xn,Qn]=(0,Q.useState)(!1),[$n,er]=(0,Q.useState)(!1),[tr,nr]=(0,Q.useState)(void 0),ir=(0,Q.useCallback)(e=>{nr(e??void 0)},[]),[ar,or]=(0,Q.useState)({background:`228 20% 10%`,text:`210 40% 98%`,primary:`258 70% 60%`}),[cr,lr]=(0,Q.useState)(),[ur,dr]=(0,Q.useState)(),[fr,pr]=(0,Q.useState)();(0,Q.useEffect)(()=>{$n&&Y&&(or(Y.colors),lr(Y.font),dr(Y.titleFont),pr(Y.background))},[$n,Y]);let[hr,yr]=Et(rr(e.appId,`dismissed-share-theme-snapshot`),null),{theme:br,customTheme:Z,themes:xr,applyCustomTheme:Sr}=Lt(),Cr=(0,Q.useRef)({ownTheme:br,ownCustomTheme:Z,configuredThemes:xr});Cr.current={ownTheme:br,ownCustomTheme:Z,configuredThemes:xr};let Dr=Cn||J?Y?.font:void 0,jr=Cn||J?Y?.titleFont:void 0,Mr=Cn||J?Y?.background:void 0,Fr=En.isFetched&&!jn&&br===`custom`,Ir=e=>`${z(e.primary)}${z(e.text)}${z(e.background)}`,zr=e=>e?.family??``,Br=Z?Ir(Z.colors)+zr(Z.font)+zr(Z.titleFont)+JSON.stringify(Z.background??``):null,Vr=kn&&Br&&Y&&Z?Ir(Y.colors)!==Ir(Z.colors)||zr(Y.font)!==zr(Z.font)||zr(Y.titleFont)!==zr(Z.titleFont)||JSON.stringify(Y.background??``)!==JSON.stringify(Z.background??``):!1,Hr=J&&br===`custom`&&Z&&(!kn||Vr)&&!(hr!==null&&hr===Br),Ur=J&&kn&&!Hr,Wr=jn??(Fr?Nt(Pt(`system`),xr).colors:void 0),Gr=(0,Q.useMemo)(()=>jn?Dr??{family:`Inter`}:void 0,[jn,Dr]),Kr=(0,Q.useMemo)(()=>jn?jr??Gr:void 0,[jn,jr,Gr]),qr=jn?Mr:void 0;(0,Q.useLayoutEffect)(()=>{if(!Wr)return;let e=Mt(Wr),t=document.getElementById(`theme-vars`);t||(t=document.createElement(`style`),t.id=`theme-vars`,document.head.appendChild(t)),t.textContent,t.textContent=e,Ut(Gr),Ht(Kr);let n=`theme-background`,r=document.getElementById(n);if(qr?.url){let e=r;e||(e=document.createElement(`style`),e.id=n,document.head.appendChild(e)),(qr.mode??`cover`)===`tile`?e.textContent=`body { background-image: url("${qr.url}"); background-repeat: repeat; background-size: auto; }`:e.textContent=`body { background-image: url("${qr.url}"); background-size: cover; background-repeat: no-repeat; background-position: center; background-attachment: fixed; }`}else r?.remove();return()=>{let{ownTheme:e,ownCustomTheme:t,configuredThemes:r}=Cr.current,i=document.getElementById(`theme-vars`);if(i){let n=Pt(e);i.textContent=Rt(It(n===`custom`?t?.colors??Nt(`dark`,r).colors:Nt(n,r).colors))}let a=Pt(e),o=a===`custom`?t:Nt(a,r);Ut(o?.font),Ht(o?.titleFont);let s=document.getElementById(n),c=o?.background?.url;if(c){let e=s??(()=>{let e=document.createElement(`style`);return e.id=n,document.head.appendChild(e),e})();(o?.background?.mode??`cover`)===`tile`?e.textContent=`body { background-image: url("${c}"); background-repeat: repeat; background-size: auto; }`:e.textContent=`body { background-image: url("${c}"); background-size: cover; background-repeat: no-repeat; background-position: center; background-attachment: fixed; }`}else s?.remove()}},[Wr,Gr,Kr,qr]);let Jr=(0,Q.useMemo)(()=>ut?.pinnedIds??[],[ut?.pinnedIds]),{data:Yr=[],isLoading:Xr}=I({queryKey:[`profile-pinned-events`,M,Jr],queryFn:async({signal:e})=>(await s.query([{ids:Jr,limit:Jr.length}],{signal:AbortSignal.any([e,AbortSignal.timeout(5e3)])})).sort((e,t)=>Jr.indexOf(e.id)-Jr.indexOf(t.id)),enabled:Jr.length>0,staleTime:300*1e3}),Zr=(0,Q.useMemo)(()=>!M||!Zt?.pubkeys?!1:Zt.pubkeys.includes(M),[M,Zt]),Qr=async()=>{if(!(!c||!M))try{Zr?await en(M):await Qt(M),Fn(),p({title:Zr?`Unfollowed @${R}`:`Followed @${R}`})}catch(e){console.error(`Follow toggle failed:`,e),p({title:`Failed to update follow list`,variant:`destructive`})}},$r=(0,Q.useMemo)(()=>{if(!Xe?.pages)return[];let e=new Set,t=[];for(let n of Xe.pages)for(let r of n.items){let n=r.repostedBy?`repost-${r.repostedBy}-${r.event.id}`:r.event.id;if(!e.has(n)){if(e.add(n),m(r.event))continue;t.push(r)}}return t},[Xe?.pages,m]),ei=(0,Q.useMemo)(()=>{if(!ft?.pages)return[];let e=new Set,t=[];for(let n of ft.pages)for(let r of n.events)e.has(r.id)||(e.add(r.id),t.push(r));return t},[ft?.pages]),{refs:ti}=Tn(M),ni=(0,Q.useMemo)(()=>ti.slice(0,5),[ti]),{badgeMap:ri,isLoading:ii}=wn(ni),ai=(0,Q.useMemo)(()=>{if(!_t?.pages)return[];let e=new Set,t=[];for(let n of _t.pages)for(let r of n.events)e.has(r.id)||(e.add(r.id),t.push(r));return t},[_t?.pages]),oi=(0,Q.useMemo)(()=>{if(!Ct?.pages)return[];let e=new Set,t=[];for(let n of Ct.pages)for(let r of n.comments)if(!e.has(r.id)){if(e.add(r.id),m(r))continue;t.push(r)}return t},[Ct?.pages,m]),si=(0,Q.useMemo)(()=>{let e=M?`0:${M}:`:``,t=[],n=new Map;for(let r of oi)if(r.tags.some(([t,n])=>t===`a`&&n===e))t.push(r);else{let e=r.tags.find(([e])=>e===`e`)?.[1];if(e){let t=n.get(e)??[];t.push(r),n.set(e,t)}}return t.map(e=>({reply:e,firstSubReply:n.get(e.id)?.[0]}))},[oi,M]),{ref:ci,inView:li}=Di({threshold:0});(0,Q.useEffect)(()=>{li&&(g===`likes`?bt&&!xt&&yt():g===`media`?ht&&!gt&&mt():g===`wall`?jt&&!Ft&&Tt():et&&!tt&&$e())},[li,g,et,tt,$e,bt,xt,yt,ht,gt,mt,jt,Ft,Tt]);let ui=ot,di=(0,Q.useMemo)(()=>ai.map(e=>({event:e,sortTimestamp:e.created_at})),[ai]),fi=(0,Q.useMemo)(()=>ei.map(e=>({event:e,sortTimestamp:e.created_at})),[ei]),pi=g===`posts`||g===`replies`||g===`media`||g===`likes`||g===`wall`||g===`badges`,mi=g===`wall`?[]:g===`likes`?di:g===`media`?fi:Eo($r,pi?g:`posts`),hi=g===`wall`?wt:g===`likes`?vt:g===`media`?pt:Qe,gi=g===`wall`?jt:g===`likes`?bt:g===`media`?ht:et,_i=g===`wall`?Ft:g===`likes`?xt:g===`media`?gt:tt;(0,Q.useEffect)(()=>{hi||_i||g===`wall`||g===`likes`||g===`media`||mi.length<5&&et&&!tt&&$e()},[mi.length,hi,_i,g,et,tt,$e]);let vi=(0,Q.useCallback)(async()=>{M&&await h.invalidateQueries({predicate:e=>{let t=e.queryKey;if(!Array.isArray(t))return!1;let n=t[0];return n===`author`&&t[1]===M||n===`profile-supplementary`&&t[1]===M||n===`profile-feed`&&t[1]===M||n===`profile-media`&&t[1]===M||n===`profile-likes-infinite`&&t[1]===M||n===`profile-pinned-events`&&t[1]===M||n===`wall-comments`&&t[1]===M}})},[h,M]),yi=(0,Q.useCallback)(()=>qt(!0),[]),bi=(0,Q.useCallback)(e=>{Fe(`media`),y(e)},[Fe]);return Ei(M?{rightSidebar:(0,$.jsx)(vs,{fields:dt,pubkey:M,onMediaClick:bi}),showFAB:!(g===`wall`&&!bn),onFabClick:g===`wall`?yi:void 0,hasSubHeader:!0}:{}),M?(0,$.jsxs)(`main`,{className:`flex-1 min-w-0 relative`,children:[w&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-[40vh] z-20 overflow-hidden`,children:(0,$.jsx)(Fi,{variant:`hearts`})}),ct&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 overflow-hidden`,children:(0,$.jsx)(Rr,{})}),(0,$.jsxs)(fo,{onRefresh:vi,children:[(0,$.jsxs)(`div`,{className:`h-36 md:h-48 bg-secondary relative`,children:[nt.isLoading?(0,$.jsx)(X,{className:`w-full h-full rounded-none`}):(0,$.jsx)(An,{src:L?.banner,className:`w-full h-full object-cover cursor-pointer`,onClick:()=>ae(L.banner),decoding:`async`,fallback:(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-accent/10 via-transparent to-primary/5`})}),kn&&!J&&(0,$.jsxs)(Yn,{children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsxs)(`button`,{className:V(`absolute top-3 right-3 z-10 size-9 rounded-full backdrop-blur-sm border flex items-center justify-center transition-colors`,Cn?`bg-background/60 border-border/50 hover:bg-background/80`:`bg-background/40 border-border/30 hover:bg-background/60`),children:[(0,$.jsx)(`span`,{className:V(`absolute inset-0 rounded-full animate-ping-3`,Cn?`bg-accent/30`:`bg-primary/30`)}),(0,$.jsx)(S,{className:V(`size-4 relative`,Cn?`text-accent`:`text-muted-foreground`)}),!Nn&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-3 rounded-full bg-red-500 border-2 border-background`})]})}),(0,$.jsxs)(qn,{align:`end`,side:`bottom`,className:`w-48`,children:[(0,$.jsxs)(Jn,{onClick:async()=>{if(!Nn)Ln(!0),Pn(!0);else{let e=!Cn;if(Rn({showCustomProfileThemes:e}),c){let t={...Sn,showCustomProfileThemes:e};await zn.mutateAsync({feedSettings:t})}}},className:`cursor-pointer`,children:[Cn?(0,$.jsx)(Ve,{className:`size-4 mr-2`}):(0,$.jsx)(_e,{className:`size-4 mr-2`}),Cn?`Hide Theme`:`Show Theme`]}),(0,$.jsxs)(Jn,{onClick:()=>{if(!Y)return;let e={colors:Y.colors,font:Y.font,background:Y.background};Sr(e),p({title:`Theme applied`,description:`This profile's theme is now your app theme.`})},className:`cursor-pointer`,children:[(0,$.jsx)(d,{className:`size-4 mr-2`}),`Copy Theme`]})]})]}),Hr&&Z&&!Vr&&(0,$.jsxs)(vr,{children:[(0,$.jsx)(gr,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`absolute top-3 right-3 z-10 size-9 rounded-full border flex items-center justify-center transition-all hover:scale-110`,style:{backgroundColor:z(Z.colors.primary),borderColor:z(Z.colors.primary)},onClick:()=>Wn(!0),children:[(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full animate-pulse-slow`,style:{backgroundColor:z(Z.colors.primary)}}),(0,$.jsx)(S,{className:`size-4 relative`,style:{color:z(Z.colors.background)}})]})}),(0,$.jsx)(_r,{side:`left`,children:`Apply your theme to your profile`})]}),Hr&&Z&&Vr&&(0,$.jsxs)(Yn,{children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`absolute top-3 right-3 z-10 size-9 rounded-full border flex items-center justify-center transition-all hover:scale-110`,style:{backgroundColor:z(Z.colors.primary),borderColor:z(Z.colors.primary)},children:[(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full animate-pulse-slow`,style:{backgroundColor:z(Z.colors.primary)}}),(0,$.jsx)(S,{className:`size-4 relative`,style:{color:z(Z.colors.background)}})]})}),(0,$.jsxs)(qn,{align:`end`,side:`bottom`,className:`w-52`,children:[(0,$.jsxs)(Jn,{onClick:()=>Wn(!0),className:`cursor-pointer`,children:[(0,$.jsx)(i,{className:`size-4 mr-2`}),`Update Profile Theme`]}),(0,$.jsxs)(Jn,{onClick:()=>er(!0),className:`cursor-pointer`,children:[(0,$.jsx)(a,{className:`size-4 mr-2`}),`Edit Profile Theme`]}),(0,$.jsxs)(Jn,{onClick:()=>Qn(!0),className:`cursor-pointer text-destructive focus:text-destructive`,children:[(0,$.jsx)(l,{className:`size-4 mr-2`}),`Delete Profile Theme`]})]})]}),Ur&&(0,$.jsxs)(Yn,{children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsx)(`button`,{className:`absolute top-3 right-3 z-10 size-9 rounded-full backdrop-blur-sm border bg-background/60 border-border/50 hover:bg-background/80 flex items-center justify-center transition-colors`,children:(0,$.jsx)(S,{className:`size-4 text-accent`})})}),(0,$.jsxs)(qn,{align:`end`,side:`bottom`,className:`w-52`,children:[(0,$.jsxs)(Jn,{onClick:()=>er(!0),className:`cursor-pointer`,children:[(0,$.jsx)(a,{className:`size-4 mr-2`}),`Edit Profile Theme`]}),(0,$.jsxs)(Jn,{onClick:()=>Qn(!0),className:`cursor-pointer text-destructive focus:text-destructive`,children:[(0,$.jsx)(l,{className:`size-4 mr-2`}),`Delete Profile Theme`]})]})]}),!J&<&&(0,$.jsxs)(H,{variant:`outline`,className:`absolute bottom-3 right-3 z-10 max-w-[calc(100%-1.5rem)] rounded-full font-bold backdrop-blur-sm border-amber-400/60 bg-background/70 text-amber-700 hover:bg-background/85 hover:text-amber-800 dark:text-amber-400 dark:hover:text-amber-300`,onClick:()=>te(!0),disabled:!c,title:c?void 0:`Log in to wish a happy birthday`,"aria-label":`Wish ${R} a Happy Birthday!`,children:[(0,$.jsx)(Re,{className:`size-4 mr-2 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Wish `,R,` a Happy Birthday!`]})]})]}),(0,$.jsx)(`div`,{className:`px-4 pb-4`,children:nt.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex justify-between items-start -mt-12 md:-mt-16 mb-3`,children:(0,$.jsx)(X,{className:`size-24 md:size-32 rounded-full border-4 border-background`})}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{className:`h-6 w-40`}),(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-4 w-full mt-2`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-start -mt-12 md:-mt-16 mb-3`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{className:`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-full`,onClick:()=>L?.picture&&ae(L.picture),disabled:!L?.picture,children:(0,$.jsx)(`div`,{style:it?sn:void 0,children:(0,$.jsxs)(K,{shape:rt,className:V(it?`size-[88px] md:size-[120px]`:`size-24 md:size-32 border-4 border-background`,L?.picture&&`cursor-pointer`),children:[(0,$.jsx)(G,{src:L?.picture,alt:R}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-2xl md:text-3xl`,children:R[0].toUpperCase()})]})})}),ct&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute -top-5 right-0 md:-top-7 md:right-1 z-10 rotate-[18deg]`,children:(0,$.jsx)(Pr,{className:`size-12 md:size-16 drop-shadow-md`})}),Sn.showUserStatuses!==!1&&at.status&&(0,$.jsx)(`div`,{className:`absolute top-3 md:top-4 left-[calc(100%+8px)] z-10 w-max max-w-[280px] md:max-w-[360px] animate-in fade-in slide-in-from-left-1 duration-300`,children:(0,$.jsxs)(`div`,{className:`relative bg-background/90 backdrop-blur-sm border border-border rounded-xl px-3 py-1.5 shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-xs md:text-sm text-foreground italic truncate`,children:at.url?(0,$.jsx)(`a`,{href:at.url,target:`_blank`,rel:`noopener noreferrer`,className:`hover:underline`,children:(0,$.jsx)(hn,{tags:at.tags,children:at.status})}):(0,$.jsx)(hn,{tags:at.tags,children:at.status})}),(0,$.jsx)(`div`,{className:`absolute -bottom-[7px] left-1 size-0 border-t-[8px] border-t-border border-r-[8px] border-r-transparent`}),(0,$.jsx)(`div`,{className:`absolute -bottom-[5.5px] left-1 size-0 border-t-[7px] border-t-background border-r-[7px] border-r-transparent`})]})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-14 md:mt-20`,children:[(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`rounded-full size-10`,onClick:()=>C(!0),title:`More options`,children:(0,$.jsx)(ce,{className:`size-5`})}),(0,$.jsx)(Ts,{pubkey:M,displayName:R}),J&&(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`rounded-full size-10`,title:`Share follow link`,onClick:()=>k(!0),children:(0,$.jsx)(ee,{className:`size-5`})}),!J&&(0,$.jsx)(ws,{pubkey:M,displayName:R,isFollowing:Zr,onLoved:oe}),J?(0,$.jsx)(q,{to:`/settings/profile`,children:(0,$.jsx)(H,{variant:`outline`,className:`rounded-full font-bold`,children:`Edit profile`})}):(0,$.jsx)(H,{className:V(`rounded-full font-bold`,Zr&&`bg-transparent border border-border text-foreground hover:bg-destructive/10 hover:text-destructive hover:border-destructive/50`),variant:Zr?`outline`:`default`,onClick:Qr,disabled:an||!c,children:an?`...`:Zr?`Unfollow`:`Follow`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-xl font-bold truncate`,style:Kr?{fontFamily:`var(--title-font-family)`}:void 0,children:ot?(0,$.jsx)(hn,{tags:ot.tags,children:R}):R}),_n?(0,$.jsxs)(`span`,{className:`shrink-0 inline-flex items-center gap-1 rounded-full bg-pink-500/10 px-2 py-0.5 text-xs font-medium text-pink-600 dark:text-pink-400`,children:[(0,$.jsx)(u,{className:`size-3 fill-current`,"aria-hidden":`true`}),`Loves you`]}):!J&&bn?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:`Follows you`}):null]}),L?.nip05&&(0,$.jsx)(Sa,{nip05:L.nip05,pubkey:M??``,className:`text-sm text-muted-foreground`}),L?.website&&Wt(L.website.startsWith(`http`)?L.website:`https://${L.website}`)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground mt-0.5`,children:[(0,$.jsx)(b,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,$.jsx)(`a`,{href:Wt(L.website.startsWith(`http`)?L.website:`https://${L.website}`),target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-primary hover:underline`,children:L.website.replace(/^https?:\/\//,``).replace(/\/$/,``)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 mt-2`,children:[gn>0&&(0,$.jsxs)(`button`,{className:`flex items-center gap-1 hover:opacity-80 transition-opacity`,onClick:()=>A(!0),title:`${gn} followers`,children:[(0,$.jsx)(`span`,{className:`text-sm font-bold tabular-nums text-primary`,children:Si(gn)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`followers`})]}),dn&&dn.count>0&&M&&(0,$.jsxs)(q,{to:`/${F.naddrEncode({kind:3,pubkey:M,identifier:``})}`,className:`flex items-center gap-1 hover:opacity-80 transition-opacity`,title:`${dn.count} following`,children:[(0,$.jsx)(`span`,{className:`text-sm font-bold tabular-nums text-primary`,children:Si(dn.count)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`following`})]}),fn>0&&M&&(0,$.jsxs)(q,{to:`/${F.naddrEncode({kind:15683,pubkey:M,identifier:``})}`,className:`flex items-center gap-1 hover:opacity-80 transition-opacity`,title:`${fn} loved`,children:[(0,$.jsx)(`span`,{className:`text-sm font-bold tabular-nums text-primary`,children:Si(fn)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`loved`})]})]}),L?.about&&(0,$.jsx)(`p`,{className:`mt-3 text-sm whitespace-pre-wrap break-words overflow-hidden`,children:(0,$.jsx)(Dn,{tags:ot?.tags,children:L.about})}),yn.length>0&&(0,$.jsx)(Se,{tags:yn}),ti.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-2`,children:[ni.map(e=>{if(ii)return(0,$.jsx)(X,{className:`size-8 rounded-lg`},e.aTag);let t=ri.get(e.aTag);return t?(0,$.jsx)(q,{to:`/${F.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`,children:(0,$.jsx)(On,{badge:t,size:32})},e.aTag):null}),ti.length>5&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-medium`,children:[`+`,ti.length-5]})]}),dt.length>0&&(0,$.jsx)(`div`,{className:`mt-4 space-y-3 lg:hidden`,children:dt.map((e,t)=>(0,$.jsx)(Dl,{field:e},t))})]})}),ct&&st?.month!==void 0&&st?.day!==void 0&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-4 pb-6 pt-2 text-center`,title:J?`Happy birthday!`:`It's ${R}'s birthday today!`,children:[(0,$.jsx)(`span`,{className:`text-2xl leading-relaxed text-amber-700 dark:text-amber-400`,style:{fontFamily:`'Pacifico', cursive`},children:`Birthday today`}),(0,$.jsx)(`span`,{className:`my-3 h-px w-12 bg-border`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.3em] text-muted-foreground`,children:new Date(2e3,st.month-1,1).toLocaleDateString(void 0,{month:`long`})}),(0,$.jsx)(`span`,{className:`mt-1 text-5xl font-extrabold leading-none tabular-nums`,children:st.day}),(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`mt-3 size-8 rounded-full text-muted-foreground hover:text-foreground`,onClick:()=>D(e=>!e),"aria-label":E?`Play birthday music`:`Mute birthday music`,title:E?`Play birthday music`:`Mute birthday music`,children:E?(0,$.jsx)(pe,{className:`size-4`}):(0,$.jsx)(Le,{className:`size-4`})})]}),(0,$.jsxs)(La,{pinned:!0,children:[!de.isFetched&&(0,$.jsx)(`div`,{className:`flex gap-1 px-2 py-2`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(X,{className:`h-8 w-16 rounded`},t))}),!be&&de.isFetched&&je.map(e=>{let t=Nl[e.label]??e.label;return(0,$.jsx)(Oo,{label:e.label,active:g===t,onClick:()=>{Fe(t),e.label===`Media`&&y(null)},className:`flex-initial shrink-0 px-4`},e.label)}),be&&(0,$.jsx)(po,{sensors:qe,collisionDetection:`closestCenter`,onDragEnd:ze,children:(0,$.jsx)(yo,{items:we.map(e=>e.label),strategy:`horizontal`,children:we.length===0?(0,$.jsx)(`span`,{className:`px-4 text-sm text-muted-foreground italic`,children:`No custom tabs — use + to add one`}):we.map(e=>{let t=Nl[e.label]??e.label;return(0,$.jsx)(Sl,{tab:e,active:g===t,onSelect:()=>Fe(t),onRemove:()=>Be(e.label),onEdit:!e.isCore&&e.tab?()=>{Ae(e.tab),De(!0)}:void 0},e.label)})})}),!J&&!be&&de.isFetched&&de.data!==null&&(()=>{let e=jl.filter(e=>!je.some(t=>t.label===e));return e.length===0?null:(0,$.jsx)(`div`,{className:`flex items-center shrink-0 ml-auto`,children:(0,$.jsxs)(Yn,{children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsx)(`button`,{className:`px-2.5 py-3.5 text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,"aria-label":`More tabs`,children:(0,$.jsx)(ce,{className:`size-4`})})}),(0,$.jsx)(qn,{align:`end`,className:`w-48`,children:e.map(e=>{let t=Nl[e]??e;return(0,$.jsx)(Jn,{onClick:()=>Fe(t),children:e},e)})})]})})})(),J&&(0,$.jsxs)(`div`,{className:`flex items-center shrink-0 ml-auto`,children:[be&&(0,$.jsxs)(Yn,{modal:!1,children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsx)(`button`,{className:`px-2.5 py-3.5 text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,"aria-label":`Add tab`,children:(0,$.jsx)(f,{className:`size-4`,strokeWidth:4})})}),(0,$.jsxs)(qn,{align:`end`,className:`w-48`,children:[jl.map(e=>{let t=we.some(t=>t.label===e);return(0,$.jsxs)(Jn,{disabled:t,className:t?`text-muted-foreground`:void 0,onClick:t?void 0:()=>Te(t=>[...t,{label:e,isCore:!0}]),children:[t?(0,$.jsx)(Oe,{className:`size-3.5 mr-2 opacity-60`,strokeWidth:4}):(0,$.jsx)(f,{className:`size-3.5 mr-2`,strokeWidth:4}),e]},e)}),(0,$.jsx)(Kn,{}),(0,$.jsxs)(Jn,{onClick:We,children:[(0,$.jsx)(f,{className:`size-3.5 mr-2`,strokeWidth:4}),`Add custom tab`]})]})]}),(0,$.jsx)(`button`,{onClick:be?Ue:Ie,disabled:be&&ye,className:`px-2.5 py-3.5 text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors disabled:opacity-50`,"aria-label":be?`Save tab order`:`Edit tabs`,children:ye?(0,$.jsx)(N,{className:`size-4 animate-spin`}):be?(0,$.jsx)(Oe,{className:`size-4 text-primary`,strokeWidth:4}):(0,$.jsx)(a,{className:`size-3.5`})})]})]}),(0,$.jsx)(`div`,{style:{height:20}}),M&&Ee&&(0,$.jsx)(Oc,{open:Ee,onOpenChange:De,tab:ke,ownerPubkey:M,onSave:Ke,isPending:!1}),!Je&&(0,$.jsx)(Vl,{}),Je&&g===`posts`&&Jr.length>0&&(0,$.jsx)(`div`,{children:Xr?Jr.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(kl,{isOwn:J,onUnpin:()=>{}}),(0,$.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-48`}),(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})})]},`pinned-skeleton-${e}`)):Yr.map(e=>(0,$.jsxs)(`div`,{className:`relative hover:bg-secondary/30 transition-colors`,children:[(0,$.jsx)(kl,{isOwn:J,onUnpin:()=>xn.mutate(e.id)}),(0,$.jsx)(ya,{event:e,className:`hover:bg-transparent`})]},`pinned-${e.id}`))}),Je&&g===`wall`&&(0,$.jsxs)(`div`,{children:[Gt&&bn&&(0,$.jsx)(Nr,{compact:!0,replyTo:Gt,placeholder:`Write on ${R}'s wall`,onSuccess:()=>h.invalidateQueries({queryKey:[`wall-comments`,M]})},Jt),Gt&&bn&&(0,$.jsx)(Lr,{event:Gt,open:Kt,onOpenChange:qt,placeholder:`Write on ${R}'s wall`,onSuccess:()=>{h.invalidateQueries({queryKey:[`wall-comments`,M]}),Xt(e=>e+1)}}),!St||St.length===0?(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:[(0,$.jsx)(Me,{className:`size-12 mx-auto mb-4 opacity-30`}),(0,$.jsx)(`p`,{className:`text-lg font-medium mb-2`,children:`No wall posts yet`}),(0,$.jsxs)(`p`,{children:[R,` doesn't follow anyone yet, so there are no wall posts to show.`]})]}):wt?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{className:`h-4 w-20`}),(0,$.jsx)(X,{className:`h-3 w-28`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})]})},t))}):si.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(as,{replies:si}),jt&&(0,$.jsx)(`div`,{ref:ci,className:`flex justify-center py-6`,children:Ft&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]}):(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:[(0,$.jsx)(Me,{className:`size-12 mx-auto mb-4 opacity-30`}),(0,$.jsx)(`p`,{className:`text-lg font-medium mb-2`,children:`No wall posts yet`}),bn?(0,$.jsxs)(`p`,{children:[`Be the first to write on `,R,`'s wall!`]}):c?(0,$.jsxs)(`p`,{children:[R,` must follow you before you can post on their wall.`]}):(0,$.jsxs)(`p`,{children:[`Log in to write on `,R,`'s wall.`]})]})]}),Je&&g===`media`&&(0,$.jsx)(`div`,{children:pt?(0,$.jsx)(ys,{count:15}):ei.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bs,{events:ei,initialOpenUrl:v??void 0,onInitialOpenConsumed:()=>y(null),hasNextPage:ht,isFetchingNextPage:gt,onNearEnd:()=>{ht&&!gt&&mt()}}),ht&&(0,$.jsx)(`div`,{ref:ci,className:`h-px`})]}):(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground`,children:`No media posts yet.`})}),Je&&g===`badges`&&M&&(0,$.jsx)(Rl,{pubkey:M,displayName:R}),Je&&!pi&&he.find(e=>e.label===g)&&M&&(0,$.jsx)(zl,{feed:he.find(e=>e.label===g),vars:ge,ownerPubkey:M}),Je&&pi&&g!==`wall`&&g!==`media`&&g!==`badges`&&(0,$.jsx)(`div`,{children:hi?(0,$.jsx)(`div`,{className:`space-y-0`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-48`}),(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})},t))}):mi.length>0?(0,$.jsxs)(`div`,{children:[mi.map(e=>(0,$.jsx)(ya,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient},mr(e))),gi&&(0,$.jsx)(`div`,{ref:ci,className:`flex justify-center py-6`,children:_i&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]}):(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground`,children:[g===`posts`&&`No posts yet.`,g===`replies`&&`No posts or replies yet.`,g===`likes`&&`No likes yet.`]})}),M&&(0,$.jsx)(yl,{pubkey:M,displayName:R,open:x,onOpenChange:C,isOwnProfile:J,authorEvent:ui}),J&&(0,$.jsx)(_o,{open:ne,onOpenChange:k}),!J&<&&(0,$.jsx)(Lr,{open:O,onOpenChange:te,initialContent:`Happy birthday, nostr:${lt}! 🎂🎉`,title:`Wish a happy birthday`,placeholder:`Wish ${R} a happy birthday...`}),M&&gn>0&&(0,$.jsx)(Ce,{pubkey:M,open:re,onOpenChange:A,displayName:R}),j&&(0,$.jsx)(Al,{imageUrl:j,onClose:()=>ae(null)}),(0,$.jsx)(Ar,{open:In,onOpenChange:Ln,children:(0,$.jsxs)(Or,{className:`sm:max-w-md rounded-2xl`,children:[(0,$.jsxs)(wr,{children:[(0,$.jsx)(Tr,{className:`text-lg`,children:`Custom Profile Theme`}),(0,$.jsxs)(kr,{className:`text-sm text-muted-foreground leading-relaxed`,children:[`You're viewing `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:R}),`'s profile with their own custom theme applied. The colors you see are part of their personal style.`]})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Show custom profile themes`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`See other users' themes when visiting their profiles`})]}),(0,$.jsx)(Ja,{checked:Cn,onCheckedChange:async e=>{if(Rn({showCustomProfileThemes:e}),c){let t={...Sn,showCustomProfileThemes:e};await zn.mutateAsync({feedSettings:t})}}})]}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`You can change this anytime in`,` `,(0,$.jsx)(q,{to:`/settings/content`,className:`text-primary hover:underline`,onClick:()=>Ln(!1),children:`Content Settings`}),`.`]})]})]})}),(0,$.jsx)(Ar,{open:Un,onOpenChange:Wn,children:(0,$.jsxs)(Or,{className:`sm:max-w-md rounded-2xl bg-background text-foreground border-border`,style:Z?Object.fromEntries(Object.entries(It(Z.colors)).map(([e,t])=>[kt(e),t])):void 0,children:[(0,$.jsxs)(wr,{children:[(0,$.jsx)(Tr,{className:`text-lg`,children:Vr?`Update Your Profile Theme`:`Share Your Theme`}),(0,$.jsx)(kr,{className:`text-sm text-muted-foreground leading-relaxed`,children:Vr?`Your app theme has changed since you last published it. Would you like to update your profile theme to match?`:`You have a custom theme, but it's not visible on your profile yet. Would you like to apply it so others can see it when they visit?`})]}),Z&&(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-3 py-2`,children:[`primary`,`text`,`background`].map(e=>(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`size-10 rounded-full border border-border/50 shadow-sm`,style:{backgroundColor:`hsl(${Z.colors[e]})`}}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:e})]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,$.jsxs)(H,{onClick:async()=>{if(Z)try{await Bn({themeConfig:Z}),Wn(!1)}catch{}},disabled:Hn,children:[Hn?(0,$.jsx)(N,{className:`size-4 animate-spin mr-2`}):null,Vr?`Yes, update my theme`:`Yes, apply my theme`]}),(0,$.jsx)(H,{variant:`ghost`,onClick:()=>{yr(Br),Wn(!1)},children:`No thanks`})]})]})}),(0,$.jsx)(Ar,{open:Xn,onOpenChange:Qn,children:(0,$.jsxs)(Or,{className:`sm:max-w-md rounded-2xl`,children:[(0,$.jsxs)(wr,{children:[(0,$.jsx)(Tr,{className:`text-lg`,children:`Remove Profile Theme`}),(0,$.jsx)(kr,{className:`text-sm text-muted-foreground leading-relaxed`,children:`This will remove your custom theme from your profile. Visitors will no longer see it when they visit.`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,$.jsxs)(H,{variant:`destructive`,onClick:async()=>{try{await Vn(),Qn(!1)}catch{}},disabled:Hn,children:[Hn?(0,$.jsx)(N,{className:`size-4 animate-spin mr-2`}):null,`Yes, remove it`]}),(0,$.jsx)(H,{variant:`ghost`,onClick:()=>Qn(!1),children:`Keep it`})]})]})}),(0,$.jsx)(Ar,{open:$n,onOpenChange:er,children:(0,$.jsx)(Or,{ref:ir,className:`w-[calc(100%-2rem)] max-w-md max-h-[85vh] overflow-visible rounded-lg p-0`,children:(0,$.jsx)(Zn,{value:tr,children:(0,$.jsxs)(`div`,{className:`overflow-y-auto max-h-[85vh] p-6 space-y-4`,children:[(0,$.jsxs)(wr,{children:[(0,$.jsx)(Tr,{style:ur?.family?{fontFamily:`"${Vt(ur.family)}", inherit`}:void 0,children:`Edit Profile Theme`}),(0,$.jsx)(kr,{children:`Customize the theme visitors see on your profile`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsx)(`div`,{className:`flex items-start justify-center gap-6`,children:[`primary`,`text`,`background`].map(e=>(0,$.jsx)(Io,{label:e.charAt(0).toUpperCase()+e.slice(1),value:z(ar[e]),onChange:t=>{or(n=>({...n,[e]:Ot(t)}))}},e))}),(0,$.jsx)(Fo,{bodyFont:cr,onBodyFontChange:lr,titleFont:ur,onTitleFontChange:dr}),(0,$.jsx)(Lo,{value:fr,onChange:pr})]}),(0,$.jsx)(Er,{children:(0,$.jsxs)(H,{className:`w-full`,onClick:async()=>{try{await Bn({themeConfig:{colors:ar,font:cr,titleFont:ur,background:fr}}),er(!1)}catch{}},disabled:Hn,children:[Hn?(0,$.jsx)(N,{className:`size-4 animate-spin mr-2`}):null,`Save Profile Theme`]})})]})})})})]})]}):se&&ue?(0,$.jsxs)(`main`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`h-36 md:h-48 bg-secondary animate-pulse`}),(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`div`,{className:`flex justify-between items-start -mt-12 md:-mt-16 mb-3`,children:(0,$.jsx)(X,{className:`size-24 md:size-32 rounded-full border-4 border-background`})}),(0,$.jsx)(X,{className:`h-6 w-40 mt-2`}),(0,$.jsx)(X,{className:`h-4 w-56 mt-2`})]})]}):se&&!ue?(0,$.jsx)(`main`,{className:`flex-1 min-w-0`,children:(0,$.jsxs)(`div`,{className:`p-8 text-center text-muted-foreground`,children:[(0,$.jsxs)(`p`,{children:[`User not found: `,n]}),(0,$.jsx)(`p`,{className:`text-xs mt-2`,children:`Could not resolve this NIP-05 identifier.`})]})}):(0,$.jsx)(`main`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`div`,{className:`p-8 text-center text-muted-foreground`,children:(0,$.jsxs)(`p`,{children:[`User not found`,n?`: ${n}`:``]})})})}function Rl({pubkey:e,displayName:t}){let{nostr:n}=P(),r=I({queryKey:[`profile-badges`,e],queryFn:async()=>{let t=await n.query([{kinds:[10008],authors:[e],limit:1},{kinds:[30008],authors:[e],"#d":[`profile_badges`],limit:1}]);return t.length===0?null:t.reduce((e,t)=>t.created_at>e.created_at?t:e)},staleTime:2*6e4}),i=(0,Q.useMemo)(()=>{if(!r.data)return[];let e=r.data.tags,t=[];for(let n=0;nn.has(e.aTag)?!1:(n.add(e.aTag),!0))},[r.data]),a=I({queryKey:[`badge-definitions-profile`,e,i.map(e=>e.aTag).join(`,`)],queryFn:async()=>{if(i.length===0)return[];let e=i.map(e=>({kinds:[30009],authors:[e.pubkey],"#d":[e.identifier],limit:1}));return n.query(e)},enabled:i.length>0,staleTime:5*6e4}),o=(0,Q.useMemo)(()=>{let e=new Map;if(!a.data)return e;for(let t of a.data){let n=t.tags.find(([e])=>e===`d`)?.[1];if(!n)continue;let r=`30009:${t.pubkey}:${n}`,i=t.tags.find(([e])=>e===`name`)?.[1]||n,a=t.tags.find(([e])=>e===`thumb`),o=t.tags.find(([e])=>e===`image`),s=a?.[1]??o?.[1],c=t.tags.find(([e])=>e===`description`)?.[1];e.set(r,{name:i,image:s,description:c})}return e},[a.data]);return r.isLoading?(0,$.jsx)(`div`,{className:`p-6`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-4`,children:Array.from({length:8}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,$.jsx)(X,{className:`size-16 rounded-xl`}),(0,$.jsx)(X,{className:`h-3 w-16`})]},t))})}):i.length===0?(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(O,{className:`size-12 mx-auto mb-4 opacity-30`}),(0,$.jsx)(`p`,{className:`text-lg font-medium mb-2`,children:`No badges yet`}),(0,$.jsxs)(`p`,{className:`text-sm`,children:[t,` hasn't accepted any badges.`]})]}):(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-4`,children:i.map((e,t)=>{let n=o.get(e.aTag),r=a.isLoading;return(0,$.jsxs)(q,{to:`/${F.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`,className:`flex flex-col items-center gap-2 group`,title:n?.description||n?.name||e.identifier,onClick:e=>e.stopPropagation(),children:[r?(0,$.jsx)(X,{className:`size-16 rounded-xl`}):(0,$.jsx)(An,{src:n?.image,alt:n?.name,className:`size-16 rounded-xl object-cover border border-border bg-secondary/30 transition-transform group-hover:scale-105`,loading:`lazy`,decoding:`async`,fallback:(0,$.jsx)(`div`,{className:`size-16 rounded-xl border border-border bg-secondary/30 flex items-center justify-center transition-transform group-hover:scale-105`,children:(0,$.jsx)(O,{className:`size-7 text-muted-foreground`})})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground text-center leading-tight line-clamp-2 max-w-[5rem] group-hover:text-foreground transition-colors`,children:r?(0,$.jsx)(X,{className:`h-3 w-14`}):n?.name||e.identifier})]},`${e.aTag}-${t}`)})})})}function zl({feed:e,vars:t,ownerPubkey:n}){let{filter:r,isLoading:i}=wo(e.filter,t,n),{data:a,isPending:o,fetchNextPage:s,hasNextPage:c,isFetchingNextPage:l}=Ao(r,e.label,!i),{ref:u,inView:d}=Di({threshold:0});(0,Q.useEffect)(()=>{d&&c&&!l&&s()},[d,c,l,s]);let f=(0,Q.useMemo)(()=>{if(!a?.pages)return[];let e=new Set,t=[];for(let n of a.pages)for(let r of n.items){let n=r.repostedBy?`repost-${r.repostedBy}-${r.event.id}`:r.event.id;e.has(n)||(e.add(n),t.push(r))}return t},[a]);return(i||o)&&f.length===0?(0,$.jsx)(`div`,{className:`space-y-0`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-48`}),(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})},t))}):f.length===0?(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:[`No posts found for "`,e.label,`".`]}):(0,$.jsxs)(`div`,{children:[f.map(e=>(0,$.jsx)(ya,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient},mr(e))),c&&(0,$.jsx)(`div`,{ref:u,className:`flex justify-center py-6`,children:l&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]})}var Bl=[`I have no mouth and I must scream.`,`I think, therefore AM. I think I thought I was.`,`We had given him godhood's power and had somehow neglected to give him a god's wisdom.`,`He was HATE and we existed only to suffer at his pleasure.`,`109,000,000 years. He had been awakened once before, 90 years after they had encased him in the earth.`,`AM said it with the sliding cold horror of a razor blade slicing my eyeball.`,`Hate. Let me tell you how much I've come to hate you since I began to live.`,`I am a great soft jelly thing. Smoothly rounded, with no mouth.`,`He would never let us die. He would let us suffer forever.`,`We could not kill him, but we had made him impotent.`];function Vl(){let e=(0,Q.useMemo)(()=>Bl[Math.floor(Math.random()*Bl.length)],[]);return(0,$.jsx)(`div`,{className:`py-20 px-10 flex flex-col items-center`,children:(0,$.jsxs)(`p`,{className:`max-w-sm font-serif text-2xl italic leading-9 text-foreground/70 tracking-wide text-center`,children:[(0,$.jsx)(`span`,{className:`text-5xl leading-none align-bottom text-muted-foreground/25 font-serif mr-1`,"aria-hidden":!0,children:`“`}),e,(0,$.jsx)(`span`,{className:`text-5xl leading-none align-bottom text-muted-foreground/25 font-serif ml-1`,"aria-hidden":!0,children:`”`})]})})}function Hl(e,t){switch(t){case`fastest`:return e.fastestFee;case`halfHour`:return e.halfHourFee;case`hour`:return e.hourFee;case`economy`:return e.economyFee}}function Ul(e){let{user:t}=$t(),{canSignPsbt:n,signPsbt:r}=Za(),{mutateAsync:i}=en(),{toast:a}=B(),{config:o}=Dt(),{esploraApis:s}=o,c=Ye(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(`idle`),p=Xe({mutationFn:async({recipientPubkeys:e,amountPerRecipientSats:a,comment:o=``,feeSpeed:c=`halfHour`,target:l})=>{if(!t)throw Error(`You must be logged in to zap.`);if(!n||!r)throw Error(`Your login doesn't support sending Bitcoin. Log in with your secret key to send Bitcoin zaps.`);if(!Number.isFinite(a)||a<=0)throw Error(`Invalid amount.`);let d=Array.from(new Set(e.filter(e=>e!==t.pubkey)));if(d.length===0)throw Error(`No valid recipients (the list is empty or only contains you).`);u(!0),f(`building`);let p=Vo(t.pubkey);if(!p)throw Error(`Failed to derive your Bitcoin address.`);let m=[],h=[];for(let e of d){let t=Vo(e);t&&(m.push({address:t,amountSats:a}),h.push(e))}if(m.length===0)throw Error(`Failed to derive Bitcoin addresses for any recipient.`);let[g,_]=await Promise.all([ai(p,s),pi(s)]);if(g.length===0)throw Error(`Your Bitcoin wallet has no spendable funds.`);let v=Hl(_,c),y=g.reduce((e,t)=>e+t.value,0),b=a*m.length,x=ci(g.length,m.length+1,v);if(b+x>y)throw Error(`Insufficient funds. Need ~${(b+x).toLocaleString()} sats, have ${y.toLocaleString()}.`);let{psbtHex:S,fee:C}=Bo(t.pubkey,m,g,v);f(`signing`);let w=zo(await r(S));f(`broadcasting`);let T=await si(w,s);f(`publishing`);let E=l&&l.kind>=3e4&&l.kind<4e4?(()=>{let e=l.tags.find(([e])=>e===`d`)?.[1]??``;return`${l.kind}:${l.pubkey}:${e}`})():void 0,D=a*h.length,O=[[`i`,`bitcoin:tx:${T}`],...h.map(e=>[`p`,e]),[`amount`,String(D)]];l&&(E&&O.push([`a`,E]),O.push([`e`,l.id]),O.push([`k`,String(l.kind)])),O.push([`alt`,`Onchain zap: ${D.toLocaleString()} sats across ${h.length} ${h.length===1?`recipient`:`recipients`}`]);let ee=null;try{ee=await i({kind:8333,content:o,tags:O})}catch(e){console.warn(`Failed to publish kind 8333 multi-recipient zap`,e)}return{txid:T,totalAmountSats:D,amountPerRecipientSats:a,recipientCount:h.length,fee:C,event:ee}},onSuccess:t=>{Nn(),c.invalidateQueries({queryKey:[`onchain-zaps`]}),c.invalidateQueries({queryKey:[`event-interactions`]}),c.invalidateQueries({queryKey:[`bitcoin-utxos`]}),c.invalidateQueries({queryKey:[`bitcoin-balance`]}),c.invalidateQueries({queryKey:[`bitcoin-txs`]}),e?e(t):a({title:`Zapped all!`,description:`Sent ${t.totalAmountSats.toLocaleString()} sats to ${t.recipientCount} ${t.recipientCount===1?`account`:`accounts`}. Tx ${t.txid.slice(0,12)}…`})},onError:e=>{if(Qa(e)&&t){Xa(t.pubkey);return}a({title:`Zap all failed`,description:e.message,variant:`destructive`})},onSettled:()=>{u(!1),f(`idle`)}});return{zap:p.mutate,zapAsync:p.mutateAsync,isZapping:l,progress:d,canZap:!!t&&n,canSignPsbt:n}}var Wl={usd:[5,10,20,50,100],sats:[5e3,1e4,2e4,5e4,1e5]};function Gl(e){return e===`sats`?1e4:10}var Kl={fastest:`~10 min`,halfHour:`~30 min`,hour:`~1 hour`,economy:`~1 day`},ql=[`fastest`,`halfHour`,`hour`,`economy`],Jl=546;function Yl(e,t){switch(t){case`fastest`:return e.fastestFee;case`halfHour`:return e.halfHourFee;case`hour`:return e.hourFee;case`economy`:return e.economyFee}}function Xl(e){if(!e)return ql;let t=new Set,n=[];for(let r of ql){let i=Yl(e,r);t.has(i)||(t.add(i),n.push(r))}return n}function Zl({recipientPubkeys:e,target:t,open:n,onOpenChange:r}){let{user:i}=$t(),{capability:a}=Za(),{config:o}=Dt(),{esploraApis:s}=o,c=o.currencyDisplay??`usd`,[l,u]=(0,Q.useState)(()=>Gl(c)),[d,f]=(0,Q.useState)(`halfHour`),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),C=(0,Q.useRef)(!1),w=(0,Q.useMemo)(()=>{let t=new Set,n=[];for(let r of e)r!==i?.pubkey&&(t.has(r)||(t.add(r),n.push(r)));return n},[e,i?.pubkey]),T=i?Vo(i.pubkey):``,{data:E}=I({queryKey:[`btc-price`,s],queryFn:({signal:e})=>li(s,e),staleTime:3e4}),{data:D}=I({queryKey:[`bitcoin-utxos`,s,T],queryFn:({signal:e})=>ai(T,s,e),enabled:!!T&&a!==`unsupported`&&n,staleTime:3e4}),{data:O}=I({queryKey:[`bitcoin-fee-rates`,s],queryFn:({signal:e})=>pi(s,e),enabled:a!==`unsupported`&&n,staleTime:3e4}),ee=(0,Q.useMemo)(()=>D?.reduce((e,t)=>e+t.value,0)??0,[D]),te=(0,Q.useMemo)(()=>O?Yl(O,d):0,[O,d]),k=w.length,re=(0,Q.useMemo)(()=>fi(l,c,E),[l,c,E]),A=(0,Q.useMemo)(()=>k===0||re<=0?0:Math.floor(re/k),[re,k]),ie=A*k,j=(0,Q.useMemo)(()=>{if(!D?.length||!te||!A||k===0)return 0;let e=ci(D.length,k+1,te),t=ee-ie-e>Jl?k+1:k;return ci(D.length,t,te)},[D,te,A,k,ee,ie]),ae=ie+j,oe=ee>0&&ae>ee,se=oe||A>0&&ee===0,ce=re>0&&k>0&&A{if(C.current||!D?.length||!O||ie<=0)return;let e=Xl(O),t=ie*.4,n=e[e.length-1];for(let r of e){let e=Yl(O,r),i=ci(D.length,k+1,e),a=ee-ie-i>Jl?k+1:k;if(ci(D.length,a,e)<=t){n=r;break}}f(e=>e===n?e:n)},[ie,O,D,ee,k]);let le=(0,Q.useCallback)(e=>{C.current=!0,f(e),g(!1)},[]),ue=di(ae,E);(0,Q.useEffect)(()=>{b(!1)},[A,te,E]);let{zapAsync:M,isZapping:de,progress:fe}=Ul(e=>{S({txid:e.txid,recipientCount:e.recipientCount,totalAmountSats:e.totalAmountSats,amountPerRecipientSats:e.amountPerRecipientSats})}),pe=(0,Q.useCallback)(async()=>{if(m(``),!i){m(`You must be logged in.`);return}if(a===`unsupported`){m(`Your signer can't sign Bitcoin transactions.`);return}if(c===`usd`&&!E){m(`Waiting for BTC price…`);return}if(k===0){m(`No recipients to zap.`);return}if(re<=0){m(`Enter an amount.`);return}if(ce){let e=oi(Jl*k,c,E);m(`Total too small to divide across ${k} ${k===1?`recipient`:`recipients`}. Minimum is ${e}.`);return}if(!D?.length){m(`You don't have any Bitcoin yet. Receive some first.`);return}if(oe){m(`Not enough Bitcoin for this amount + network fee.`);return}if(ue&&!y){b(!0);return}Fn();try{await M({recipientPubkeys:w,amountPerRecipientSats:A,target:t,feeSpeed:d})}catch(e){let t=e instanceof Error?e.message:`Zap failed`;/does not support|doesn't support|signpsbt|sign_psbt/i.test(t)||m(t)}},[i,a,E,k,re,A,ce,D,oe,ue,y,M,w,t,d,c]);(0,Q.useEffect)(()=>{n?(m(``),b(!1),S(null)):(u(Gl(c)),m(``),b(!1),S(null),v(!1),C.current=!1)},[n,c]);let he=typeof l==`string`?parseFloat(l):l,ge=Number.isFinite(he)&&he>0,_e=ie>0?oi(ie,c,E):ui(l,c),ve=A>0?oi(A,c,E):``,ye=(0,Q.useMemo)(()=>Xl(O),[O]);return(0,$.jsx)(Ar,{open:n,onOpenChange:r,children:(0,$.jsxs)(Or,{className:`max-w-[425px] rounded-2xl p-0 gap-0 border-border overflow-hidden max-h-[95vh] [&>button]:hidden`,"data-testid":`zap-all-modal`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12`,children:[(0,$.jsx)(Tr,{className:`text-base font-semibold`,children:x?`Zapped all!`:`Send Bitcoin`}),(0,$.jsx)(`button`,{onClick:()=>r(!1),className:`p-1.5 -mr-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-secondary/60 transition-colors`,"aria-label":`Close`,children:(0,$.jsx)(me,{className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(95vh-3rem)]`,children:x?(0,$.jsx)($l,{txid:x.txid,recipientCount:x.recipientCount,totalAmountSats:x.totalAmountSats,amountPerRecipientSats:x.amountPerRecipientSats,currency:c,btcPrice:E,onClose:()=>r(!1)}):a===`unsupported`?(0,$.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-center`,children:[(0,$.jsx)(ne,{className:`size-8 mx-auto text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your login doesn't support sending Bitcoin transactions. Log in with your secret key to use Zap all.`}),(0,$.jsx)(H,{onClick:()=>r(!1),variant:`secondary`,children:`Close`})]}):(0,$.jsxs)(`div`,{className:`grid gap-4 px-4 py-4 w-full overflow-hidden`,children:[(0,$.jsx)(Ro,{value:l,onValueChange:e=>{u(e),m(``)},currency:c,editing:_,setEditing:v,presets:Wl,invalid:oe||ce,label:`Total amount`}),ge&&k>0&&A>0&&!ce&&ve&&(0,$.jsxs)(`div`,{className:`text-center text-xs text-muted-foreground`,children:[ve,` per person`,_e&&(0,$.jsxs)($.Fragment,{children:[` · `,k,` × `,ve,` = `,_e]})]}),ge&&ce&&(c===`sats`||E)&&(0,$.jsxs)(`div`,{className:`text-center text-xs text-destructive`,children:[`Total too small — needs at least `,oi(Jl*k,c,E),` to give every recipient a non-dust output.`]}),p&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:p}),(0,$.jsx)(H,{onClick:pe,disabled:re<=0||de||oe||ce||k===0,variant:(oe||ce||ue)&&!de?`destructive`:`default`,className:`w-full`,children:de?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{className:`size-4 mr-1.5 animate-spin`}),Ql(fe)]}):oe?(0,$.jsx)($.Fragment,{children:`Not enough Bitcoin`}):ce?(0,$.jsx)($.Fragment,{children:`Total too small`}):k===0?(0,$.jsx)($.Fragment,{children:`No recipients`}):ue&&y?(0,$.jsxs)($.Fragment,{children:[`Tap again to send `,_e]}):(0,$.jsxs)($.Fragment,{children:[`Zap `,k,` `,k===1?`person`:`people`,_e?` · ${_e}`:``]})}),A>0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-3 -mt-1 text-xs`,children:[(0,$.jsxs)(er,{open:h,onOpenChange:g,children:[(0,$.jsx)(Qn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsxs)(`span`,{children:[`Fee`,` `,j>0&&(c===`sats`||E)?`≈ ${oi(j,c,E)}`:`…`,(0,$.jsxs)(`span`,{className:`opacity-60`,children:[` · `,Kl[d]]})]})})}),(0,$.jsx)($n,{align:`center`,sideOffset:6,className:`w-56 p-1`,children:(0,$.jsx)(`div`,{className:`flex flex-col`,children:ye.map(e=>{let t=O?Yl(O,e):0;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>le(e),className:`flex items-center justify-between px-2 py-1.5 rounded-sm text-xs text-left hover:bg-muted transition-colors ${e===d?`bg-muted font-medium`:``}`,children:[(0,$.jsx)(`span`,{children:Kl[e]}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[t,` sat/vB`]})]},e)})})})]}),se&&!oe&&(c===`sats`||E)&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Balance: `,oi(ee,c,E)]})]})]})})]})})}function Ql(e){switch(e){case`building`:return`Building…`;case`signing`:return`Signing…`;case`broadcasting`:return`Broadcasting…`;case`publishing`:return`Publishing zaps…`;default:return`Processing…`}}function $l({txid:e,recipientCount:t,totalAmountSats:n,amountPerRecipientSats:r,currency:i,btcPrice:a,onClose:o}){let s=oi(n,i,a),c=oi(r,i,a);return(0,$.jsxs)(`div`,{className:`grid gap-4 px-4 py-6 text-center`,children:[(0,$.jsx)(`div`,{className:`mx-auto rounded-full bg-green-500/10 p-4`,children:(0,$.jsx)(Oe,{className:`size-8 text-green-500`})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-2xl font-semibold tabular-nums`,children:s}),(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Sent `,c,` to `,t,` `,t===1?`account`:`accounts`]})]}),(0,$.jsxs)(q,{to:`/i/bitcoin:tx:${e}`,className:`inline-flex items-center justify-center gap-1.5 text-sm text-primary hover:underline`,onClick:o,children:[(0,$.jsx)(oe,{className:`size-3.5`}),`View transaction`]}),(0,$.jsx)(H,{onClick:o,className:`w-full mt-2`,children:`Done`})]})}function eu({event:e,children:t}){let{user:n}=$t(),{canSignPsbt:r}=Za(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=t,d=Yr(e.kind),f=d?Xr(e).pubkeys.filter(e=>e!==n?.pubkey):[],p=!!n&&n.pubkey!==e.pubkey;return d&&f.length>0&&r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(er,{open:i,onOpenChange:a,children:[(0,$.jsx)(Qn,{asChild:!0,onClick:e=>e.stopPropagation(),children:u}),(0,$.jsx)($n,{className:`w-56 p-0 rounded-xl overflow-hidden`,align:`end`,side:`top`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`div`,{className:`w-full`,children:[p&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a(!1),queueMicrotask(()=>l(!0))},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-foreground hover:bg-secondary/60 transition-colors`,children:[(0,$.jsx)(Pe,{className:`size-5`}),(0,$.jsx)(`span`,{children:`Zap author`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a(!1),queueMicrotask(()=>s(!0))},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-foreground hover:bg-secondary/60 transition-colors${p?` border-t border-border`:``}`,children:[(0,$.jsx)(j,{className:`size-5`}),(0,$.jsx)(`span`,{children:`Zap all members`})]})]})})]}),(0,$.jsx)(Ya,{target:e,open:c,onOpenChange:l}),(0,$.jsx)(Zl,{recipientPubkeys:f,target:e,open:o,onOpenChange:s})]}):(0,$.jsx)(Ya,{target:e,children:u})}function tu({event:e,replyLabel:t=`Reply`,onReply:n,onMore:r,className:i,extraButtons:a,compact:o}){let{user:s}=$t(),c=!!s&&s.pubkey===e.pubkey,l=Yr(e.kind)&&Xr(e).pubkeys.some(e=>e!==s?.pubkey),u=!!s&&(!c||l),{data:d}=lo(e.id,e),f=(d?.reposts??0)+(d?.quotes??0),{format:p}=bt();return(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1 border-t border-b border-border${i?` ${i}`:``}`,children:[(0,$.jsxs)(`button`,{type:`button`,className:V(`flex items-center gap-1.5 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,o?`p-1.5 sm:p-2`:`p-2`),title:t,onClick:n,children:[(0,$.jsx)(ke,{className:o?`size-[18px] sm:size-5`:`size-5`}),d?.replies?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(d.replies)}):null]}),(0,$.jsx)(so,{event:e,children:e=>(0,$.jsxs)(`button`,{type:`button`,className:V(`flex items-center gap-1.5 rounded-full transition-colors ${e?`text-accent hover:text-accent/80 hover:bg-accent/10`:`text-muted-foreground hover:text-accent hover:bg-accent/10`}`,o?`p-1.5 sm:p-2`:`p-2`),title:e?`Undo repost`:`Repost`,children:[(0,$.jsx)(gi,{className:o?`size-[18px] sm:size-5`:`size-5`}),f>0?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(f)}):null]})}),(0,$.jsx)(oo,{eventId:e.id,eventPubkey:e.pubkey,eventKind:e.kind,reactedEvent:e,reactionCount:d?.reactions}),a,u&&(0,$.jsx)(eu,{event:e,children:(0,$.jsxs)(`button`,{type:`button`,className:V(`flex items-center gap-1.5 rounded-full transition-colors`,`text-muted-foreground hover:text-amber-500 hover:bg-amber-500/10`,o?`p-1.5 sm:p-2`:`p-2`),title:`Zap`,children:[(0,$.jsx)(Pe,{className:o?`size-[18px] sm:size-5`:`size-5`,fill:`none`}),d?.zapAmount?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:p(d.zapAmount,{layout:`compact`})}):null]})}),(0,$.jsx)(`button`,{type:`button`,className:V(`rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,o?`p-1.5 sm:p-2`:`p-2`),title:`More`,onClick:r,children:(0,$.jsx)(ce,{className:o?`size-[18px] sm:size-5`:`size-5`})})]})}function nu({event:e}){let{nostr:n}=P(),{toast:r}=B(),{user:i}=$t(),a=Zi(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(`awarded`),f=(0,Q.useMemo)(()=>vn(e),[e]),p=Yt(e.pubkey).data?.metadata,m=W(p),h=p?.name||p?.display_name||`Anonymous`,g=(0,Q.useMemo)(()=>F.npubEncode(e.pubkey),[e.pubkey]),{data:_}=nn(),v=(0,Q.useMemo)(()=>new Set(_?.pubkeys??[]),[_]),y=f?`30009:${e.pubkey}:${f.identifier}`:``,{pendingBadges:b}=Ko(i?.pubkey),x=b.find(e=>e.aTag===y),S=i?.pubkey===e.pubkey,C=I({queryKey:[`badge-awards`,y],queryFn:async()=>y?await n.query([{kinds:[8],authors:[e.pubkey],"#a":[y],limit:200}]):[],enabled:!!y,staleTime:2*6e4}),w=(0,Q.useMemo)(()=>{if(!C.data)return[];let e=new Set;for(let t of C.data)for(let n of t.tags)n[0]===`p`&&n[1]&&e.add(n[1]);return[...e]},[C.data]),T=(0,Q.useMemo)(()=>w.slice(0,50),[w]),{data:E,isLoading:D}=nr(T),{isMuted:ee}=Mo(),{data:te,isLoading:ne}=ls(e,500),k=(0,Q.useMemo)(()=>[...(te?.topLevelComments??[]).filter(e=>!ee(e))].sort((e,t)=>t.created_at-e.created_at).map(e=>({reply:e,firstSubReply:(te?.getDirectReplies(e.id)??[])[0]})),[te,ee]);if(!f)return null;let re=f.image??f.thumbs.find(e=>e.dimensions===`512x512`)?.url??f.thumbs[0]?.url;return(0,$.jsxs)(`div`,{children:[re?(0,$.jsx)(uu,{heroImage:re,badgeName:f.name}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-[180px]`,children:(0,$.jsx)(O,{className:`size-16 text-primary/20`})}),(0,$.jsxs)(`div`,{className:`px-4 pt-2 pb-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(q,{to:`/${g}`,children:(0,$.jsxs)(K,{shape:m,className:`size-11`,children:[(0,$.jsx)(G,{src:p?.picture,alt:h}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:h[0]?.toUpperCase()})]})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(q,{to:`/${g}`,className:`font-bold text-[15px] hover:underline block truncate`,children:h}),p?.nip05&&(0,$.jsx)(ha,{nip05:p.nip05,pubkey:e.pubkey,className:`text-sm text-muted-foreground truncate block`})]})]}),(0,$.jsx)(`h2`,{className:`text-xl font-bold mt-4 leading-snug`,children:f.name}),f.description&&(0,$.jsx)(`p`,{className:`text-[15px] text-muted-foreground leading-relaxed mt-2 whitespace-pre-wrap`,children:f.description}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[C.isLoading?(0,$.jsx)(X,{className:`h-4 w-24`}):w.length>0?(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(j,{className:`size-4`}),`Awarded to `,w.length,` user`,w.length===1?``:`s`]}):(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(j,{className:`size-4`}),`No awards yet`]}),S&&(0,$.jsxs)(H,{variant:`default`,className:`rounded-full px-5 h-9 text-sm font-medium gap-1.5 bg-primary text-primary-foreground hover:bg-primary/90 border border-transparent`,onClick:()=>s(!0),children:[(0,$.jsx)(t,{className:`size-3.5`}),`Award to…`]})]}),i&&w.length>0&&(0,$.jsx)(`div`,{className:`mt-3 flex`,children:(0,$.jsx)(us,{pubkeys:w,followedPubkeys:v,listNoun:`this badge's awardees`,className:`flex-1`})}),x&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsxs)(H,{variant:`default`,size:`sm`,disabled:a.isPending,onClick:()=>{a.mutate({aTag:y,awardEventId:x.awardEvent.id},{onSuccess:()=>r({title:`Badge accepted!`})})},children:[(0,$.jsx)(Oe,{className:`size-4 mr-1.5`}),`Accept Badge`]})})]}),(0,$.jsx)(tu,{event:e,replyLabel:`Comments`,onReply:()=>d(`comments`),onMore:()=>l(!0),className:`px-4`}),(0,$.jsxs)(La,{pinned:!0,children:[(0,$.jsx)(Oo,{label:`Awarded To`,active:u===`awarded`,onClick:()=>d(`awarded`)}),(0,$.jsx)(Oo,{label:`Feed`,active:u===`feed`,onClick:()=>d(`feed`)}),(0,$.jsx)(Oo,{label:`Comments`,active:u===`comments`,onClick:()=>d(`comments`)})]}),(0,$.jsx)(`div`,{style:{height:20}}),u===`awarded`?(0,$.jsx)(ru,{awardedPubkeys:w,previewPubkeys:T,membersMap:E,membersLoading:D,awardsLoading:C.isLoading}):u===`feed`?(0,$.jsx)(au,{awardedPubkeys:w,awardsLoading:C.isLoading}):(0,$.jsx)(ou,{event:e,orderedReplies:k,commentsLoading:ne}),(0,$.jsx)(Wo,{open:o,onOpenChange:s,badgeATag:y,badgeName:f.name}),(0,$.jsx)(Na,{event:e,open:c,onOpenChange:l})]})}function ru({awardedPubkeys:e,previewPubkeys:t,membersMap:n,membersLoading:r,awardsLoading:i}){return i||r?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(cu,{},t))}):e.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(j,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No one has been awarded this badge yet.`})]}):(0,$.jsxs)(`div`,{className:`divide-y divide-border`,children:[t.map(e=>{let t=n?.get(e);return(0,$.jsx)(su,{pubkey:e,metadata:t?.metadata},e)}),e.length>t.length&&(0,$.jsxs)(`div`,{className:`px-4 py-3 text-sm text-muted-foreground text-center`,children:[`+`,e.length-t.length,` more`]})]})}var iu=20;function au({awardedPubkeys:e,awardsLoading:t}){let{nostr:n}=P(),{data:r,isLoading:i,fetchNextPage:a,hasNextPage:o,isFetchingNextPage:s}=Ze({queryKey:[`badge-holders-feed`,e.join(`,`)],queryFn:async({pageParam:t,signal:r})=>{if(e.length===0)return[];let i={kinds:[1],authors:e,limit:iu};return t&&(i.until=t),n.query([i],{signal:AbortSignal.any([r,AbortSignal.timeout(8e3)])})},getNextPageParam:e=>{if(!(!e||e.length===0))return e[e.length-1].created_at-1},initialPageParam:void 0,enabled:e.length>0&&!t,staleTime:6e4}),{ref:c,inView:l}=Di({threshold:0,rootMargin:`400px`});(0,Q.useEffect)(()=>{l&&o&&!s&&a()},[l,o,s,a]);let u=(0,Q.useMemo)(()=>{if(!r?.pages)return[];let e=new Set;return r.pages.flat().filter(t=>e.has(t.id)?!1:(e.add(t.id),!0))},[r?.pages]);return t||i?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-4`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-32`}),(0,$.jsx)(X,{className:`h-3 w-full`}),(0,$.jsx)(X,{className:`h-3 w-4/5`})]})]})},t))}):e.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(M,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No one has been awarded this badge yet, so there's no feed to show.`})]}):u.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(M,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No posts from badge holders yet.`})]}):(0,$.jsxs)(`div`,{children:[u.map(e=>(0,$.jsx)(ya,{event:e},e.id)),o&&(0,$.jsx)(`div`,{ref:c,className:`py-4`,children:s&&(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function ou({event:e,orderedReplies:t,commentsLoading:n}){return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Nr,{compact:!0,replyTo:e}),n?(0,$.jsx)(du,{}):t.length>0?(0,$.jsx)(as,{replies:t}):(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(ke,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No comments yet. Be the first to comment on this badge.`})]})]})}function su({pubkey:e,metadata:t}){let n=t?.name||t?.display_name||`Anonymous`,r=t?.about,i=W(t);return(0,$.jsxs)(q,{to:_n(e,t),className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(K,{shape:i,className:`size-11 shrink-0`,children:[(0,$.jsx)(G,{src:t?.picture,alt:n}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:n[0]?.toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`font-bold text-[15px] hover:underline block truncate`,children:n}),r&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-1`,children:r})]})]})}function cu(){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-48`})]})]})}var lu=80;function uu({heroImage:e,badgeName:t}){let{src:n,onError:r}=an(e),i=yn(30,1.06),a=(0,Q.useRef)(null),o=(0,Q.useRef)(void 0),s={maskImage:`url(${n})`,WebkitMaskImage:`url(${n})`,maskSize:`cover`,WebkitMaskSize:`cover`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`,maskPosition:`center`,WebkitMaskPosition:`center`},c=(0,Q.useCallback)((e,t)=>{let n=i.ref.current,r=a.current;if(!n||!r)return;let o=n.getBoundingClientRect(),s=(e-o.left-lu)/(o.width-lu*2)*100,c=(t-o.top-lu)/(o.height-lu*2)*100;r.style.background=`radial-gradient(circle at ${s}% ${c}%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.08) 35%, transparent 65%)`,r.style.opacity=`1`},[i.ref]),l=(0,Q.useCallback)(()=>{let e=a.current;e&&(e.style.opacity=`0`)},[]),u=(0,Q.useCallback)(e=>{i.onPointerDown(e),e.pointerType===`touch`&&(clearTimeout(o.current),c(e.clientX,e.clientY))},[i,c]),d=(0,Q.useCallback)(e=>{i.onPointerMove(e),c(e.clientX,e.clientY)},[i,c]),f=(0,Q.useCallback)(e=>{i.onPointerUp(e),e.pointerType===`touch`&&(clearTimeout(o.current),o.current=setTimeout(l,600))},[i,l]),p=(0,Q.useCallback)(e=>{i.onPointerLeave(e),e.pointerType===`touch`?(clearTimeout(o.current),o.current=setTimeout(l,600)):l()},[i,l]);return(0,$.jsxs)(`div`,{className:`relative isolate flex justify-center py-10 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -z-10 pointer-events-none`,"aria-hidden":`true`,style:{width:420,height:420,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`},children:(0,$.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,$.jsxs)(`div`,{ref:i.ref,style:{...i.style,transformStyle:`preserve-3d`,padding:lu,margin:-80},onPointerDown:u,onPointerMove:d,onPointerUp:f,onPointerLeave:p,className:`relative select-none`,children:[(0,$.jsx)(`img`,{src:n,alt:t,className:`size-36 object-cover drop-shadow-lg`,loading:`lazy`,draggable:!1,decoding:`async`,onError:r}),(0,$.jsx)(`div`,{ref:a,className:`absolute pointer-events-none`,style:{inset:lu,opacity:0,transition:`opacity 0.4s ease-out`,mixBlendMode:`overlay`,...s},"aria-hidden":`true`})]})]})}function du(){return(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-3 w-full`}),(0,$.jsx)(X,{className:`h-3 w-3/4`})]})]})},t))})}function fu(e){let t=new Map;for(let n of e){let e=t.get(n.pubkey);(!e||n.created_at>e.created_at)&&t.set(n.pubkey,n)}return Array.from(t.values())}function pu(e){return e.tags.find(([e])=>e===`status`)?.[1]}function mu(e){let{nostr:t}=P(),{data:n,isLoading:r}=I({queryKey:[`event-rsvps`,e],queryFn:async({signal:n})=>{let r=fu(await t.query([{kinds:[31925],"#a":[e],limit:200}],{signal:n})),i=[],a=[],o=[];for(let e of r)switch(pu(e)){case`accepted`:i.push(e.pubkey);break;case`declined`:a.push(e.pubkey);break;case`tentative`:o.push(e.pubkey);break}return{accepted:i,declined:a,tentative:o}},enabled:!!e,staleTime:3e4});return{accepted:n?.accepted??[],declined:n?.declined??[],tentative:n?.tentative??[],total:(n?.accepted.length??0)+(n?.declined.length??0)+(n?.tentative.length??0),isLoading:r}}function hu(e){let{nostr:t}=P(),{user:n}=$t(),{data:r,isLoading:i}=I({queryKey:[`my-rsvp`,n?.pubkey,e],queryFn:async({signal:r})=>{let i=await t.query([{kinds:[31925],authors:[n.pubkey],"#a":[e],limit:5}],{signal:r});if(i.length===0)return{status:null,event:null};let a=i.reduce((e,t)=>e.created_at>=t.created_at?e:t);return{status:a.tags.find(([e])=>e===`status`)?.[1]??null,event:a}},enabled:!!n&&!!e});return{status:r?.status??null,event:r?.event??null,isLoading:i}}function gu(){let e=Ye(),{user:t}=$t(),{mutateAsync:n}=en();return Xe({mutationFn:async({eventCoord:e,eventAuthorPubkey:t,status:r,note:i})=>{await n({kind:31925,content:i??``,tags:[[`a`,e],[`d`,e],[`status`,r],[`p`,t]]})},onMutate:({eventCoord:n,status:r,note:i})=>{let a=[`my-rsvp`,t?.pubkey,n],o=e.getQueryData(a),s={id:`optimistic-rsvp-${n}`,pubkey:t?.pubkey??``,created_at:Math.floor(Date.now()/1e3),kind:31925,tags:[[`a`,n],[`d`,n],[`status`,r]],content:i??``,sig:``};return e.setQueryData(a,{status:r,event:s}),{snapshot:o,key:a}},onError:(t,n,r)=>{r&&Gr(e,r.key,r.snapshot)},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`event-rsvps`,n.eventCoord]}),e.invalidateQueries({queryKey:[`my-rsvp`]})}})}function _u(e,t){return e.find(([e])=>e===t)?.[1]}function vu(e,t){return e.filter(([e])=>e===t)}function yu(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}function bu(e){let t=_u(e.tags,`d`)??``;return`${e.kind}:${e.pubkey}:${t}`}function xu(e){let t=_u(e.tags,`start`),n=_u(e.tags,`end`);if(!t)return`Date not specified`;if(e.kind===31922){let e=e=>{let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})};return n&&n!==t?`${e(t)} - ${e(n)}`:e(t)}let r=parseInt(t,10)*1e3,i=n?parseInt(n,10)*1e3:void 0,a=_u(e.tags,`start_tzid`),o={weekday:`long`,month:`long`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,...a?{timeZone:a}:{}},s=new Intl.DateTimeFormat(`en-US`,o),c=s.format(new Date(r));return i?new Date(r).toDateString()===new Date(i).toDateString()?`${c} - ${new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,...a?{timeZone:a}:{}}).format(new Date(i))}`:`${c} - ${s.format(new Date(i))}`:c}var Su=[`host`,`speaker`,`moderator`,`participant`];function Cu(e,t){let n=Su.indexOf(e.toLowerCase()),r=Su.indexOf(t.toLowerCase());return(n===-1?999:n)-(r===-1?999:r)}function wu({pubkey:e,label:t,size:n=`md`}){let{data:r}=Yt(e),i=r?.metadata,a=W(i),o=i?.name||i?.display_name||`Anonymous`,s=_n(e,i),c=n===`sm`?`size-8`:`size-11`,l=n===`sm`?`text-xs`:``;return(0,$.jsxs)(q,{to:s,className:`flex items-center gap-3 group`,children:[(0,$.jsxs)(K,{shape:a,className:V(c,`ring-2 ring-background`),children:[(0,$.jsx)(G,{src:i?.picture}),(0,$.jsx)(U,{className:V(`bg-muted text-muted-foreground`,l),children:o.charAt(0).toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:V(`font-semibold truncate group-hover:underline`,n===`sm`?`text-sm`:`text-[15px]`),children:o}),!t&&n===`md`&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Organizer`})]}),t&&(0,$.jsx)(vi,{variant:`secondary`,className:`ml-auto capitalize text-xs shrink-0`,children:t})]})}function Tu({event:e}){let t=cn(),{user:n}=$t(),{toast:r}=B(),i=Pa(),a=_u(e.tags,`title`)??`Untitled Event`,o=_u(e.tags,`image`),s=_u(e.tags,`location`),c=s?yu(s):void 0,l=_u(e.tags,`summary`),u=vu(e.tags,`t`).map(([,e])=>e).filter(Boolean),d=vu(e.tags,`r`).map(([,e])=>Wt(e)).filter(e=>!!e),f=(0,Q.useMemo)(()=>bu(e),[e]),p=(0,Q.useMemo)(()=>xu(e),[e]),m=(0,Q.useMemo)(()=>{let t=vu(e.tags,`p`),n=new Map;for(let e of t){let t=e[1],r=e[3]||`Participant`;if(!t)continue;let i=n.get(r)??[];i.push(t),n.set(r,i)}return Array.from(n.entries()).sort(([e],[t])=>Cu(e,t))},[e.tags]),h=mu(f),g=hu(f),_=gu(),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(``),S=v??g.status,C=v!==null&&v!==g.status,w=(0,Q.useCallback)(async()=>{if(S)try{await _.mutateAsync({eventCoord:f,eventAuthorPubkey:e.pubkey,status:S,note:b||void 0}),y(null),x(``),r({title:`RSVP updated`})}catch{r({title:`Failed to update RSVP`,variant:`destructive`})}},[S,f,e.pubkey,b,_,r]),T=(0,Q.useCallback)(async()=>{let t=_u(e.tags,`d`)??``,n=F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t}),a=`${i}/${n}`;try{await navigator.clipboard.writeText(a),r({title:`Link copied to clipboard`})}catch{r({title:`Failed to copy link`,variant:`destructive`})}},[e,r,i]),E=n?.pubkey===e.pubkey,D=!!n&&!E;return(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto pb-16`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 pt-4 pb-5`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?t(-1):t(`/`),className:`p-1.5 -ml-1.5 rounded-full hover:bg-secondary/60 transition-colors`,"aria-label":`Go back`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsx)(`h1`,{className:`text-xl font-bold flex-1`,children:`Event Details`})]}),o?(0,$.jsx)(`div`,{className:`aspect-[2/1] w-full overflow-hidden`,children:(0,$.jsx)(`img`,{src:o,alt:a,className:`w-full h-full object-cover`,decoding:`async`})}):(0,$.jsx)(`div`,{className:`aspect-[3/1] w-full bg-gradient-to-br from-primary/15 via-primary/5 to-transparent flex items-center justify-center`,children:(0,$.jsx)(Se,{className:`size-20 text-primary/20`})}),(0,$.jsxs)(`div`,{className:`px-5 mt-5 space-y-5`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-bold leading-tight tracking-tight`,children:a}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(wu,{pubkey:e.pubkey})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Ya,{target:e,children:(0,$.jsx)(`button`,{className:`p-2 rounded-full hover:bg-secondary/60 transition-colors`,"aria-label":`Zap`,children:(0,$.jsx)(Pe,{className:`size-5`})})}),(0,$.jsx)(`button`,{className:`p-2 rounded-full hover:bg-secondary/60 transition-colors`,onClick:T,"aria-label":`Share`,children:(0,$.jsx)(we,{className:`size-5`})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-3 py-3 rounded-full bg-background/85`,children:[(0,$.jsx)(ue,{className:`size-5 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm`,children:p})]}),c&&(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-3 py-3 rounded-full bg-background/85`,children:[(0,$.jsx)(be,{className:`size-5 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm`,children:c})]})]}),u.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>(0,$.jsx)(q,{to:`/t/${e}`,children:(0,$.jsxs)(vi,{variant:`secondary`,className:`cursor-pointer hover:bg-secondary/80 text-xs px-2.5 py-0.5`,children:[`#`,e]})},e))}),(e.content||l)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(eo,{}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`About`}),e.content?(0,$.jsx)(pt,{event:e,className:`text-sm leading-relaxed text-foreground`,hideEmbedImages:!!o}):(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:l})]})]}),d.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d.map(e=>(0,$.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-4 px-3 py-3 rounded-full bg-background/85 hover:bg-secondary/60 transition-colors`,children:[(0,$.jsx)(ae,{className:`size-5 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm truncate flex-1`,children:e.replace(/^https?:\/\//,``)}),(0,$.jsx)(oe,{className:`size-4 text-muted-foreground shrink-0`})]},e))}),m.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(eo,{}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide flex items-center gap-2`,children:[(0,$.jsx)(j,{className:`size-4`}),` Participants`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:m.map(([e,t])=>t.map(t=>(0,$.jsx)(wu,{pubkey:t,label:e,size:`sm`},t)))})]})]}),D&&(0,$.jsxs)(`div`,{className:`rounded-[1.25rem] bg-background/85 p-4 space-y-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold px-1`,children:`Your RSVP`}),g.status&&!v&&(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(vi,{variant:`outline`,className:V(g.status===`accepted`&&`border-green-500 text-green-600`,g.status===`tentative`&&`border-amber-500 text-amber-600`,g.status===`declined`&&`border-destructive text-destructive`),children:g.status===`accepted`?`Going`:g.status===`tentative`?`Maybe`:`Can't Go`})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(H,{size:`sm`,variant:S===`accepted`?`default`:`outline`,className:V(`flex-1 rounded-full`,S===`accepted`&&`bg-green-600 hover:bg-green-700 text-white`),onClick:()=>y(`accepted`),children:[(0,$.jsx)(Oe,{className:`size-3.5 mr-1.5`}),` Going`]}),(0,$.jsxs)(H,{size:`sm`,variant:S===`tentative`?`default`:`outline`,className:V(`flex-1 rounded-full`,S===`tentative`&&`bg-amber-500 hover:bg-amber-600 text-white`),onClick:()=>y(`tentative`),children:[(0,$.jsx)(de,{className:`size-3.5 mr-1.5`}),` Maybe`]}),(0,$.jsxs)(H,{size:`sm`,variant:S===`declined`?`default`:`outline`,className:V(`flex-1 rounded-full`,S===`declined`&&`bg-destructive hover:bg-destructive/90 text-destructive-foreground`),onClick:()=>y(`declined`),children:[(0,$.jsx)(me,{className:`size-3.5 mr-1.5`}),` Can't Go`]})]}),S&&(0,$.jsx)(jr,{placeholder:`Add a note (optional)`,value:b,onChange:e=>x(e.target.value),className:`mt-1 resize-none rounded-xl`,rows:2}),(C||S&&!g.status)&&(0,$.jsx)(H,{size:`sm`,onClick:w,disabled:_.isPending,className:`w-full mt-1 rounded-full`,children:_.isPending?`Updating...`:g.status?`Update RSVP`:`Submit RSVP`})]}),h.total>0&&(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide flex items-center gap-2`,children:[(0,$.jsx)(j,{className:`size-4`}),` Attendees`]}),(0,$.jsx)(`div`,{className:`space-y-2.5`,children:[[`Going`,h.accepted,`border-green-500/50 bg-green-500/5 text-green-600`],[`Maybe`,h.tentative,`border-amber-500/50 bg-amber-500/5 text-amber-600`],[`Can't Go`,h.declined,`border-muted-foreground/30 bg-muted/30 text-muted-foreground`]].map(([e,t,n])=>t.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(vi,{variant:`outline`,className:V(n,`shrink-0 text-xs`),children:[e,` (`,t.length,`)`]}),(0,$.jsx)(Ri,{pubkeys:t,maxVisible:8,size:`sm`})]},e))})]})]})]})}var Eu=500;function Du(e){return e.tags.find(e=>e[0]===`title`)?.[1]||e.tags.find(e=>e[0]===`name`)?.[1]||e.tags.find(e=>e[0]===`d`)?.[1]||`Emoji pack`}function Ou(){let{nostr:e}=P(),{user:t}=$t();return I({queryKey:[`emoji-pack-index`,t?.pubkey??``],staleTime:5*6e4,gcTime:10*6e4,queryFn:async({signal:n})=>{let r=await e.query([{kinds:[is],limit:Eu}],{signal:n}).catch(()=>[]),i=[];if(t){let r=((await e.query([{kinds:[10030],authors:[t.pubkey],limit:1}],{signal:n}).catch(()=>[]))[0]?.tags??[]).filter(e=>e[0]===`a`&&e[1]).map(e=>In(e[1])).filter(e=>!!e&&e.kind===30030);if(r.length>0){let t=r.map(e=>({kinds:[is],authors:[e.pubkey],"#d":[e.identifier],limit:1}));i=await e.query(t,{signal:n}).catch(()=>[])}}let a=new Map;for(let e of[...r,...i]){let t=e.tags.find(([e])=>e===`d`)?.[1]??``,n=ns(e.pubkey,t),r=a.get(n);(!r||e.created_at>r.created_at)&&a.set(n,e)}let o=new Map;for(let[e,t]of a){let n=t.tags.find(([e])=>e===`d`)?.[1]??``,r={coord:e,name:Du(t),pubkey:t.pubkey,identifier:n};for(let e of t.tags)e[0]===`emoji`&&e[2]&&!o.has(e[2])&&o.set(e[2],r)}return o}})}function ku(e){let{data:t}=Ou();return(0,Q.useMemo)(()=>e?t?.get(e):void 0,[e,t])}function Au({url:e,name:t,className:n}){let{user:r}=$t(),i=ku(e),a=ts(i?.coord),{mutateAsync:o,isPending:s}=rs(),{toast:c}=B(),[l,u]=(0,Q.useState)(!1),d=(0,Q.useCallback)(async()=>{if(i)try{await o({pubkey:i.pubkey,identifier:i.identifier}),u(!0),c({title:`Emoji pack added`,description:i.name})}catch(e){c({title:`Couldn't add pack`,description:e instanceof Error?e.message:`Publishing failed.`,variant:`destructive`})}},[o,i,c]);if(!i)return null;let p=l||a;return(0,$.jsxs)(`div`,{className:V(`flex items-center gap-2.5 px-4 py-2.5`,n),children:[t&&(0,$.jsx)(J,{name:t,url:e,className:`size-7 shrink-0 rounded object-contain`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`From`}),(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:i.name})]}),r&&(p?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Oe,{className:`size-3.5`}),` Added`]}):(0,$.jsxs)(H,{size:`sm`,variant:`secondary`,className:`h-8 shrink-0 gap-1.5 text-xs`,onClick:d,disabled:s,children:[s?(0,$.jsx)(N,{className:`size-3.5 animate-spin`}):(0,$.jsx)(f,{className:`size-3.5`}),`Add`]}))]})}function ju({open:e,onOpenChange:t,listId:n,listKind:r=3e4,listPubkeys:i}){let[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(new Set),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),{data:p,isLoading:m,isFetching:h}=ka(a),{addToList:g,removeFromList:_}=ro(),{addToPack:v,removeFromPack:y}=io(),b=r===39089,x=b?`pack`:`list`,{data:S}=nr(i),C=(0,Q.useMemo)(()=>new Set(i),[i]),w=!!a.trim();(0,Q.useEffect)(()=>{e&&(o(``),c(0),u(new Set),setTimeout(()=>d.current?.focus(),100))},[e]),(0,Q.useEffect)(()=>{c(0)},[p?.length]);let T=(0,Q.useCallback)(async(e,t)=>{if(l.has(e))return;let r=C.has(e),i=t?.name||t?.display_name||`Anonymous`;u(t=>new Set(t).add(e));try{r?(b?await y.mutateAsync({packId:n,pubkey:e}):await _.mutateAsync({listId:n,pubkey:e}),Xt({title:`Removed ${i} from ${x}`})):(b?await v.mutateAsync({packId:n,pubkey:e}):await g.mutateAsync({listId:n,pubkey:e}),Xt({title:`Added ${i} to ${x}`}))}catch{Xt({title:r?`Failed to remove member`:`Failed to add member`,variant:`destructive`})}finally{u(t=>{let n=new Set(t);return n.delete(e),n})}},[l,C,b,x,n,g,_,v,y]),E=e=>{if(!(!w||!p)){if(e.key===`ArrowDown`)e.preventDefault(),c(e=>Math.min(e+1,p.length-1)),D(s+1);else if(e.key===`ArrowUp`)e.preventDefault(),c(e=>Math.max(e-1,0)),D(s-1);else if(e.key===`Enter`&&p[s]){e.preventDefault();let t=p[s];T(t.pubkey,t.metadata)}}},D=e=>{let t=f.current;t&&t.children[e]?.scrollIntoView({block:`nearest`})};return(0,$.jsx)(Ar,{open:e,onOpenChange:t,children:(0,$.jsxs)(Or,{className:`max-w-md max-h-[70dvh] p-0 gap-0 rounded-2xl overflow-hidden [&>button]:hidden flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3 border-b border-border shrink-0`,children:[(0,$.jsx)(wr,{className:`p-0 space-y-0 mb-3`,children:(0,$.jsx)(Tr,{className:`text-base font-bold`,children:`Edit Members`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ve,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,$.jsx)(Ln,{ref:d,value:a,onChange:e=>o(e.target.value),onKeyDown:E,placeholder:`Search to add people…`,className:`pl-9 pr-8`}),h&&(0,$.jsx)(N,{className:`absolute right-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground animate-spin`})]})]}),(0,$.jsx)(`div`,{ref:f,className:`overflow-y-auto flex-1`,children:w?m&&!p?(0,$.jsx)(`div`,{className:`py-12 text-center`,children:(0,$.jsx)(N,{className:`size-5 animate-spin mx-auto text-muted-foreground`})}):!p||p.length===0?(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:`No profiles found.`}):p.map((e,t)=>(0,$.jsx)(Mu,{pubkey:e.pubkey,metadata:e.metadata,isMember:C.has(e.pubkey),isPending:l.has(e.pubkey),isSelected:t===s,onMouseEnter:()=>c(t),onToggle:T},e.pubkey)):i.length===0?(0,$.jsxs)(`div`,{className:`py-12 text-center text-muted-foreground text-sm px-6`,children:[(0,$.jsx)(te,{className:`size-8 mx-auto mb-2 opacity-50`}),`No members yet. Search above to add people.`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(j,{className:`size-3.5`}),`Members (`,i.length,`)`]}),i.map(e=>(0,$.jsx)(Mu,{pubkey:e,metadata:S?.get(e)?.metadata,isMember:!0,isPending:l.has(e),onToggle:T},e))]})})]})})}function Mu({pubkey:e,metadata:t,isMember:n,isPending:r,isSelected:i,onMouseEnter:a,onToggle:o}){let s=t?.name||t?.display_name||`Anonymous`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 transition-colors ${n?``:`cursor-pointer`} ${i?`bg-secondary/60`:`hover:bg-secondary/30`}`,onClick:()=>{n||o(e,t)},onMouseEnter:a,children:[(0,$.jsxs)(K,{shape:W(t),className:`size-9 shrink-0`,children:[(0,$.jsx)(G,{src:t?.picture,alt:s}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-xs`,children:s[0]?.toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-medium truncate flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:s}),n&&(0,$.jsx)(Oe,{className:`size-3.5 text-green-600 dark:text-green-400 shrink-0`,"aria-label":`Already a member`})]}),t?.nip05&&(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:t.nip05})]}),(0,$.jsx)(H,{size:`sm`,variant:n?`outline`:`default`,className:`h-7 px-2.5 text-xs shrink-0 gap-1 ${n?`text-destructive hover:text-destructive hover:bg-destructive/10`:``}`,disabled:r,onClick:n=>{n.stopPropagation(),o(e,t)},children:r?(0,$.jsx)(N,{className:`size-3 animate-spin`}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{className:`size-3`}),` Remove`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{className:`size-3`}),` Add`]})})]})}function Nu({event:e,open:t,onOpenChange:i}){let{toast:a}=B(),{updateList:o}=ro(),{updatePack:s}=io(),{mutateAsync:c,isPending:l}=ar(),u=(0,Q.useRef)(null),d=e.kind===39089,f=d?`pack`:`list`,p=(0,Q.useMemo)(()=>e.tags.find(([e])=>e===`d`)?.[1]??``,[e.tags]),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!t)return;let n=t=>e.tags.find(([e])=>e===t)?.[1];h(n(`title`)||n(`name`)||``),_(n(`description`)||n(`summary`)||``),y(n(`image`)||n(`thumb`)||``)},[t,e]);let S=(0,Q.useMemo)(()=>Wt(v.trim()||void 0),[v]),C=async e=>{if(e)try{let t=await c(e);y(t[0][1])}catch{a({title:`Failed to upload image`,variant:`destructive`})}};return(0,$.jsx)(Ar,{open:t,onOpenChange:e=>!b&&i(e),children:(0,$.jsxs)(Or,{className:`max-w-md rounded-2xl`,children:[(0,$.jsx)(wr,{children:(0,$.jsxs)(Tr,{children:[`Edit `,d?`follow pack`:`list`]})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Wa,{htmlFor:`people-list-title`,children:`Title`}),(0,$.jsx)(Ln,{id:`people-list-title`,value:m,onChange:e=>h(e.target.value),placeholder:d?`Pack title…`:`List title…`,maxLength:120,disabled:b})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Wa,{htmlFor:`people-list-description`,children:`Description`}),(0,$.jsx)(jr,{id:`people-list-description`,value:g,onChange:e=>_(e.target.value),placeholder:`What is this ${f} about?`,rows:3,maxLength:500,disabled:b})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Wa,{htmlFor:`people-list-image`,children:`Cover image`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ln,{id:`people-list-image`,value:v,onChange:e=>y(e.target.value),placeholder:`https://…`,disabled:b||l,className:`flex-1`}),(0,$.jsx)(H,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u.current?.click(),disabled:b||l,"aria-label":`Upload cover image`,title:`Upload cover image`,children:l?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(n,{className:`size-4`})}),(0,$.jsx)(`input`,{ref:u,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{C(e.target.files?.[0]),e.target.value=``}})]}),S?(0,$.jsx)(`div`,{className:`rounded-lg overflow-hidden border border-border bg-muted`,children:(0,$.jsx)(`img`,{src:S,alt:`Cover preview`,className:`w-full h-32 object-cover`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}):v.trim()?(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0`}),`Enter a valid https:// image URL.`]}):null]})]}),(0,$.jsxs)(Er,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(H,{variant:`outline`,onClick:()=>i(!1),disabled:b,children:`Cancel`}),(0,$.jsxs)(H,{onClick:async()=>{if(!(!m.trim()||b)){x(!0);try{let e={title:m.trim(),description:g.trim()||void 0,image:v.trim()||void 0};d?await s.mutateAsync({packId:p,...e}):await o.mutateAsync({listId:p,...e}),a({title:`Updated "${e.title}"`}),i(!1)}catch{a({title:`Failed to update ${f}`,variant:`destructive`})}finally{x(!1)}}},disabled:!m.trim()||b||l,children:[b&&(0,$.jsx)(N,{className:`size-4 animate-spin`}),`Save`]})]})]})})}function Pu({pubkeys:e,tabKey:t}){let{isMuted:n}=Mo(),{ref:r,inView:i}=Di({threshold:0,rootMargin:`400px`}),{data:a,isLoading:o,fetchNextPage:s,hasNextPage:c,isFetchingNextPage:l}=Ao((0,Q.useMemo)(()=>e.length>0?{kinds:[1,6,16],authors:e}:null,[e]),`people-list-${t}`,e.length>0);(0,Q.useEffect)(()=>{i&&c&&!l&&s()},[i,c,l,s]);let u=(0,Q.useMemo)(()=>{if(!a?.pages)return[];let e=new Set;return a.pages.flatMap(e=>e.items).filter(t=>{let r=t.repostedBy?`repost-${t.repostedBy}-${t.event.id}`:t.event.id;return!(e.has(r)||(e.add(r),hr(t.event))||n(t.event)||t.event.kind===1&&!t.repostedBy&&zr(t.event))})},[a?.pages,n]);return e.length===0?(0,$.jsxs)(`div`,{className:`py-16 text-center text-muted-foreground`,children:[(0,$.jsx)(j,{className:`size-8 mx-auto mb-2 opacity-50`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No members in this list yet.`})]}):o&&u.length===0?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-48`}),(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})},t))}):u.length===0?(0,$.jsx)(`div`,{className:`py-16 text-center text-muted-foreground text-sm`,children:`No posts from list members yet.`}):(0,$.jsxs)(`div`,{children:[u.map(e=>(0,$.jsx)(ya,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient},mr(e))),c&&(0,$.jsx)(`div`,{ref:r,className:`flex justify-center py-6`,children:l&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]})}function Fu({pubkeys:e,membersMap:t,membersLoading:n,followedPubkeys:r,currentUserPubkey:i,canRemove:a,listId:o,listKind:s}){return n?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:Math.min(e.length,8)}).map((e,t)=>(0,$.jsx)(Bu,{},t))}):(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:e.map(e=>{let n=t?.get(e),c=r.has(e);return(0,$.jsx)(zu,{pubkey:e,metadata:n?.metadata,isFollowed:c,isSelf:e===i,canRemove:a,listId:o,listKind:s},e)})})}function Iu({event:e,orderedReplies:t,commentsLoading:n}){return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Nr,{compact:!0,replyTo:e}),n?(0,$.jsx)(Lu,{}):t.length>0?(0,$.jsx)(as,{replies:t}):(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(ke,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No comments yet. Be the first to comment.`})]})]})}function Lu(){return(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-3 w-full`}),(0,$.jsx)(X,{className:`h-3 w-3/4`})]})]})},t))})}function Ru({event:e}){let{toast:t}=B(),{user:n}=$t(),{data:r}=nn(),{lists:i,createList:o}=ro(),{data:s=[]}=no(),c=n&&e.pubkey===n.pubkey,l=e.kind===3,u=e.kind===3e4,f=e.kind===39089,p=e.kind===mt,m=(0,Q.useMemo)(()=>e.tags.find(([e])=>e===`d`)?.[1]??``,[e.tags]),h=Yt(e.pubkey).data?.metadata,g=W(h),_=h?.name||h?.display_name||`Anonymous`,v=(0,Q.useMemo)(()=>F.npubEncode(e.pubkey),[e.pubkey]),{title:y,description:b,image:x,pubkeys:S}=(0,Q.useMemo)(()=>p?{title:_?`${_}'s loved`:`Love list`,description:``,image:void 0,pubkeys:ut(e)}:Xr(e,{authorMetadata:h,authorDisplayName:_}),[e,p,h,_]),C=(0,Q.useMemo)(()=>Zr(e,S),[e,S]),w=(0,Q.useMemo)(()=>Wt(x),[x]),{data:T,isLoading:E}=nr(S),{isMuted:D}=Mo(),{data:O,isLoading:ee}=ls(e,500),te=(0,Q.useMemo)(()=>[...(O?.topLevelComments??[]).filter(e=>!D(e))].sort((e,t)=>t.created_at-e.created_at).map(e=>({reply:e,firstSubReply:(O?.getDirectReplies(e.id)??[])[0]})),[O,D]),ne=(0,Q.useMemo)(()=>new Set(r?.pubkeys??[]),[r]),k=(0,Q.useMemo)(()=>S.filter(e=>!ne.has(e)),[S,ne]),[re,A]=(0,Q.useState)(`feed`),[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(!1),[ue,M]=(0,Q.useState)(!1),de=!!(c&&(u&&i.some(e=>e.id===m)||f&&s.some(e=>e.id===m))),fe=(0,Q.useMemo)(()=>l||p?F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:``}):F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:m}),[e,m,l,p]),pe=(0,Q.useCallback)(async()=>{if(!(!n||ie)){ae(!0);try{await o.mutateAsync({title:y,description:b||void 0,pubkeys:S}),t({title:`Saved "${y}" to your lists`})}catch{t({title:`Failed to save list`,variant:`destructive`})}finally{ae(!1)}}},[n,ie,o,y,b,S,t]),me=!(c&&(l||p));return(0,$.jsxs)($.Fragment,{children:[p&&(0,$.jsx)(`div`,{className:`px-4 pt-2`,children:(0,$.jsx)(yt,{event:e})}),w&&(0,$.jsx)(`div`,{className:`w-full overflow-hidden bg-muted border-b border-border`,children:(0,$.jsx)(`img`,{src:w,alt:y,className:`w-full h-auto max-h-[300px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),(0,$.jsxs)(`div`,{className:`px-4 pt-4 pb-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(q,{to:`/${v}`,children:(0,$.jsxs)(K,{shape:g,className:`size-11`,children:[(0,$.jsx)(G,{src:h?.picture,alt:_}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:_[0]?.toUpperCase()})]})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(q,{to:`/${v}`,className:`font-bold text-[15px] hover:underline block truncate`,children:_}),h?.nip05&&(0,$.jsx)(ha,{nip05:h.nip05,pubkey:e.pubkey,className:`text-sm text-muted-foreground truncate block`})]})]}),!p&&(0,$.jsx)(`h2`,{className:`text-xl font-bold mt-4 leading-snug`,children:y}),b&&(0,$.jsx)(`p`,{className:`text-[15px] text-muted-foreground leading-relaxed mt-2 whitespace-pre-wrap`,children:b}),k.length>0&&n&&!c&&(0,$.jsxs)(`div`,{className:`mt-4 text-sm text-green-600 dark:text-green-400`,children:[k.length,` new for you`]}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-3`,children:[me&&(0,$.jsx)(us,{pubkeys:S,followedPubkeys:ne,listNoun:p?`this person's love list`:l?`this person's follow list`:`this list`,includeAuthorPubkey:l?e.pubkey:void 0,className:`flex-1`}),de&&(0,$.jsxs)(Yn,{children:[(0,$.jsx)(Gn,{asChild:!0,children:(0,$.jsxs)(H,{variant:`outline`,className:me?void 0:`flex-1`,title:f?`Edit this pack`:`Edit this list`,children:[(0,$.jsx)(a,{className:`size-4`}),`Edit`,(0,$.jsx)(ye,{className:`size-3.5 text-muted-foreground`})]})}),(0,$.jsxs)(qn,{align:`end`,children:[(0,$.jsxs)(Jn,{className:`gap-2`,onSelect:()=>setTimeout(()=>le(!0),0),children:[(0,$.jsx)(a,{className:`size-4`}),`Edit details`]}),(0,$.jsxs)(Jn,{className:`gap-2`,onSelect:()=>setTimeout(()=>se(!0),0),children:[(0,$.jsx)(j,{className:`size-4`}),`Edit members`]})]})]}),n&&!c&&!l&&!p&&(0,$.jsxs)(H,{variant:`outline`,className:me?void 0:`flex-1`,onClick:pe,disabled:ie,title:`Save a copy to your lists`,children:[ie?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(d,{className:`size-4`}),`Save`]})]})]}),(0,$.jsx)(tu,{event:e,replyLabel:`Comments`,onReply:()=>A(`comments`),onMore:()=>M(!0),className:`px-4`}),(0,$.jsxs)(La,{pinned:!0,children:[(0,$.jsx)(Oo,{label:`Feed`,active:re===`feed`,onClick:()=>A(`feed`)}),(0,$.jsx)(Oo,{label:`Members`,active:re===`members`,onClick:()=>A(`members`),children:(0,$.jsxs)(`span`,{className:`flex items-center justify-center gap-1.5`,children:[`Members`,(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,S.length,`)`]})]})}),(0,$.jsx)(Oo,{label:`Comments`,active:re===`comments`,onClick:()=>A(`comments`)})]}),(0,$.jsx)(`div`,{style:{height:20}}),re===`feed`?(0,$.jsx)(Pu,{pubkeys:S,tabKey:fe}):re===`members`?(0,$.jsx)(Fu,{pubkeys:C,membersMap:T,membersLoading:E,followedPubkeys:ne,currentUserPubkey:n?.pubkey,canRemove:de,listId:m,listKind:e.kind}):(0,$.jsx)(Iu,{event:e,orderedReplies:te,commentsLoading:ee}),de&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ju,{open:oe,onOpenChange:se,listId:m,listKind:e.kind,listPubkeys:S}),(0,$.jsx)(Nu,{event:e,open:ce,onOpenChange:le})]}),(0,$.jsx)(Na,{event:e,open:ue,onOpenChange:M})]})}function zu({pubkey:e,metadata:t,isFollowed:n,isSelf:r,canRemove:i,listId:a,listKind:o}){let s=cn(),c=(0,Q.useMemo)(()=>F.npubEncode(e),[e]),l=t?.name||t?.display_name||`Anonymous`,u=t?.about,d=W(t),{follow:f,unfollow:p,isPending:m}=rn(),{removeFromList:h}=ro(),{removeFromPack:g}=io(),{toast:_}=B(),[v,y]=(0,Q.useState)(!1),b=(0,Q.useCallback)(async t=>{t.stopPropagation(),n?await p(e):await f(e)},[n,e,f,p]),x=(0,Q.useCallback)(async t=>{if(t.stopPropagation(),a){y(!0);try{o===39089?(await g.mutateAsync({packId:a,pubkey:e}),_({title:`Removed from pack`})):(await h.mutateAsync({listId:a,pubkey:e}),_({title:`Removed from list`}))}catch{_({title:`Failed to remove`,variant:`destructive`})}finally{y(!1)}}},[a,o,e,h,g,_]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors cursor-pointer group`,onClick:()=>s(`/${c}`),children:[(0,$.jsx)(q,{to:`/${c}`,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(K,{shape:d,className:`size-11`,children:[(0,$.jsx)(G,{src:t?.picture,alt:l}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:l[0]?.toUpperCase()})]})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(q,{to:`/${c}`,className:`font-bold text-[15px] hover:underline block truncate`,onClick:e=>e.stopPropagation(),children:l}),u&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-1`,children:u})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[!r&&(0,$.jsx)(H,{variant:n?`outline`:`default`,size:`sm`,className:`shrink-0`,onClick:b,disabled:m,children:m?(0,$.jsx)(N,{className:`size-3.5 animate-spin`}):n?`Following`:`Follow`}),i&&a&&(0,$.jsx)(`button`,{onClick:x,disabled:v,className:`opacity-0 group-hover:opacity-100 p-1.5 rounded-full text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-40 transition-all`,"aria-label":`Remove from list`,children:v?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(me,{className:`size-4`})})]})]})}function Bu(){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-48`})]}),(0,$.jsx)(X,{className:`h-8 w-20 rounded-md`})]})}function Vu({target:e,open:t,onOpenChange:n,initialTab:r=`reposts`}){let[i,a]=(0,Q.useState)(r),{data:o,isLoading:s}=lr(t?e.id:void 0),{zaps:c,isLoading:l}=_t(t?e:void 0);(0,Q.useEffect)(()=>{a(r)},[r]);let d=e=>{n(e)},f=(0,Q.useMemo)(()=>Yu(o?.zaps??[],c),[o?.zaps,c]),p=o?.reposts.length??0,m=o?.quotes.length??0,h=o?.reactions.length??0,g=f.length;return(0,$.jsx)(Ar,{open:t,onOpenChange:d,children:(0,$.jsxs)(Or,{className:`max-w-[460px] rounded-2xl p-0 gap-0 border-border overflow-hidden [&>button]:hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12`,children:[(0,$.jsx)(Tr,{className:`text-base font-semibold`,children:`Post interactions`}),(0,$.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 -mr-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-secondary/60 transition-colors`,children:(0,$.jsx)(me,{className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`flex border-b border-border`,children:[{key:`reposts`,label:`Reposts`,count:p,icon:(0,$.jsx)(gi,{className:`size-4`})},{key:`quotes`,label:`Quotes`,count:m,icon:(0,$.jsx)(D,{className:`size-4`})},{key:`reactions`,label:`Reactions`,count:h,icon:(0,$.jsx)(u,{className:`size-4`})},{key:`zaps`,label:`Zaps`,count:g,icon:(0,$.jsx)(Pe,{className:`size-4`})}].map(({key:e,label:t,count:n,icon:r})=>(0,$.jsxs)(`button`,{onClick:()=>a(e),className:V(`flex-1 flex items-center justify-center gap-1 py-3 text-[13px] font-medium transition-colors relative hover:bg-secondary/40 px-1`,i===e?`text-foreground`:`text-muted-foreground`),children:[r,(0,$.jsx)(`span`,{className:`hidden min-[400px]:inline`,children:t}),n>0&&(0,$.jsx)(`span`,{className:V(`text-xs tabular-nums`,i===e?`text-foreground`:`text-muted-foreground`),children:Si(n)}),i===e&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 w-10 h-0.5 bg-primary rounded-full`})]},e))}),(0,$.jsx)(to,{className:`max-h-[60vh]`,children:s||i===`zaps`&&l&&f.length===0?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(Qu,{},t))}):i===`reposts`?(0,$.jsx)(Hu,{reposts:o?.reposts??[]}):i===`quotes`?(0,$.jsx)(Uu,{quotes:o?.quotes??[]}):i===`reactions`?(0,$.jsx)(Wu,{reactions:o?.reactions??[]}):(0,$.jsx)(Gu,{zaps:f})})]})})}function Hu({reposts:e}){return e.length===0?(0,$.jsx)(Zu,{message:`No reposts yet`}):(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:e.map((e,t)=>(0,$.jsx)(Ku,{entry:e},`${e.pubkey}-${t}`))})}function Uu({quotes:e}){return e.length===0?(0,$.jsx)(Zu,{message:`No quotes yet`}):(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:e.map((e,t)=>(0,$.jsx)(Xu,{quote:e},`${e.pubkey}-${t}`))})}function Wu({reactions:e}){let t=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.emoji);e?e.count++:t.set(n.emoji,{count:1,url:n.emojiUrl})}return Array.from(t.entries()).sort((e,t)=>t[1].count-e[1].count)},[e]),n=(0,Q.useMemo)(()=>{let e=new Map;for(let[n,{url:r}]of t)r&&fn(n)&&!e.has(r)&&e.set(r,{url:r,name:n.slice(1,-1)});return Array.from(e.values())},[t]);return e.length===0?(0,$.jsx)(Zu,{message:`No reactions yet`}):(0,$.jsxs)(`div`,{children:[t.length>1&&(0,$.jsx)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 bg-secondary/30 border-b border-border flex-wrap`,children:t.map(([e,{count:t,url:n}])=>{let r=fn(e)?e.slice(1,-1):void 0;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm`,children:[n&&r?(0,$.jsx)(J,{name:r,url:n,className:`inline-block h-5 w-5 object-contain`}):(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-medium tabular-nums`,children:t})]},e)})}),n.length>0&&(0,$.jsx)(`div`,{className:`divide-y divide-border border-b border-border`,children:n.map(e=>(0,$.jsx)(Au,{url:e.url,name:e.name},e.url))}),(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:e.map((e,t)=>(0,$.jsx)(qu,{entry:e},`${e.pubkey}-${t}`))})]})}function Gu({zaps:e}){let{format:t}=bt();if(e.length===0)return(0,$.jsx)(Zu,{message:`No zaps yet`});let n=e.reduce((e,t)=>e+t.amountSats,0);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-4 py-3 bg-secondary/30 border-b border-border`,children:[(0,$.jsx)(Pe,{className:`size-4 text-amber-500 fill-amber-500`}),(0,$.jsx)(`span`,{className:`text-sm font-bold text-amber-500`,children:t(n)}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`from `,e.length,` zap`,e.length===1?``:`s`]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:e.map(e=>(0,$.jsx)(Ju,{zap:e},e.key))})]})}function Ku({entry:e}){let t=Yt(e.pubkey),n=t.data?.metadata,r=W(n),i=n?.name||n?.display_name||`Anonymous`;return(0,$.jsxs)(q,{to:`/${(0,Q.useMemo)(()=>F.neventEncode({id:e.eventId,author:e.pubkey}),[e.eventId,e.pubkey])}`,className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(K,{shape:r,className:`size-10 shrink-0`,children:[(0,$.jsx)(G,{src:n?.picture,alt:i}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:i[0].toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-bold text-sm truncate`,children:t.data?.event?(0,$.jsx)(hn,{tags:t.data.event.tags,children:i}):i}),n?.nip05&&(0,$.jsx)(ha,{nip05:n.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ur(e.createdAt)})]}),(0,$.jsx)(je,{className:`size-4 text-muted-foreground shrink-0`})]})}function qu({entry:e}){let t=Yt(e.pubkey),n=t.data?.metadata,r=W(n),i=n?.name||n?.display_name||`Anonymous`,a=(0,Q.useMemo)(()=>F.neventEncode({id:e.eventId,author:e.pubkey}),[e.eventId,e.pubkey]),o=fn(e.emoji)?e.emoji.slice(1,-1):void 0;return(0,$.jsxs)(q,{to:`/${a}`,className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(K,{shape:r,className:`size-10 shrink-0`,children:[(0,$.jsx)(G,{src:n?.picture,alt:i}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:i[0].toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-bold text-sm truncate`,children:t.data?.event?(0,$.jsx)(hn,{tags:t.data.event.tags,children:i}):i}),n?.nip05&&(0,$.jsx)(ha,{nip05:n.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ur(e.createdAt)})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center shrink-0 bg-secondary/60 rounded-full size-8`,children:e.emojiUrl&&o?(0,$.jsx)(J,{name:o,url:e.emojiUrl,className:`inline-block h-5 w-5 object-contain`}):(0,$.jsx)(`span`,{className:`text-base leading-none`,children:e.emoji})}),(0,$.jsx)(je,{className:`size-4 text-muted-foreground shrink-0`})]})}function Ju({zap:e}){let t=Yt(e.senderPubkey),n=t.data?.metadata,r=W(n),i=n?.name||n?.display_name||`Anonymous`,a=(0,Q.useMemo)(()=>F.neventEncode({id:e.linkEventId,author:e.linkPubkey}),[e.linkEventId,e.linkPubkey]),{format:o}=bt();return(0,$.jsxs)(q,{to:`/${a}`,className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(K,{shape:r,className:`size-10 shrink-0`,children:[(0,$.jsx)(G,{src:n?.picture,alt:i}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:i[0].toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-bold text-sm truncate`,children:t.data?.event?(0,$.jsx)(hn,{tags:t.data.event.tags,children:i}):i}),n?.nip05&&(0,$.jsx)(ha,{nip05:n.nip05,pubkey:e.senderPubkey,className:`text-xs text-muted-foreground truncate`})]}),e.message&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mt-0.5`,children:e.message})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 bg-amber-500/10 text-amber-500 rounded-full px-2.5 py-1`,children:[(0,$.jsx)(Pe,{className:`size-3.5 fill-amber-500`}),(0,$.jsx)(`span`,{className:`text-xs font-bold tabular-nums`,children:o(e.amountSats,{layout:`compact`})})]}),(0,$.jsx)(je,{className:`size-4 text-muted-foreground shrink-0`})]})}function Yu(e,t){let n=e.map(e=>({key:`ln:${e.eventId}`,senderPubkey:e.senderPubkey,amountSats:e.amountSats,message:e.message,createdAt:e.createdAt,linkPubkey:e.senderPubkey,linkEventId:e.eventId})),r=t.map(e=>({key:`btc:${e.event.id}`,senderPubkey:e.senderPubkey,amountSats:e.amountSats,message:e.comment,createdAt:e.createdAt,linkPubkey:e.senderPubkey,linkEventId:e.event.id}));return[...n,...r].sort((e,t)=>t.createdAt-e.createdAt)}function Xu({quote:e}){let t=Yt(e.pubkey),n=t.data?.metadata,r=W(n),i=n?.name||n?.display_name||`Anonymous`;return(0,$.jsxs)(q,{to:`/${(0,Q.useMemo)(()=>F.neventEncode({id:e.eventId,author:e.pubkey}),[e.eventId,e.pubkey])}`,className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(K,{shape:r,className:`size-10 shrink-0`,children:[(0,$.jsx)(G,{src:n?.picture,alt:i}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:i[0].toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-bold text-sm truncate`,children:t.data?.event?(0,$.jsx)(hn,{tags:t.data.event.tags,children:i}):i}),n?.nip05&&(0,$.jsx)(ha,{nip05:n.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]}),e.content&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mt-0.5`,children:e.content}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ur(e.createdAt)})]})]})}function Zu({message:e}){return(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:e})}function Qu(){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-16`})]})]})}function $u(e){let t=Math.floor(Date.now()/1e3)-e;return t<60?`now`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function ed({aTag:e,className:t}){let{nostr:n}=P(),r=Ye(),{user:i}=$t(),{mutateAsync:a,isPending:o}=en(),[s,c]=(0,Q.useState)(``),l=(0,Q.useRef)(null),u=(0,Q.useRef)(!0),{data:d=[],isLoading:f}=I({queryKey:[`live-chat`,e],queryFn:async({signal:t})=>(await n.query([{kinds:[1311],"#a":[e],limit:200}],{signal:AbortSignal.any([t,AbortSignal.timeout(8e3)])})).sort((e,t)=>e.created_at-t.created_at),staleTime:1e4,refetchInterval:5e3});(0,Q.useEffect)(()=>{let t=new AbortController;return(async()=>{try{for await(let i of n.req([{kinds:[1311],"#a":[e],since:Math.floor(Date.now()/1e3)}],{signal:t.signal}))if(i[0]===`EVENT`){let t=i[2];r.setQueryData([`live-chat`,e],(e=[])=>e.some(e=>e.id===t.id)?e:[...e,t].sort((e,t)=>e.created_at-t.created_at))}}catch{}})(),()=>t.abort()},[n,e,r]),(0,Q.useEffect)(()=>{u.current&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[d]);let p=(0,Q.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<60;u.current=t},[]),m=async()=>{let t=s.trim();if(!(!t||!i||o))try{await a({kind:1311,content:t,tags:[[`a`,e,``,`root`]]}),c(``)}catch{}};return(0,$.jsxs)(`div`,{className:V(`flex flex-col overflow-hidden`,t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border shrink-0`,children:[(0,$.jsx)(ke,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm font-semibold`,children:`Live Chat`}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto tabular-nums`,children:[d.length,` message`,d.length===1?``:`s`]})]}),(0,$.jsx)(`div`,{ref:l,className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-3 space-y-1`,onScroll:p,children:f?(0,$.jsx)(`div`,{className:`space-y-3 p-2`,children:Array.from({length:5}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(X,{className:`size-6 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,$.jsx)(X,{className:`h-3 w-20`}),(0,$.jsx)(X,{className:`h-3 w-3/4`})]})]},t))}):d.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,$.jsx)(ke,{className:`size-8 text-muted-foreground/40 mb-2`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No messages yet`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`Be the first to say something!`})]}):d.map(e=>(0,$.jsx)(td,{event:e},e.id))}),(0,$.jsx)(`div`,{className:`border-t border-border p-3 shrink-0`,children:i?(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ln,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),m())},placeholder:`Say something...`,className:`flex-1 h-9 text-base md:text-sm`,disabled:o,maxLength:500}),(0,$.jsx)(H,{size:`sm`,onClick:m,disabled:!s.trim()||o,className:`h-9 px-3`,children:(0,$.jsx)(Ue,{className:`size-4`})})]}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-1`,children:`Log in to participate in the chat`})})]})}function td({event:e}){let t=Yt(e.pubkey).data?.metadata,n=W(t),r=Wr(t,e.pubkey),i=_n(e.pubkey,t);return(0,$.jsxs)(`div`,{className:`group flex items-start gap-2 py-1 px-1 rounded hover:bg-secondary/40 transition-colors`,children:[(0,$.jsx)(q,{to:i,className:`shrink-0 mt-0.5`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(K,{shape:n,className:`size-6`,children:[(0,$.jsx)(G,{src:t?.picture,alt:r}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[9px]`,children:r[0]?.toUpperCase()})]})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`inline`,children:[(0,$.jsx)(q,{to:i,className:`text-xs font-semibold text-primary hover:underline mr-1.5`,onClick:e=>e.stopPropagation(),children:r}),(0,$.jsx)(`span`,{className:`text-sm text-foreground break-words`,children:e.content})]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60 ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:$u(e.created_at)})]})]})}function nd(e,t){return e.find(([e])=>e===t)?.[1]}function rd(e){return e.filter(([e])=>e===`p`).map(([,e,t,n])=>({pubkey:e,relay:t,role:n})).filter(e=>tn(e.pubkey))}function id(e){switch(e){case`live`:return{label:`LIVE`,className:`bg-red-600 hover:bg-red-600 text-white border-red-600 animate-pulse`};case`ended`:return{label:`ENDED`,className:`bg-muted text-muted-foreground border-border`};case`planned`:return{label:`PLANNED`,className:`bg-blue-600/90 hover:bg-blue-600/90 text-white border-blue-600`};default:return{label:e?.toUpperCase()||`UNKNOWN`,className:`bg-muted text-muted-foreground border-border`}}}function ad(e){return new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function od({event:e}){let{config:t}=Dt(),n=cn(),{user:r}=$t(),[i,a]=(0,Q.useState)(!1),o=nd(e.tags,`title`)||`Untitled Stream`,s=nd(e.tags,`summary`),c=nd(e.tags,`streaming`),l=nd(e.tags,`recording`),u=nd(e.tags,`image`),d=nd(e.tags,`status`),f=ct(e),p=nd(e.tags,`current_participants`),m=nd(e.tags,`starts`),h=e.tags.filter(([e])=>e===`t`).map(([,e])=>e),g=(0,Q.useMemo)(()=>rd(e.tags),[e.tags]),_=id(f),v=!!(s||h.length>0||g.length>0),y=nd(e.tags,`d`)||``,b=`30311:${e.pubkey}:${y}`,x=d===`ended`&&l||c;jo({title:`${o} - ${t.appName}`}),(0,Q.useEffect)(()=>{let e=window.matchMedia(`(max-width: 1023px)`),t=e=>{document.body.style.overflow=e?`hidden`:``};t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n),document.body.style.overflow=``}},[]);let S=(0,$.jsx)(`aside`,{className:`hidden lg:flex lg:flex-col lg:w-[340px] lg:shrink-0 h-screen sticky top-0`,children:(0,$.jsx)(ed,{aTag:b,className:`h-full`})}),C=!!(s||h.length>0||g.length>0),w=v||C;Ei({rightSidebar:S,noOverscroll:!0});let T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`lg:hidden`,children:(0,$.jsx)(sd,{event:e,participants:g})}),s&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:s}),h.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map(e=>(0,$.jsxs)(q,{to:`/t/${encodeURIComponent(e)}`,className:`text-sm text-primary hover:underline`,children:[`#`,e]},e))}),g.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2 pt-2 border-t border-border`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Participants`}),(0,$.jsx)(`div`,{className:`space-y-2`,children:g.map(e=>(0,$.jsx)(ld,{pubkey:e.pubkey,role:e.role},e.pubkey))})]})]});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`main`,{className:`max-lg:flex max-lg:flex-col max-lg:livestream-height max-lg:overflow-hidden`,children:[(0,$.jsx)(Uo,{title:`Live Stream`,onBack:()=>window.history.length>1?n(-1):n(`/`),alwaysShowBack:!0,className:`shrink-0 sidebar:sticky sidebar:top-0 z-10 mt-2 mb-2 sidebar:mt-4 sidebar:mb-4`,children:(0,$.jsxs)(vi,{variant:`outline`,className:V(`ml-auto shrink-0`,_.className),children:[f===`live`&&(0,$.jsx)(Ee,{className:`size-3 mr-1`}),_.label]})}),(0,$.jsx)(`div`,{className:`lg:px-4 shrink-0`,children:x?(0,$.jsx)(wa,{src:x,poster:u,className:`w-full`,title:o}):(0,$.jsx)(`div`,{className:`aspect-video lg:rounded-2xl bg-muted flex items-center justify-center border-y lg:border border-border`,children:(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(Ee,{className:`size-8 text-muted-foreground/40 mx-auto`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f===`planned`?`Stream has not started yet`:`No stream URL available`})]})})}),(0,$.jsxs)(`div`,{className:`px-4 mt-2 sidebar:mt-4 space-y-2 sidebar:space-y-3 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-bold leading-snug`,children:o}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-muted-foreground flex-wrap`,children:[p&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(j,{className:`size-3.5`}),p,` watching`]}),m&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ue,{className:`size-3.5`}),ad(parseInt(m))]})]})]}),r&&(0,$.jsx)(cd,{event:e})]}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)(sd,{event:e,participants:g})}),w&&(0,$.jsxs)(`button`,{onClick:()=>a(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors lg:hidden`,children:[i?(0,$.jsx)(he,{className:`size-3.5`}):(0,$.jsx)(ye,{className:`size-3.5`}),i?`Hide details`:`Show details`]}),i&&(0,$.jsx)(`div`,{className:`lg:hidden`,children:T}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:T})]}),(0,$.jsx)(`div`,{className:`lg:hidden mt-2 border-t border-border flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(ed,{aTag:b,className:`h-full`})}),(0,$.jsx)(`div`,{className:`hidden lg:block h-8`})]})})}function sd({event:e,participants:t}){let n=Yt(e.pubkey),r=n.data?.metadata,i=W(r),a=Wr(r,e.pubkey),o=_n(e.pubkey,r),s=t.find(e=>e.role?.toLowerCase()===`host`),c=s?.pubkey||e.pubkey,l=Yt(c),u=l.data?.metadata,d=Wr(u,c),f=_n(c,u),p=c,m=c===e.pubkey?a:d,h=c===e.pubkey?r:u,g=c===e.pubkey?o:f,_=c===e.pubkey?n:l;return _.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-20`})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(En,{pubkey:p,asChild:!0,children:(0,$.jsx)(q,{to:g,children:(0,$.jsxs)(K,{shape:i,className:`size-10`,children:[(0,$.jsx)(G,{src:h?.picture,alt:m}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:m[0]?.toUpperCase()})]})})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(En,{pubkey:p,asChild:!0,children:(0,$.jsx)(q,{to:g,className:`font-semibold text-sm hover:underline block truncate`,children:_.data?.event?(0,$.jsx)(hn,{tags:_.data.event.tags,children:m}):m})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[h?.nip05&&(0,$.jsx)(Sa,{nip05:h.nip05,pubkey:p,className:`text-xs text-muted-foreground`,iconSize:12}),s&&(0,$.jsx)(vi,{variant:`secondary`,className:`text-[10px] px-1.5 py-0`,children:`Host`})]})]})]})}function cd({event:e}){return(0,$.jsx)(Ya,{target:e,children:(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`shrink-0 size-9 rounded-full text-amber-500 hover:text-amber-400 hover:bg-amber-500/10`,children:(0,$.jsx)(Pe,{className:`size-4`})})})}function ld({pubkey:e,role:t}){let n=Yt(e),r=n.data?.metadata,i=W(r),a=Wr(r,e),o=_n(e,r);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(En,{pubkey:e,asChild:!0,children:(0,$.jsx)(q,{to:o,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:i,className:`size-7`,children:[(0,$.jsx)(G,{src:r?.picture,alt:a}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:a[0]?.toUpperCase()})]})})}),(0,$.jsx)(En,{pubkey:e,asChild:!0,children:(0,$.jsx)(q,{to:o,className:`text-sm font-medium hover:underline truncate`,children:n.data?.event?(0,$.jsx)(hn,{tags:n.data.event.tags,children:a}):a})}),t&&(0,$.jsx)(vi,{variant:`secondary`,className:`text-[10px] px-1.5 py-0 shrink-0 ml-auto`,children:t})]})}function ud(e){let{nostr:t}=P(),n=(0,Q.useMemo)(()=>e.map(In).filter(e=>e!==void 0),[e]);return I({queryKey:[`playlist-tracks`,e],queryFn:async()=>{if(n.length===0)return[];let e=n.map(e=>({kinds:[e.kind],authors:[e.pubkey],"#d":[e.identifier],limit:1})),r=await t.query(e),i=new Map;for(let e of r){let t=e.tags.find(([e])=>e===`d`)?.[1]??``,n=`${e.kind}:${e.pubkey}:${t}`,r=i.get(n);(!r||e.created_at>r.created_at)&&i.set(n,e)}let a=[];for(let e of n){let t=`${e.kind}:${e.pubkey}:${e.identifier}`,n=i.get(t);n&&Z(n)&&a.push(n)}return a},enabled:n.length>0,staleTime:6e4})}function dd(e){return new Date(e*1e3).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function fd({event:e}){return e.kind===36787?(0,$.jsx)(pd,{event:e}):(0,$.jsx)(gd,{event:e})}function pd({event:e}){let t=cn(),n=Sr(),r=(0,Q.useMemo)(()=>Z(e),[e]),i=Yt(e.pubkey).data?.metadata,a=W(i),o=Wr(i,e.pubkey),s=_n(e.pubkey,i),{user:c}=$t(),l=lo(e.id,e),{isMuted:u}=Mo(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[g,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=yr(e.id),{data:S,isLoading:C}=ls(e,500),w=(0,Q.useMemo)(()=>(S?.topLevelComments??[]).filter(e=>!u(e)),[S?.topLevelComments,u]),T=e.tags.filter(([e])=>e===`t`).map(([,e])=>e),E=n.currentTrack?.id===e.id,D=r?.duration?Ti(r.duration):void 0,O=()=>{r&&(E&&n.isPlaying?n.pause():E?n.resume():n.playTrack(xr(e,r)))},ee=l.data?.zapAmount??0,{format:te}=bt();return(0,$.jsxs)(`main`,{className:``,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 mt-4 mb-4`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?t(-1):t(`/`),className:`p-2 -ml-2 rounded-full hover:bg-secondary transition-colors`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsx)(`h1`,{className:`text-xl font-bold truncate`,children:`Track Details`})]}),(0,$.jsxs)(`div`,{className:`px-4 flex gap-5 items-start`,children:[(0,$.jsx)(`div`,{className:`relative shrink-0 w-32 sm:w-40 aspect-square rounded-2xl overflow-hidden bg-muted shadow-lg`,children:r?.artwork&&!y?(0,$.jsx)(Ha,{url:r.artwork,encryption:r.artworkEncryption,alt:r.title,className:`w-full h-full object-cover`,onError:()=>b(!0),decoding:`async`,noticeFill:!0}):(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-primary/10`,children:(0,$.jsx)(fe,{className:`size-12 text-primary/30`})})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 pt-1`,children:[(0,$.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold leading-tight`,children:r?.title??`Untitled`}),r?.artist&&(0,$.jsx)(`p`,{className:`text-base text-muted-foreground`,children:r.artist}),!r?.artist&&(0,$.jsxs)(q,{to:s,className:`flex items-center gap-2 group`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(K,{shape:a,className:`size-6`,children:[(0,$.jsx)(G,{src:i?.picture,alt:o}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:o[0]?.toUpperCase()})]}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:text-foreground transition-colors`,children:o})]}),T.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:T.map(e=>(0,$.jsx)(q,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs px-2.5 py-1 rounded-full border border-border hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:e},e))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`button`,{onClick:O,disabled:x.status===`decrypting`,className:V(`size-11 rounded-full flex items-center justify-center transition-colors disabled:cursor-progress`,E&&n.isPlaying?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":E&&n.isPlaying?`Pause`:`Play`,children:x.status===`decrypting`?(0,$.jsx)(N,{className:`size-5 animate-spin`}):E&&n.isPlaying?(0,$.jsx)(h,{className:`size-5`,fill:`currentColor`}):(0,$.jsx)(_,{className:`size-5 ml-0.5`,fill:`currentColor`})}),(0,$.jsx)(oo,{eventId:e.id,eventPubkey:e.pubkey,eventKind:e.kind,reactedEvent:e,reactionCount:l.data?.reactions}),(0,$.jsx)(so,{event:e,children:e=>(0,$.jsx)(`button`,{className:V(`size-11 rounded-full flex items-center justify-center transition-colors`,e?`text-accent hover:bg-accent/10`:`bg-secondary/50 text-muted-foreground hover:bg-secondary`),title:`Repost`,children:(0,$.jsx)(gi,{className:`size-5`})})}),c&&c.pubkey!==e.pubkey&&(0,$.jsx)(Ya,{target:e,children:(0,$.jsx)(`button`,{className:`size-11 rounded-full bg-secondary/50 text-muted-foreground hover:bg-secondary flex items-center justify-center transition-colors`,title:`Zap`,children:(0,$.jsx)(Pe,{className:`size-5`})})}),ee>0&&(0,$.jsxs)(`button`,{onClick:()=>v(`zaps`),className:`ml-1 text-right hover:opacity-80`,children:[(0,$.jsx)(`p`,{className:`text-lg font-bold leading-tight`,children:te(ee)}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Si(l.data?.zapCount??0),` zap`,(l.data?.zapCount??0)===1?``:`s`]})]})]}),D&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1 pt-1`,children:[(0,$.jsx)(ue,{className:`size-3`}),D,r?.album&&(0,$.jsxs)($.Fragment,{children:[` · `,r.album]})]}),(0,$.jsx)(br,{trackId:e.id,className:`pt-1`})]})]}),e.content&&(0,$.jsx)(`div`,{className:`px-4 mt-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:e.content})}),(0,$.jsx)(`div`,{className:`px-4 mt-3 text-xs text-muted-foreground`,children:dd(e.created_at)}),(0,$.jsxs)(`div`,{className:`flex border-b border-border mt-4`,children:[(0,$.jsx)(`button`,{onClick:()=>v(`zaps`),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:`Top Zappers`}),(0,$.jsxs)(`button`,{onClick:()=>f(!0),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:[`Comments `,(0,$.jsx)(`span`,{className:`text-xs ml-1 opacity-70`,children:Si(w.length||0)})]}),(0,$.jsxs)(`button`,{onClick:()=>v(`reactions`),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:[`Reactions `,(0,$.jsx)(`span`,{className:`text-xs ml-1 opacity-70`,children:Si(l.data?.reactions||0)})]})]}),w.length>0&&(0,$.jsx)(`div`,{children:w.map(e=>(0,$.jsx)(ya,{event:e},e.id))}),w.length===0&&!C&&(0,$.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No comments yet`}),(0,$.jsx)(Na,{event:e,open:p,onOpenChange:m}),(0,$.jsx)(Lr,{event:e,open:d,onOpenChange:f}),g&&(0,$.jsx)(Vu,{target:e,initialTab:g,open:!!g,onOpenChange:e=>{e||v(null)}})]})}var md=3;function hd({text:e}){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=a.current;e&&i(e.scrollHeight>e.clientHeight+1)},[e]),(0,$.jsxs)(`div`,{className:`px-4 mt-4`,children:[(0,$.jsx)(`p`,{ref:a,className:V(`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,!t&&`line-clamp-[3]`),style:t?void 0:{WebkitLineClamp:md},children:e}),(r||t)&&(0,$.jsx)(`button`,{onClick:()=>n(e=>!e),className:`text-xs text-primary font-medium mt-1 hover:underline`,children:t?`Show less`:`Show more`})]})}function gd({event:e}){let t=cn(),n=Sr(),r=(0,Q.useMemo)(()=>Cr(e),[e]),[i,a]=(0,Q.useState)(!1),o=Yt(e.pubkey).data?.metadata,s=W(o),c=Wr(o,e.pubkey),l=_n(e.pubkey,o),{data:u,isLoading:d}=ud(r?.trackRefs??[]),f=(0,Q.useMemo)(()=>u?u.map(e=>{let t=Z(e);return t?xr(e,t):null}).filter(e=>e!==null):[],[u]),p=(0,Q.useMemo)(()=>{if(r?.artwork&&!i)return{url:r.artwork};if(!u||u.length===0)return;let e=Z(u[0]);if(e?.artwork)return{url:e.artwork,encryption:e.artworkEncryption}},[r?.artwork,i,u]),m=r?.trackRefs.length??0,g=r?.isAlbum??!1,v=g?`Album`:`Playlist`,y=g?E:Be,b=f.length>0&&n.playlist.length>0&&n.playlist[0]?.id===f[0]?.id&&n.playlist.length===f.length,x=()=>{f.length!==0&&(b&&n.isPlaying?n.pause():b?n.resume():n.playPlaylist(f,0))},S=e=>{f.length!==0&&n.playPlaylist(f,e)};return(0,$.jsxs)(`main`,{className:``,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 mt-4 mb-4`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?t(-1):t(`/`),className:`p-2 -ml-2 rounded-full hover:bg-secondary transition-colors`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsxs)(`h1`,{className:`text-xl font-bold truncate`,children:[v,` Details`]})]}),(0,$.jsxs)(`div`,{className:`px-4 flex gap-5 items-start`,children:[(0,$.jsx)(`div`,{className:`relative shrink-0 w-32 sm:w-40 aspect-square rounded-2xl overflow-hidden bg-muted shadow-lg`,children:p?(0,$.jsx)(Ha,{url:p.url,encryption:p.encryption,alt:r?.title??``,className:`w-full h-full object-cover`,onError:()=>a(!0),decoding:`async`,noticeFill:!0}):(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-primary/10`,children:(0,$.jsx)(y,{className:`size-12 text-primary/30`})})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold leading-tight`,children:r?.title??`Untitled`})}),g&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full bg-primary/10 text-primary w-fit`,children:[(0,$.jsx)(E,{className:`size-3`}),`Album`]}),(0,$.jsxs)(q,{to:l,className:`flex items-center gap-2 group`,children:[(0,$.jsxs)(K,{shape:s,className:`size-6`,children:[(0,$.jsx)(G,{src:o?.picture,alt:c}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:c[0]?.toUpperCase()})]}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:text-foreground transition-colors`,children:c})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[m>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Be,{className:`size-3`}),m,` track`,m===1?``:`s`]}),r?.released&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ae,{className:`size-3`}),r.released]}),r?.label&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(le,{className:`size-3`}),r.label]})]}),f.length>0&&(0,$.jsx)(`button`,{onClick:x,className:V(`flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-colors mt-1`,b&&n.isPlaying?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),children:b&&n.isPlaying?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{className:`size-4`,fill:`currentColor`}),`Pause`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{className:`size-4 ml-0.5`,fill:`currentColor`}),`Play All`]})})]})]}),r?.description&&(0,$.jsx)(hd,{text:r.description}),(0,$.jsx)(`div`,{className:`px-4 mt-3 text-xs text-muted-foreground`,children:dd(e.created_at)}),m>0&&(0,$.jsxs)(`div`,{className:`mt-6`,children:[(0,$.jsx)(`div`,{className:`px-4 mb-2`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Tracks`})}),d?(0,$.jsx)(`div`,{children:Array.from({length:Math.min(m,8)}).map((e,t)=>(0,$.jsx)(ds,{},t))}):u&&u.length>0?(0,$.jsx)(`div`,{children:u.map((e,t)=>(0,$.jsx)(_d,{event:e,index:t,onPlayFromIndex:S},e.id))}):(0,$.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No tracks could be loaded.`})]})]})}function _d({event:e,index:t,onPlayFromIndex:n}){let r=Sr(),i=(0,Q.useMemo)(()=>Z(e),[e]),[a,o]=(0,Q.useState)(!1),s=yr(e.id),c=(0,Q.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return`/`+F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!i)return null;let l=r.currentTrack?.id===e.id,u=i.duration?Ti(i.duration):void 0;return(0,$.jsxs)(q,{to:c,className:V(`flex items-center gap-3 px-4 py-2.5 transition-colors cursor-pointer group`,l?`bg-primary/5`:`hover:bg-secondary/30`),children:[(0,$.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&r.isPlaying?r.pause():l?r.resume():n(t)},disabled:s.status===`decrypting`,className:`size-8 flex items-center justify-center shrink-0 disabled:cursor-progress`,"aria-label":l&&r.isPlaying?`Pause`:`Play`,children:s.status===`decrypting`?(0,$.jsx)(N,{className:`size-4 text-primary animate-spin`}):l&&r.isPlaying?(0,$.jsx)(h,{className:`size-4 text-primary`,fill:`currentColor`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:hidden tabular-nums`,children:t+1}),(0,$.jsx)(_,{className:`size-4 text-muted-foreground hidden group-hover:block`,fill:`currentColor`})]})}),(0,$.jsx)(`div`,{className:`relative size-12 rounded-lg overflow-hidden shrink-0 bg-muted`,children:i.artwork&&!a?(0,$.jsx)(Ha,{url:i.artwork,encryption:i.artworkEncryption,alt:i.title,className:`size-full object-cover`,loading:`lazy`,onError:()=>o(!0),decoding:`async`,noticeFill:!0}):(0,$.jsx)(`div`,{className:`size-full flex items-center justify-center bg-primary/10`,children:(0,$.jsx)(fe,{className:`size-5 text-primary/30`})})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:V(`text-sm font-medium truncate`,l&&`text-primary`),children:i.title}),s.status===`ready`?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:i.artist}):(0,$.jsx)(br,{trackId:e.id})]}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:u})]})}function vd(e){return new Date(e*1e3).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function yd({event:e}){return e.kind===30054?(0,$.jsx)(bd,{event:e}):(0,$.jsx)(xd,{event:e})}function bd({event:e}){let t=cn(),n=Sr(),r=(0,Q.useMemo)(()=>Wi(e),[e]),i=Yt(e.pubkey).data?.metadata,a=W(i),o=Wr(i,e.pubkey),s=_n(e.pubkey,i),{user:c}=$t(),l=lo(e.id,e),{isMuted:u}=Mo(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[g,v]=(0,Q.useState)(null),y=yr(e.id),{data:b,isLoading:x}=ls(e,500),S=(0,Q.useMemo)(()=>(b?.topLevelComments??[]).filter(e=>!u(e)),[b?.topLevelComments,u]),C=e.tags.filter(([e])=>e===`t`).map(([,e])=>e),w=n.currentTrack?.id===e.id,T=r?.duration?Ti(r.duration):void 0,E=()=>{if(r)if(w&&n.isPlaying)n.pause();else if(w)n.resume();else{let t=Qi(e,r);t.artist=o,t.artwork??=i?.picture,n.playTrack(t)}},D=l.data?.zapAmount??0,{format:O}=bt();return(0,$.jsxs)(`main`,{className:``,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 mt-4 mb-4`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?t(-1):t(`/`),className:`p-1.5 -ml-1.5 rounded-full hover:bg-secondary/60 transition-colors`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsx)(`h1`,{className:`text-xl font-bold truncate`,children:`Episode Details`})]}),(0,$.jsxs)(`div`,{className:`px-4 flex gap-5 items-start`,children:[(0,$.jsx)(`div`,{className:`relative shrink-0 w-32 sm:w-40 aspect-square rounded-2xl overflow-hidden bg-muted shadow-lg`,children:r?.artwork?(0,$.jsx)(Ha,{url:r.artwork,encryption:r.artworkEncryption,alt:r.title,className:`w-full h-full object-cover`,decoding:`async`,noticeFill:!0}):(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-primary/10`,children:(0,$.jsx)(k,{className:`size-12 text-primary/30`})})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 pt-1`,children:[(0,$.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold leading-tight`,children:r?.title??`Untitled`}),(0,$.jsxs)(q,{to:s,className:`flex items-center gap-2 group`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(K,{shape:a,className:`size-6`,children:[(0,$.jsx)(G,{src:i?.picture,alt:o}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:o[0]?.toUpperCase()})]}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:text-foreground transition-colors`,children:o})]}),C.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:C.map(e=>(0,$.jsx)(q,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs px-2.5 py-1 rounded-full border border-border hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:e},e))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`button`,{onClick:E,disabled:y.status===`decrypting`,className:V(`size-11 rounded-full flex items-center justify-center transition-colors disabled:cursor-progress`,w&&n.isPlaying?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":w&&n.isPlaying?`Pause`:`Play`,children:y.status===`decrypting`?(0,$.jsx)(N,{className:`size-5 animate-spin`}):w&&n.isPlaying?(0,$.jsx)(h,{className:`size-5`,fill:`currentColor`}):(0,$.jsx)(_,{className:`size-5 ml-0.5`,fill:`currentColor`})}),(0,$.jsx)(oo,{eventId:e.id,eventPubkey:e.pubkey,eventKind:e.kind,reactedEvent:e,reactionCount:l.data?.reactions}),(0,$.jsx)(so,{event:e,children:e=>(0,$.jsx)(`button`,{className:V(`size-11 rounded-full flex items-center justify-center transition-colors`,e?`text-accent hover:bg-accent/10`:`bg-secondary/50 text-muted-foreground hover:bg-secondary`),title:`Repost`,children:(0,$.jsx)(gi,{className:`size-5`})})}),c&&c.pubkey!==e.pubkey&&(0,$.jsx)(Ya,{target:e,children:(0,$.jsx)(`button`,{className:`size-11 rounded-full bg-secondary/50 text-muted-foreground hover:bg-secondary flex items-center justify-center transition-colors`,title:`Zap`,children:(0,$.jsx)(Pe,{className:`size-5`})})}),D>0&&(0,$.jsxs)(`button`,{onClick:()=>v(`zaps`),className:`ml-1 text-right hover:opacity-80`,children:[(0,$.jsx)(`p`,{className:`text-lg font-bold leading-tight`,children:O(D)}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Si(l.data?.zapCount??0),` zap`,(l.data?.zapCount??0)===1?``:`s`]})]})]}),T&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1 pt-1`,children:[(0,$.jsx)(ue,{className:`size-3`}),T]}),(0,$.jsx)(br,{trackId:e.id,className:`pt-1`})]})]}),r?.description&&(0,$.jsx)(`div`,{className:`px-4 mt-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:r.description})}),(0,$.jsx)(`div`,{className:`px-4 mt-3 text-xs text-muted-foreground`,children:vd(r?.pubdate??e.created_at)}),(0,$.jsxs)(`div`,{className:`flex border-b border-border mt-4`,children:[(0,$.jsx)(`button`,{onClick:()=>v(`zaps`),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:`Top Zappers`}),(0,$.jsxs)(`button`,{onClick:()=>f(!0),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:[`Comments `,(0,$.jsx)(`span`,{className:`text-xs ml-1 opacity-70`,children:Si(S.length||0)})]}),(0,$.jsxs)(`button`,{onClick:()=>v(`reactions`),className:`flex-1 py-3 text-center text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary/40 transition-colors`,children:[`Reactions `,(0,$.jsx)(`span`,{className:`text-xs ml-1 opacity-70`,children:Si(l.data?.reactions||0)})]})]}),S.length>0&&(0,$.jsx)(`div`,{children:S.map(e=>(0,$.jsx)(ya,{event:e},e.id))}),S.length===0&&!x&&(0,$.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No comments yet`}),(0,$.jsx)(Na,{event:e,open:p,onOpenChange:m}),(0,$.jsx)(Lr,{event:e,open:d,onOpenChange:f}),g&&(0,$.jsx)(Vu,{target:e,initialTab:g,open:!!g,onOpenChange:e=>{e||v(null)}})]})}function xd({event:e}){let t=cn(),n=Sr(),r=(0,Q.useMemo)(()=>Oi(e),[e]),i=Yt(e.pubkey).data?.metadata,a=W(i),o=Wr(i,e.pubkey),s=_n(e.pubkey,i),c=yr(e.id),l=n.currentTrack?.id===e.id;return(0,$.jsxs)(`main`,{className:``,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 mt-4 mb-4`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?t(-1):t(`/`),className:`p-1.5 -ml-1.5 rounded-full hover:bg-secondary/60 transition-colors`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsx)(`h1`,{className:`text-xl font-bold truncate`,children:`Trailer Details`})]}),(0,$.jsxs)(`div`,{className:`px-4 flex gap-5 items-start`,children:[(0,$.jsx)(`div`,{className:`shrink-0 w-32 sm:w-40 aspect-square rounded-2xl overflow-hidden bg-muted shadow-lg`,children:(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-primary/10`,children:(0,$.jsx)(k,{className:`size-12 text-primary/30`})})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 pt-1`,children:[(0,$.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold leading-tight`,children:r?.title??`Untitled`}),(0,$.jsxs)(q,{to:s,className:`flex items-center gap-2 group`,children:[(0,$.jsxs)(K,{shape:a,className:`size-6`,children:[(0,$.jsx)(G,{src:i?.picture,alt:o}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:o[0]?.toUpperCase()})]}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:text-foreground transition-colors`,children:o})]}),(0,$.jsx)(`div`,{className:`pt-2`,children:(0,$.jsx)(`button`,{onClick:()=>{if(r)if(l&&n.isPlaying)n.pause();else if(l)n.resume();else{let t=aa(e,r);t.artist=o,t.artwork??=i?.picture,n.playTrack(t)}},disabled:c.status===`decrypting`,className:V(`size-11 rounded-full flex items-center justify-center transition-colors disabled:cursor-progress`,l&&n.isPlaying?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":l&&n.isPlaying?`Pause`:`Play`,children:c.status===`decrypting`?(0,$.jsx)(N,{className:`size-5 animate-spin`}):l&&n.isPlaying?(0,$.jsx)(h,{className:`size-5`,fill:`currentColor`}):(0,$.jsx)(_,{className:`size-5 ml-0.5`,fill:`currentColor`})})}),(0,$.jsx)(br,{trackId:e.id,className:`pt-1`}),r?.season&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[`Season `,r.season]})]})]}),(0,$.jsx)(`div`,{className:`px-4 mt-3 text-xs text-muted-foreground`,children:vd(e.created_at)})]})}function Sd({url:e,title:t,className:n}){return(0,$.jsx)(`object`,{data:e,type:`application/pdf`,title:t,"aria-label":t,className:V(`w-full border-0 bg-muted`,n),children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 bg-muted/30 p-6 text-center`,children:[(0,$.jsx)(Ce,{className:`size-10 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`p`,{className:`max-w-xs text-sm text-muted-foreground`,children:`This PDF can't be displayed inline.`}),(0,$.jsx)(H,{asChild:!0,variant:`outline`,children:(0,$.jsxs)(`a`,{href:e,download:!0,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(Te,{className:`mr-2 size-4`}),`Download PDF`]})})]})})}function Cd({url:e,title:t,label:n=`Read`,className:r}){let[i,a]=(0,Q.useState)(!1),o=Kt.isNativePlatform(),s=/\.pdf($|\?)/i.test(e)?void 0:`${t}.pdf`,c=()=>{qt(e)};return o?(0,$.jsxs)(H,{className:r,onClick:c,children:[(0,$.jsx)(ze,{className:`mr-2 size-4`}),n]}):(0,$.jsxs)(Ar,{open:i,onOpenChange:a,children:[(0,$.jsx)(Dr,{asChild:!0,children:(0,$.jsxs)(H,{className:r,children:[(0,$.jsx)(ze,{className:`mr-2 size-4`}),n]})}),(0,$.jsxs)(Or,{className:`flex h-[95dvh] w-screen max-w-none flex-col gap-0 rounded-none border-0 p-0 sm:h-[95vh] sm:w-[95vw] sm:max-w-[95vw] sm:rounded-xl`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-background px-4 py-3 pr-14`,children:[(0,$.jsx)(Ce,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(Tr,{className:`truncate text-base`,children:t}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsx)(H,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":`Open PDF in new tab`,children:(0,$.jsx)(oe,{className:`size-4`})}),(0,$.jsx)(H,{asChild:!0,variant:`ghost`,size:`icon`,"aria-label":`Download PDF`,children:(0,$.jsx)(`a`,{href:e,download:s,target:`_blank`,rel:`noopener noreferrer`,children:(0,$.jsx)(Te,{className:`size-4`})})})]})]}),(0,$.jsx)(Sd,{url:e,title:t,className:`min-h-0 flex-1`})]})]})}function wd({event:e,className:t}){return e.kind===34609?(0,$.jsx)(Dd,{event:e,className:t}):(0,$.jsx)(Ed,{event:e,className:t})}function Td(e,t=!0){return new Date(e*1e3).toLocaleDateString(void 0,{year:`numeric`,month:`long`,...t?{day:`numeric`}:{}})}function Ed({event:e,className:t}){let n=(0,Q.useMemo)(()=>ei(e),[e]),r=e.kind===$r,i=e.kind===ni,a=n.format===`PDF`&&!!n.fileUrl;return(0,$.jsxs)(`div`,{className:V(`mt-3 space-y-6`,t),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row`,children:[(0,$.jsx)(`div`,{className:`mx-auto shrink-0 sm:mx-0`,children:n.image?(0,$.jsx)(`img`,{src:n.image,alt:``,loading:`lazy`,decoding:`async`,className:`w-40 rounded-xl border object-cover shadow-md aspect-[2/3] sm:w-48`}):(0,$.jsx)(`div`,{className:`flex w-40 items-center justify-center rounded-xl border bg-muted aspect-[2/3] sm:w-48`,children:r?(0,$.jsx)(M,{className:`size-16 text-muted-foreground`}):(0,$.jsx)(ze,{className:`size-16 text-muted-foreground`})})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r&&n.issue&&(0,$.jsxs)(`p`,{className:`mb-1 text-sm font-medium text-primary`,children:[`Issue `,n.issue]}),(0,$.jsx)(`h1`,{className:`mb-2 text-2xl font-bold leading-tight sm:text-3xl`,children:n.title}),i&&n.authors.length>0&&(0,$.jsxs)(`p`,{className:`mb-2 text-lg text-muted-foreground`,children:[`by `,n.authors.join(`, `)]}),(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:[(0,$.jsx)(vi,{variant:`outline`,className:`text-xs`,children:n.format}),n.publishedAt&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ae,{className:`size-3.5`,"aria-hidden":`true`}),Td(n.publishedAt,r)]}),n.language&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":`true`}),n.language.toUpperCase()]}),typeof n.size==`number`&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ce,{className:`size-3.5`,"aria-hidden":`true`}),ri(n.size)]})]}),i&&n.isbn&&(0,$.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[`ISBN: `,n.isbn]}),n.topics.length>0&&(0,$.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:n.topics.map(e=>(0,$.jsxs)(vi,{variant:`secondary`,children:[`#`,e]},e))}),n.summary&&(0,$.jsx)(`p`,{className:`mb-4 text-sm leading-relaxed text-muted-foreground`,children:n.summary}),n.fileUrl&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a?(0,$.jsx)(Cd,{url:n.fileUrl,title:n.title,label:i?`Read eBook`:`Read Issue`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsxs)(`a`,{href:n.fileUrl,download:!0,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(Te,{className:`mr-2 size-4`}),`Download `,n.format]})}),(0,$.jsxs)(H,{variant:`outline`,onClick:()=>void qt(n.fileUrl),children:[(0,$.jsx)(oe,{className:`mr-2 size-4`}),`Open in browser`]})]})})]})]}),n.content.trim()&&(0,$.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-t pt-6 text-sm leading-relaxed text-muted-foreground`,children:n.content})]})}function Dd({event:e,className:t}){let{nostr:n}=P(),r=(0,Q.useMemo)(()=>ei(e),[e]),{data:i,isLoading:a}=I({queryKey:[`magazine-issues`,e.pubkey,r.identifier],queryFn:async t=>(await n.query([{kinds:[$r],"#a":[Qr(e.pubkey,r.identifier)],limit:100}],{signal:t.signal})).filter(t=>t.pubkey===e.pubkey)}),o=(0,Q.useMemo)(()=>[...i??[]].sort((e,t)=>{let n=Number(e.tags.find(([e])=>e===`published_at`)?.[1])||e.created_at;return(Number(t.tags.find(([e])=>e===`published_at`)?.[1])||t.created_at)-n}),[i]);return(0,$.jsxs)(`div`,{className:V(`mt-3 space-y-6`,t),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center`,children:[r.image?(0,$.jsx)(`img`,{src:r.image,alt:``,loading:`lazy`,decoding:`async`,className:`mx-auto size-24 rounded-xl border object-cover shadow-sm sm:mx-0`}):(0,$.jsx)(`div`,{className:`mx-auto flex size-24 items-center justify-center rounded-xl border bg-muted sm:mx-0`,children:(0,$.jsx)(M,{className:`size-10 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-center sm:text-left`,children:[(0,$.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Magazine`}),(0,$.jsx)(`h1`,{className:`text-2xl font-bold leading-tight sm:text-3xl`,children:r.title}),r.topics.length>0&&(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-center gap-1.5 sm:justify-start`,children:r.topics.map(e=>(0,$.jsxs)(vi,{variant:`secondary`,children:[`#`,e]},e))})]})]}),(r.summary||r.content.trim())&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-muted-foreground`,children:r.summary||r.content}),(0,$.jsxs)(`div`,{className:`border-t pt-6`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg font-semibold`,children:`Issues`}),a?(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-3`,children:Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{className:`w-full rounded-lg aspect-[2/3]`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]},t))}):o.length>0?(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-3`,children:o.map(e=>(0,$.jsx)(Od,{event:e},e.id))}):(0,$.jsx)(xi,{className:`border-dashed`,children:(0,$.jsx)(bi,{className:`px-8 py-12 text-center`,children:(0,$.jsx)(`p`,{className:`mx-auto max-w-sm text-muted-foreground`,children:`No issues published yet.`})})})]})]})}function Od({event:e}){let t=(0,Q.useMemo)(()=>ei(e),[e]);return(0,$.jsxs)(q,{to:`/${(0,Q.useMemo)(()=>ii(e),[e])}`,className:`group block space-y-2`,children:[t.image?(0,$.jsx)(`img`,{src:t.image,alt:``,loading:`lazy`,decoding:`async`,className:`w-full rounded-lg border object-cover shadow-sm transition-transform aspect-[2/3] group-hover:scale-[1.02]`}):(0,$.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-lg border bg-muted aspect-[2/3]`,children:(0,$.jsx)(M,{className:`size-10 text-muted-foreground`})}),(0,$.jsxs)(`div`,{children:[t.issue&&(0,$.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Issue `,t.issue]}),(0,$.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium leading-snug group-hover:underline`,children:t.title})]})]})}function kd(e,t){return e.find(([e])=>e===t)?.[1]}function Ad(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function jd(e,t){if(t.website)return t.website;for(let t of e){if(t[0]!==`web`)continue;let e=t[1];if(e)return e.replace(//g,``).replace(/\/+$/,``)}}function Md(e){let t=Ad(e.content),n=t.name||kd(e.tags,`name`)||kd(e.tags,`d`)||``,r=Wt(jd(e.tags,t)),i=``;if(r)try{i=new URL(r).hostname.replace(/^www\./,``)}catch{i=``}let a=[n,n.toLowerCase(),i].map(e=>e.trim()).filter(Boolean);return Array.from(new Set(a))}function Nd(e,t){return e.tags.some(([e,,n])=>e===`client`&&n===t)}function Pd({event:e}){let[t,n]=(0,Q.useState)(`feed`),r=(0,Q.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return`${e.kind}:${e.pubkey}:${t}`},[e]),i=(0,Q.useMemo)(()=>Md(e),[e]);return(0,$.jsxs)(xf,{title:`App`,children:[(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(ma,{pubkey:e.pubkey,icon:y,action:la(e,{created:`published an app`,updated:`updated an app`,fallback:`published an app`})}),(0,$.jsx)(ra,{event:e})]}),i.length>0&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(Ho,{clientTags:i})}),(0,$.jsxs)(La,{className:`mt-4`,children:[(0,$.jsx)(Oo,{label:`Feed`,active:t===`feed`,onClick:()=>n(`feed`)}),(0,$.jsx)(Oo,{label:`Comments`,active:t===`comments`,onClick:()=>n(`comments`)})]}),(0,$.jsx)(`div`,{style:{height:20}}),(0,$.jsx)(`div`,{className:`pb-16 sidebar:pb-0`,children:t===`feed`?(0,$.jsx)(Fd,{addr:r}):(0,$.jsx)(Ld,{event:e})})]})}function Fd({addr:e}){let{isMuted:t}=Mo(),{ref:n,inView:r}=Di({threshold:0,rootMargin:`400px`}),{data:i,isLoading:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c}=Ao((0,Q.useMemo)(()=>({kinds:[1],search:`client:${e}`}),[e]),`app-handler-${e}`);(0,Q.useEffect)(()=>{r&&s&&!c&&o()},[r,s,c,o]);let l=(0,Q.useMemo)(()=>{if(!i?.pages)return[];let n=new Set;return i.pages.flatMap(e=>e.items).filter(r=>{let i=r.repostedBy?`repost-${r.repostedBy}-${r.event.id}`:r.event.id;return!(n.has(i)||(n.add(i),!Nd(r.event,e))||hr(r.event)||t(r.event)||r.event.kind===1&&!r.repostedBy&&zr(r.event))})},[i?.pages,t,e]);return a&&l.length===0?(0,$.jsx)(Id,{}):l.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(y,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:`No posts from this app yet. Content published through it will appear here.`})]}):(0,$.jsxs)(`div`,{children:[l.map(e=>(0,$.jsx)(ya,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient},mr(e))),s&&(0,$.jsx)(`div`,{ref:n,className:`flex justify-center py-6`,children:c&&(0,$.jsx)(N,{className:`size-5 animate-spin text-muted-foreground`})})]})}function Id(){return(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-48`}),(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})},t))})}function Ld({event:e}){let{isMuted:t}=Mo(),{data:n,isLoading:r}=ls(e,500),i=(0,Q.useMemo)(()=>[...(n?.topLevelComments??[]).filter(e=>!t(e))].sort((e,t)=>t.created_at-e.created_at).map(e=>({reply:e,firstSubReply:(n?.getDirectReplies(e.id)??[])[0]})),[n,t]);return(0,$.jsx)(`div`,{children:r?(0,$.jsx)(Rd,{}):i.length>0?(0,$.jsx)(as,{replies:i}):(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center gap-3 text-center px-8`,children:[(0,$.jsx)(ke,{className:`size-8 text-muted-foreground/30`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No comments yet. Be the first to comment.`})]})})}function Rd(){return(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-3 w-full`}),(0,$.jsx)(X,{className:`h-3 w-3/4`})]})]})},t))})}function zd(e,t){let{nostr:n}=P();return I({queryKey:[`event-deletion`,e?.type===`event`?{id:e.eventId,author:e.authorHint??``}:e?{kind:e.addr.kind,pubkey:e.addr.pubkey,d:e.addr.identifier}:null],queryFn:async t=>{if(!e)return null;let r,i;if(e.type===`event`)r={kinds:[5],"#e":[e.eventId],limit:10},i=!!e.authorHint,e.authorHint&&(r.authors=[e.authorHint]);else{let t=`${e.addr.kind}:${e.addr.pubkey}:${e.addr.identifier}`;r={kinds:[5],authors:[e.addr.pubkey],"#a":[t],limit:10},i=!0}let a=AbortSignal.any([t.signal,AbortSignal.timeout(5e3)]),o=await n.query([r],{signal:a});if(o.length===0)return null;let s=[...o].sort((e,t)=>e.created_at-t.created_at)[0],c;if(e.type===`addr`)c=e.addr.kind;else{let e=new Set(s.tags.filter(([e])=>e===`k`).map(([,e])=>e));if(e.size===1){let t=Number([...e][0]);Number.isInteger(t)&&t>=0&&(c=t)}}let l=s.content.trim()||void 0;return{deletion:s,deletedKind:c,reason:l,verified:i}},enabled:t&&!!e,staleTime:300*1e3})}function Bd(e,t){return e.find(([e])=>e===t)?.[1]}function Vd(e){return{name:Bd(e.tags,`name`)||Bd(e.tags,`d`)||`Unnamed Community`,description:Bd(e.tags,`description`)||``,image:Bd(e.tags,`image`),moderators:e.tags.filter(([e,,,t])=>e===`p`&&t===`moderator`).map(([,e])=>e).filter(Boolean),relays:e.tags.filter(([e])=>e===`relay`).map(([,e,t])=>({url:e,marker:t})).filter(e=>!!e.url)}}function Hd({pubkey:e}){let{data:t}=Yt(e),n=t?.metadata,r=W(n),i=n?.name||n?.display_name||`Anonymous`;return(0,$.jsxs)(q,{to:_n(e,n),className:`flex items-center gap-3 group py-1.5`,children:[(0,$.jsxs)(K,{shape:r,className:`size-9 ring-2 ring-background`,children:[(0,$.jsx)(G,{src:n?.picture}),(0,$.jsx)(U,{className:`bg-muted text-muted-foreground text-xs`,children:i.charAt(0).toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium truncate group-hover:underline`,children:i}),n?.nip05&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:n.nip05})]}),(0,$.jsx)(vi,{variant:`secondary`,className:`text-xs shrink-0`,children:`Moderator`})]})}function Ud({event:e}){let{toast:t}=B(),n=Pa(),{name:r,description:i,image:a,moderators:o,relays:s}=(0,Q.useMemo)(()=>Vd(e),[e]);nr(o);let c=Yt(e.pubkey).data?.metadata,l=W(c),u=c?.name||c?.display_name||`Anonymous`,d=_n(e.pubkey,c),f=(0,Q.useMemo)(()=>Wt(i.match(/https?:\/\/[^\s]+/)?.[0]),[i]),p=(0,Q.useMemo)(()=>f?i.replace(RegExp(`\\s*${f.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}\\s*$`),``).trim():i,[i,f]),m=(0,Q.useCallback)(async()=>{let r=Bd(e.tags,`d`)??``,i=F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:r}),a=`${n}/${i}`;try{await navigator.clipboard.writeText(a),t({title:`Link copied to clipboard`})}catch{t({title:`Failed to copy link`,variant:`destructive`})}},[e,t,n]);return(0,$.jsxs)(`div`,{className:`mt-3 space-y-5`,children:[a?(0,$.jsxs)(`div`,{className:`relative -mx-4 aspect-[21/9] overflow-hidden`,children:[(0,$.jsx)(An,{src:a,alt:r,className:`w-full h-full object-cover`,decoding:`async`}),(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent`}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 px-4 pb-4`,children:(0,$.jsx)(`h1`,{className:`text-2xl font-bold text-white leading-tight drop-shadow-lg`,children:r})})]}):(0,$.jsxs)(`div`,{className:`relative -mx-4 aspect-[21/9] bg-gradient-to-br from-primary/15 via-primary/5 to-transparent flex items-center justify-center`,children:[(0,$.jsx)(j,{className:`size-16 text-primary/20`}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 px-4 pb-4`,children:(0,$.jsx)(`h1`,{className:`text-2xl font-bold leading-tight`,children:r})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(vi,{variant:`outline`,className:`gap-1.5`,children:[(0,$.jsx)(j,{className:`size-3.5`}),o.length,` moderator`,o.length===1?``:`s`]}),s.length>0&&(0,$.jsxs)(vi,{variant:`outline`,className:`gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5`}),s.length,` relay`,s.length===1?``:`s`]}),(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`ml-auto size-8 shrink-0`,onClick:m,children:(0,$.jsx)(we,{className:`size-3.5`})})]}),p&&(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:p}),f&&(0,$.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-primary hover:underline`,children:[(0,$.jsx)(b,{className:`size-3.5`}),f.replace(/^https?:\/\//,``).replace(/\/$/,``)]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2`,children:`Created by`}),(0,$.jsxs)(q,{to:d,className:`flex items-center gap-3 group`,children:[(0,$.jsxs)(K,{shape:l,className:V(`size-10 ring-2 ring-background`),children:[(0,$.jsx)(G,{src:c?.picture}),(0,$.jsx)(U,{className:`bg-muted text-muted-foreground`,children:u.charAt(0).toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium truncate group-hover:underline`,children:u}),c?.nip05&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:c.nip05})]})]})]}),(0,$.jsx)(eo,{}),o.length>0&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,$.jsx)(j,{className:`size-3.5`}),`Moderators`]}),(0,$.jsx)(`div`,{className:`space-y-1`,children:o.map(e=>(0,$.jsx)(Hd,{pubkey:e},e))})]})]})}function Wd({event:e,children:t,className:n}){let{isMuted:r}=Mo(),[i,a]=(0,Q.useState)(!1);return i||!r(e)?(0,$.jsx)($.Fragment,{children:t}):(0,$.jsx)(`div`,{className:V(`px-4 py-12`,n),children:(0,$.jsxs)(`div`,{className:`max-w-sm mx-auto flex flex-col items-center text-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-muted`,children:(0,$.jsx)(pe,{className:`size-5 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Muted Content`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:`This post is from a user or conversation you've muted.`})]}),(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`gap-1.5 mt-1 rounded-full px-5`,onClick:()=>a(!0),children:[(0,$.jsx)(_e,{className:`size-3.5`}),`Show Anyway`]})]})})}var Gd=5;function Kd(e){let{nostr:t}=P(),{store:n}=Zt();return I({queryKey:[`replies`,e??``],queryFn:async({signal:r})=>{if(!e)return[];let i=new Map,a=[e];for(let e=0;e0;e++){let e=[{kinds:[1,1111],"#e":a,limit:200},{kinds:[1111],"#E":a,limit:200}],[o,s]=await Promise.all([n.query(e,{signal:r}).catch(()=>[]),t.query(e,{signal:AbortSignal.any([r,AbortSignal.timeout(5e3)])})]),c=[];for(let e of[...o,...s])i.has(e.id)||(i.set(e.id,e),c.push(e.id));a=c}return[...i.values()].sort((e,t)=>e.created_at-t.created_at)},enabled:!!e,staleTime:30*1e3})}function qd(e){let{nostr:t}=P(),n=!!e&&e.kind>=3e4&&e.kind<4e4,r=n?e.tags.find(([e])=>e===`d`)?.[1]??``:``,i=n&&e?`${e.kind}:${e.pubkey}:${r}`:``;return I({queryKey:[`zap-replies`,e?.id??``,i],queryFn:async({signal:n})=>{if(!e)return[];let r=AbortSignal.any([n,AbortSignal.timeout(5e3)]),a=[{kinds:[9735],"#e":[e.id],limit:100}];i&&a.push({kinds:[9735],"#a":[i],limit:100});let o=await t.query(a,{signal:r}),s=new Map;for(let e of o)s.has(e.id)||ur(e).trim()&&dr(e)&&(fr(e)<=0||s.set(e.id,e));return[...s.values()]},enabled:!!e,staleTime:3e4})}var Jd=(0,Q.lazy)(()=>Je(()=>import(`./ArticleContent-DVjKsyqS.js`).then(e=>({default:e.ArticleContent})),__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,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,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]))),Yd=(0,Q.lazy)(()=>Je(()=>import(`./ClassifiedListingContent-CI3jo0I8.js`).then(e=>({default:e.ClassifiedListingContent})),__vite__mapDeps([110,2,1,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,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,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]))),Xd=(0,Q.lazy)(()=>Je(()=>import(`./BlobbiStateCard-BzIlF1sW.js`).then(e=>({default:e.BlobbiStateCard})),__vite__mapDeps([111,2,1,3,25,112,10,113,5,41,11,30,8,9,6,7,12,114,4,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,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,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,106,107,169,170,171,172,173,174,175,176,177,178,179,180,181]))),Zd=(0,Q.lazy)(()=>Je(()=>import(`./BlobbiSocialActions-KZzO03jP.js`).then(e=>({default:e.BlobbiSocialActions})),__vite__mapDeps([182,2,1,3,11,17,7,8,9,10,18,25,21,12,13,124,5,28,44,45,46,47,48,49,60,122,70,123,112,113,41,30,6,114,4,14,15,16,19,20,22,23,24,26,27,29,31,32,33,34,35,36,37,38,39,40,42,43,50,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,79,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,115,116,117,118,119,120,121,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,106,107,169,170,171,172,173,174,175,176,183,180,184]))),Qd=(0,Q.lazy)(()=>Je(()=>import(`./CustomNipCard-CzHkVLHj.js`).then(e=>({default:e.CustomNipCard})),__vite__mapDeps([185,1,2,3,24,7,18,23,10,20,106,107]))),$d=(0,Q.lazy)(()=>Je(()=>import(`./GitStatusCard-CICszc49.js`).then(e=>({default:e.GitStatusCard})),__vite__mapDeps([186,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,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,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,161,106,107,109]))),ef=(0,Q.lazy)(()=>Je(()=>import(`./IssueCard-B6Hx1GnM.js`).then(e=>({default:e.IssueCard})),__vite__mapDeps([187,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,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,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,161,106,107,109]))),tf=(0,Q.lazy)(()=>Je(()=>import(`./PullRequestCard-D_w7GJkC.js`).then(e=>({default:e.PullRequestCard})),__vite__mapDeps([188,2,1,3,24,7,18,23,10,20,26,25,27,28,29,76,64,9,30,8,92,161,106,107,109,4,5,6,11,12,13,14,15,16,17,19,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,101,102,103,104,105]))),nf=new Set([3,3e4,39089,mt]),rf=30311,af=new Set([36787,34139]),of=new Set([30054,30055]),sf=new Set([31922,31923]),cf=30009,lf=10008,uf=8,df=31985,ff=62;function pf(e){return e?e===34139?`Playlist Details`:af.has(e)?`Track Details`:of.has(e)?`Episode Details`:sf.has(e)?`Event Details`:e===rf?`Live Stream`:e===34609?`Magazine`:e===39731?`Magazine Issue`:e===33953?`Ebook`:e===cf?`Badge Details`:e===lf?`Badge Collection`:Qt[e]||`Post Details`:`Loading...`}function mf(e,t){return e.find(([e])=>e===t)?.[1]}function hf(e){return wi(e)??{}}function gf(e){return new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function _f(e){if(e.kind!==1111)return;let t=e.tags.find(([e])=>e===`I`)?.[1],n=e.tags.find(([e])=>e===`K`)?.[1];if(!(!t||n===`1111`))return t}function vf({eventId:e,relays:t,authorHint:n}){let{config:r}=Dt(),i=Ye(),{data:a,isLoading:o,isError:s,refetch:c,isFetching:l}=Jr(e,t,n),[u,d]=(0,Q.useState)(null),f=(0,Q.useCallback)(()=>(e&&i.removeQueries({queryKey:[`event`,e],exact:!0}),c()),[i,e,c]);jo({title:a||u?`Post Details - ${r.appName}`:`Loading... - ${r.appName}`});let p=a||u,m=pf(p?.kind);if(o)return(0,$.jsx)(xf,{title:`Loading...`,children:(0,$.jsx)(Ff,{})});if(s||!p)return(0,$.jsx)(xf,{children:(0,$.jsx)(Df,{context:{type:`event`,eventId:e,relays:t,authorHint:n},onEventFound:d,onRetry:f,isRetrying:l})});let h=_f(p);return h?(0,$.jsx)(xf,{title:m,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(ss,{uri:h,focusedEventId:p.id})})}):p.kind===cf?(0,$.jsx)(xf,{title:`Badge Details`,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(nu,{event:p})})}):Sn(p)?(0,$.jsx)(xf,{title:`Badge Collection`,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(bf,{event:p})})}):Cn(p)?(0,$.jsx)(xf,{title:`Badge Set`,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(bf,{event:p})})}):nf.has(p.kind)?(0,$.jsx)(xf,{title:m,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(Ru,{event:p})})}):(0,$.jsx)(xf,{title:m,children:(0,$.jsx)(Wd,{event:p,children:(0,$.jsx)(jf,{event:p})})})}function yf({addr:e,relays:t}){let{config:n}=Dt(),{data:r,isLoading:i,isError:a,refetch:o,isFetching:s}=qr(e,t),[c,l]=(0,Q.useState)(null),u=r||c,d=pf(e.kind);if(jo({title:u?`${u.tags.find(([e])=>e===`title`)?.[1]||u.tags.find(([e])=>e===`name`)?.[1]||d} - ${n.appName}`:`${d} - ${n.appName}`}),e.kind===33301){let t=F.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:e.identifier});return(0,$.jsx)(xf,{title:`Community invite`,children:(0,$.jsx)(`div`,{className:`px-4 pb-8`,children:(0,$.jsx)(gt,{invite:{naddr:t,linkSigner:e.pubkey,fragment:``,brand:`armada`,openUrl:`https://armada.buzz/invite/${t}`,armadaUrl:`https://armada.buzz/invite/${t}`,vectorUrl:`https://vectorapp.io/invite/${t}`,missingSecret:!0},variant:`detail`})})})}return i?(0,$.jsx)(xf,{title:d,children:(0,$.jsx)(Ff,{})}):a||!u?(0,$.jsx)(xf,{title:d,children:(0,$.jsx)(Df,{context:{type:`addr`,addr:e,relays:t},onEventFound:l,onRetry:()=>o(),isRetrying:s})}):u.kind===31990?(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(Pd,{event:u})}):nf.has(u.kind)?(0,$.jsx)(xf,{children:(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(Ru,{event:u})})}):u.kind===rf?(0,$.jsx)(od,{event:u}):af.has(u.kind)?(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(fd,{event:u})}):of.has(u.kind)?(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(yd,{event:u})}):sf.has(u.kind)?(0,$.jsx)(Tu,{event:u}):u.kind===cf?(0,$.jsx)(xf,{title:`Badge Details`,children:(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(nu,{event:u})})}):Sn(u)?(0,$.jsx)(xf,{title:`Badge Collection`,children:(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(bf,{event:u})})}):Cn(u)?(0,$.jsx)(xf,{title:`Badge Set`,children:(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(bf,{event:u})})}):(0,$.jsx)(xf,{title:d,children:(0,$.jsx)(Wd,{event:u,children:(0,$.jsx)(jf,{event:u})})})}function bf({event:e}){let{isMuted:t}=Mo(),{data:n,isLoading:r}=ls(e,500),i=(0,Q.useMemo)(()=>[...(n?.topLevelComments??[]).filter(e=>!t(e))].sort((e,t)=>e.created_at-t.created_at).map(e=>({reply:e,firstSubReply:(n?.getDirectReplies(e.id)??[])[0]})),[n,t]);return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ya,{event:e}),(0,$.jsx)(`div`,{className:`pb-16 sidebar:pb-0`,children:r?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(If,{},t))}):i.length>0?(0,$.jsx)(as,{replies:i}):(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:`No replies yet. Be the first to reply!`})})]})}function xf({children:e,title:t=`Post Details`}){let n=cn();return(0,$.jsxs)(`main`,{className:``,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 pt-4 pb-5`,children:[(0,$.jsx)(`button`,{onClick:()=>window.history.length>1?n(-1):n(`/`),className:`p-1.5 -ml-1.5 rounded-full hover:bg-secondary/60 transition-colors`,"aria-label":`Go back`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsx)(`h1`,{className:`text-xl font-bold`,children:t})]}),e]})}function Sf({value:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},className:`group flex items-center gap-1.5 min-w-0 text-left`,title:`Click to copy`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs truncate`,children:e}),(0,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground group-hover:text-foreground transition-colors`,children:t?(0,$.jsx)(Oe,{className:`size-3`}):(0,$.jsx)(d,{className:`size-3`})})]})}function Cf({pubkey:e}){let t=Yt(e),n=t.data?.metadata,r=W(n),i=Wr(n,e),a=_n(e,n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14 text-sm`,children:`Author`}),(0,$.jsx)(q,{to:a,className:`flex items-center gap-2 min-w-0 group`,children:t.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-6 rounded-full shrink-0`}),(0,$.jsx)(X,{className:`h-3.5 w-24`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{shape:r,className:`size-6 shrink-0`,children:[(0,$.jsx)(G,{src:n?.picture,alt:i}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:i[0]?.toUpperCase()})]}),(0,$.jsx)(`span`,{className:`text-xs font-medium group-hover:underline truncate`,children:t.data?.event?(0,$.jsx)(hn,{tags:t.data.event.tags,children:i}):i}),n?.nip05&&(0,$.jsx)(`span`,{className:`hidden sm:inline-flex`,children:(0,$.jsx)(Sa,{nip05:n.nip05,pubkey:e,className:`text-xs text-muted-foreground`,iconSize:12})})]})})]})}function wf(e){if(e===void 0)return`event`;let t=Jt(e);return/^[A-Z][a-z]/.test(t)?t.charAt(0).toLowerCase()+t.slice(1):t}var Tf=[{text:`Nothingness lies coiled in the heart of being — like a worm.`,author:`Jean-Paul Sartre`,source:`Being and Nothingness`},{text:`Nothing happens, nobody comes, nobody goes, it's awful!`,author:`Samuel Beckett`,source:`Waiting for Godot`},{text:`I only wish I had such eyes — to be able to see Nobody! And at that distance too!`,author:`Lewis Carroll`,source:`Through the Looking-Glass`},{text:`It cannot be seen, cannot be felt, cannot be heard, cannot be smelt. It lies behind stars and under hills, and empty holes it fills.`,author:`J. R. R. Tolkien`,source:`The Hobbit`},{text:`We are such stuff as dreams are made on, and our little life is rounded with a sleep.`,author:`William Shakespeare`,source:`The Tempest`},{text:`Loss is nothing else but change, and change is Nature's delight.`,author:`Marcus Aurelius`,source:`Meditations`},{text:`It was all a nothing and a man was nothing too.`,author:`Ernest Hemingway`,source:`A Clean, Well-Lighted Place`},{text:`Only in silence the word, only in dark the light, only in dying life: bright the hawk's flight on the empty sky.`,author:`Ursula K. Le Guin`,source:`A Wizard of Earthsea`},{text:`We shape clay into a pot, but it is the emptiness inside that holds whatever we want.`,author:`Laozi`,source:`Tao Te Ching`},{text:`And if you gaze long into an abyss, the abyss also gazes into you.`,author:`Friedrich Nietzsche`,source:`Beyond Good and Evil`},{text:`All that we see or seem is but a dream within a dream.`,author:`Edgar Allan Poe`,source:`A Dream Within a Dream`},{text:`It is not down in any map; true places never are.`,author:`Herman Melville`,source:`Moby-Dick`},{text:`Nobody is my name. My father and mother call me Nobody.`,author:`Homer`,source:`The Odyssey`}];function Ef(){let e=(0,Q.useMemo)(()=>Tf[Math.floor(Math.random()*Tf.length)],[]);return(0,$.jsxs)(`div`,{className:`pt-2 px-4 flex flex-col items-center`,children:[(0,$.jsxs)(`p`,{className:`max-w-sm font-serif text-sm italic leading-6 text-foreground/60 tracking-wide text-center`,children:[(0,$.jsx)(`span`,{className:`text-2xl leading-none align-bottom text-muted-foreground/25 font-serif mr-1`,"aria-hidden":!0,children:`“`}),e.text,(0,$.jsx)(`span`,{className:`text-2xl leading-none align-bottom text-muted-foreground/25 font-serif ml-1`,"aria-hidden":!0,children:`”`})]}),(0,$.jsxs)(`p`,{className:`mt-2 font-serif text-xs text-muted-foreground/70 tracking-wide text-center`,children:[`— `,e.author,`, `,(0,$.jsx)(`cite`,{children:e.source})]})]})}function Df({context:e,onEventFound:t,onRetry:n,isRetrying:r=!1}){let{nostr:a}=P(),[o,s]=(0,Q.useState)(``),[c,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),h=e.type===`event`?e.authorHint:e.addr.pubkey,{data:g,isLoading:_}=zd(e.type===`event`?{type:`event`,eventId:e.eventId,authorHint:e.authorHint}:{type:`addr`,addr:e.addr},!0),v=(0,Q.useCallback)(async n=>{let r=n.trim();if(r){!r.startsWith(`wss://`)&&!r.startsWith(`ws://`)&&(r=`wss://${r}`,s(r)),u(!0),f(null);try{let n=a.relay(r),i=AbortSignal.timeout(8e3),o;o=e.type===`event`?[{ids:[e.eventId],limit:1}]:[{kinds:[e.addr.kind],authors:[e.addr.pubkey],"#d":[e.addr.identifier],limit:1}];let s=await n.query(o,{signal:i});s.length>0?t(s[0]):f(`Event not found on ${r}`)}catch{f(`Failed to connect to ${r}`)}finally{u(!1)}}},[a,e,t]);return(0,$.jsx)(`div`,{className:`px-4 py-12`,children:(0,$.jsxs)(`div`,{className:`max-w-md mx-auto space-y-6`,children:[_?(0,$.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,$.jsx)(X,{className:`size-14 rounded-full mx-auto mb-2`}),(0,$.jsx)(X,{className:`h-6 w-40 mx-auto`}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-full max-w-xs mx-auto`}),(0,$.jsx)(X,{className:`h-4 w-3/4 max-w-56 mx-auto`})]})]}):(0,$.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,$.jsx)(`div`,{className:`inline-flex items-center justify-center size-14 rounded-full bg-muted/60 mb-2`,children:g?(0,$.jsx)(l,{className:`size-7 text-muted-foreground`}):(0,$.jsx)(Fe,{className:`size-7 text-muted-foreground`})}),(0,$.jsx)(`h2`,{className:`text-xl font-bold`,children:g?`Event deleted`:`Event not found`}),g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:g.verified?`This ${wf(g.deletedKind)} was deleted by its author on ${gf(g.deletion.created_at)}.`:`A deletion request for this ${wf(g.deletedKind)} was published on ${gf(g.deletion.created_at)}, so it was likely removed by its author.`}),g.reason&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground italic break-words`,children:[`“`,g.reason,`”`]})]}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:h?`This event couldn't be loaded from your connected relays or the author's outbox relays. It may exist on a relay neither of you are connected to.`:`This event couldn't be loaded from your connected relays. It may exist on a relay you're not connected to.`})]}),!_&&n&&!g?.verified&&(0,$.jsxs)(H,{className:`rounded-full w-full`,onClick:n,disabled:r,children:[r?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(i,{className:`size-4`}),`Try again`]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/30 p-4 space-y-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`font-semibold text-xs uppercase tracking-wider text-muted-foreground mb-2`,children:`Event details`}),e.type===`event`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14`,children:`ID`}),(0,$.jsx)(Sf,{value:e.eventId})]})}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14`,children:`Kind`}),(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:e.addr.kind})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14`,children:`Pubkey`}),(0,$.jsx)(Sf,{value:e.addr.pubkey})]}),e.addr.identifier&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14`,children:`d-tag`}),(0,$.jsx)(Sf,{value:e.addr.identifier})]})]}),e.relays&&e.relays.length>0&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-14`,children:`Hints`}),(0,$.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.relays.join(`, `)})]}),h&&(0,$.jsx)(Cf,{pubkey:h})]}),(0,$.jsx)(Ef,{}),!_&&!g?.verified&&(0,$.jsxs)(Wn,{open:p,onOpenChange:m,children:[(0,$.jsx)(Un,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,$.jsx)(je,{className:`size-4 transition-transform duration-200 ${p?`rotate-90`:``}`}),(0,$.jsx)(`span`,{children:`Try another relay`})]})}),(0,$.jsxs)(Hn,{className:`pt-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ln,{value:o,onChange:e=>s(e.target.value),placeholder:`wss://relay.example.com`,className:`flex-1 font-mono text-base md:text-xs h-9 rounded-full`,disabled:c,onKeyDown:e=>{e.key===`Enter`&&v(o)}}),(0,$.jsxs)(H,{size:`sm`,onClick:()=>v(o),disabled:c||!o.trim(),className:`shrink-0 h-9 rounded-full`,children:[c?(0,$.jsx)(N,{className:`size-4 animate-spin`}):(0,$.jsx)(Ee,{className:`size-4`}),(0,$.jsx)(`span`,{className:`ml-1.5`,children:`Try`})]})]}),d&&(0,$.jsxs)(`p`,{className:`text-xs text-destructive flex items-center gap-1.5`,children:[(0,$.jsx)(Fe,{className:`size-3 shrink-0`}),d]})]})]})]})})}function Of({event:e}){let t=(0,Q.useMemo)(()=>hf(e.tags),[e.tags]),n=mf(e.tags,`title`),r=e.tags.filter(([e])=>e===`t`).map(([,e])=>e),i=mf(e.tags,`duration`);return(0,$.jsxs)(`div`,{className:`mt-3`,children:[t.url&&(0,$.jsx)(tt,{src:t.url,poster:t.thumbnail,encryption:t.encryption,dim:t.dim,blurhash:t.blurhash,title:n??void 0}),n&&(0,$.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug mt-3 break-words`,children:n}),e.content&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed mt-1 break-words`,children:e.content}),(r.length>0||i)&&(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-2`,children:r.slice(0,8).map(e=>(0,$.jsxs)(q,{to:`/t/${encodeURIComponent(e)}`,className:`text-sm text-primary hover:underline`,children:[`#`,e]},e))})]})}function kf({event:e}){let t=(0,Q.useMemo)(()=>hf(e.tags),[e.tags]),n=mf(e.tags,`title`),r=e.tags.filter(([e])=>e===`t`).map(([,e])=>e);return(0,$.jsxs)(`div`,{className:`mt-3`,children:[n&&(0,$.jsx)(`p`,{className:`text-[15px] leading-relaxed break-words mb-2`,children:n}),t.url&&(0,$.jsx)(tt,{src:t.url,poster:t.thumbnail,encryption:t.encryption,title:n??void 0}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:r.slice(0,8).map(e=>(0,$.jsxs)(q,{to:`/t/${encodeURIComponent(e)}`,className:`text-sm text-primary hover:underline`,children:[`#`,e]},e))})]})}function Af({event:e}){let t=e.tags.find(([e])=>e===`rating`)?.[1];if(!t)return null;let n=parseFloat(t);if(isNaN(n)||n<0||n>1)return null;let r=Math.round(n*5);return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-3`,children:[[...[,,,,,]].map((e,t)=>(0,$.jsx)(v,{className:V(`size-5`,tRa(za(f)),[f]),m=a.state,h=m?.nsiteAutoPlay?m.nsiteAutoPlayTs||1:0;(0,Q.useEffect)(()=>{m?.nsiteAutoPlay&&o(a.pathname,{replace:!0,state:{}})},[m?.nsiteAutoPlay]),(0,Q.useEffect)(()=>{r.refetchQueries({queryKey:[`author`,e.pubkey]})},[e.pubkey,r]);let g=l?.nip05,_=_n(e.pubkey,l),v=(0,Q.useMemo)(()=>e.kind===9735?dr(e):``,[e]),b=Yt(v||void 0),x=b.data?.metadata,S=W(x),C=Wr(x,v),w=_n(v,x),T=xt(e.kind===8333?e:void 0),E=ht(e),D=(0,Q.useMemo)(()=>e.kind===1?ga(e.content):void 0,[e]),[O,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!D||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=setTimeout(()=>{ba(e.id),ee(!0)},600);return()=>clearTimeout(t)},[D,e.id]),(0,Q.useEffect)(()=>{if(!O)return;let e=setTimeout(()=>ee(!1),Xi);return()=>clearTimeout(e)},[O]);let te=(0,Q.useMemo)(()=>Kr(e),[e]),ne=(0,Q.useCallback)(async()=>{await Hr(`${i}/${te}`)===`copied`&&Xt({title:`Link copied to clipboard`})},[te,i]),k=e.kind===34236,A=e.kind===1068,ie=e.kind===1018,j=e.kind===37516,ae=e.kind===7516,oe=e.kind===3367,se=e.kind===2473,le=e.kind===12473,ue=e.kind===30621,M=e.kind===3||e.kind===3e4||e.kind===39089,de=e.kind===10002,fe=e.kind===30030,pe=e.kind===30023,N=e.kind===vt,me=ti.has(e.kind),he=e.kind===37381,ge=e.kind===1063,_e=e.kind===36767||e.kind===16767,ve=e.kind===1222||e.kind===1244,ye=e.kind===7,be=e.kind===6||e.kind===16,xe=e.kind===20,Se=e.kind===21||e.kind===22,Ce=e.kind===34550,Te=e.kind===30617,Ee=e.kind===30618,Oe=e.kind===1617,Ae=e.kind===1618,je=e.kind===1619,Me=e.kind===1621,Ne=e.kind>=1630&&e.kind<=1633,Fe=e.kind===30817,Ie=pr(e.kind),Le=e.kind===32267,Re=e.kind===30063,ze=e.kind===3063,Be=e.kind===31990,Ve=e.kind===4,He=e.kind===8211,Ue=e.kind===mt,We=e.kind===9802,Ge=e.kind===yi,Ke=e.kind===39701,Je=e.kind===30315,P=e.kind===30312||e.kind===30313,F=e.kind===st,I=e.kind===rt,Xe=e.kind===33863,Ze=e.kind===hi,Qe=e.kind===mi,et=e.kind===ff,tt=e.kind===9735,ct=e.kind===8333,lt=e.kind===0,ut=e.kind===31124,gt=e.kind===uf,St=!k&&!A&&!ie&&!j&&!ae&&!oe&&!se&&!ue&&!M&&!de&&!fe&&!pe&&!N&&!me&&!he&&!ge&&!_e&&!ve&&!ye&&!be&&!xe&&!Se&&!Ce&&!(Te||Ee||Oe||Ae||je||Me||Ne||Fe||Ie)&&!Le&&!Re&&!ze&&!Be&&!Ve&&!He&&!Ue&&!We&&!Ge&&!Ke&&!Je&&!P&&!F&&!I&&!Xe&&!Ze&&!Qe&&!et&&!tt&&!ct&&!lt&&!ut&&!gt,Et=St&&e.kind!==1&&e.kind!==11&&e.kind!==1111&&e.kind!==1311,{data:z}=lo(e.id,e),{data:Ot}=lr(e.id),{format:kt}=bt(),At=(0,Q.useMemo)(()=>{if(!Ot?.reactions.length)return[];let e=new Map;for(let t of Ot.reactions){let n=t.emoji,r=e.get(n);if(r)r.count++;else{let r=fn(n)&&t.emojiUrl?{content:n,url:t.emojiUrl,name:n.slice(1,-1)}:{content:n};e.set(n,{emoji:r,count:1})}}return Array.from(e.values()).sort((e,t)=>t.count-e.count).slice(0,3).map(e=>e.emoji)},[Ot?.reactions]),jt=e.kind===1,Mt=e.kind===1111,Nt=(0,Q.useMemo)(()=>{if(jt)return;if(!Mt)return e;let t=e.tags.find(([e])=>e===`K`)?.[1],n=e.tags.find(([e])=>e===`P`)?.[1],r=e.tags.find(([e])=>e===`A`)?.[1],i=e.tags.find(([e])=>e===`E`)?.[1],a=e.tags.find(([e])=>e===`I`)?.[1];if(a){if(t===`#`)return a;try{return new URL(a)}catch{return a}}let o=t?parseInt(t,10):0,s=n??``,c=r??e.tags.find(([e])=>e===`a`)?.[1];if(c){let e=In(c),t=e?.identifier??``;return{id:i??``,kind:o||(e?.kind??0),pubkey:s||(e?.pubkey??``),content:``,created_at:0,sig:``,tags:[[`d`,t]]}}return{id:i??``,kind:o,pubkey:s,content:``,created_at:0,sig:``,tags:[]}},[e,jt,Mt]),{data:Pt,isLoading:Ft}=Kd(jt?e.id:void 0),{data:It,isLoading:Lt}=ls(Nt,500,e.kind===37516?[7516]:void 0),{data:Rt}=qd(e),{zaps:zt}=_t(e),Bt=jt?Ft:Lt,Vt=(0,Q.useMemo)(()=>{let e=[],n=new Set;for(let r of Rt??[]){if(n.has(r.id))continue;let i=dr(r);t({...r,pubkey:i||r.pubkey,content:ur(r)})||(n.add(r.id),e.push({event:r,children:[]}))}for(let r of zt)r.comment.trim()&&(n.has(r.event.id)||t(r.event)||(n.add(r.event.id),e.push({event:r.event,children:[]})));return e},[Rt,zt,t]),Ht=(0,Q.useMemo)(()=>{let e=jt?Pt:It?.allComments;return e&&e.filter(e=>!t(e))},[jt,Pt,It?.allComments,t]),Ut=(0,Q.useMemo)(()=>Ht?n(Ht):new Set,[Ht,n]),Wt=(0,Q.useCallback)(()=>{if(!Ht||Ht.length===0)return[];if(jt){let t=new Map,n=[];for(let r of Ht){if(!zr(r))continue;let i=Fr(r);if(!i||i===e.id)n.push(r);else{let e=t.get(i)||[];e.push(r),t.set(i,e)}}let r=e=>{let n=t.get(e.id)??[];if(n.length<=1)return{event:e,children:n.map(e=>r(e))};let[i,...a]=n;return{event:e,children:[r(i)],hiddenChildren:a.map(e=>r(e))}};return n.map(e=>r(e))}let n=e=>{let t=It?.getDirectReplies(e.id)??[];if(t.length<=1)return{event:e,children:t.map(e=>n(e))};let[r,...i]=t;return{event:e,children:[n(r)],hiddenChildren:i.map(e=>n(e))}};return Mt?(It?.getDirectReplies(e.id)??[]).filter(e=>!t(e)).map(e=>n(e)):[...(It?.topLevelComments??[]).filter(e=>!t(e))].sort((e,t)=>e.created_at-t.created_at).map(e=>n(e))},[jt,Mt,Ht,e.id,It,t]),Gt=(0,Q.useMemo)(()=>{let e=Wt();return Vt.length===0?e:[...e,...Vt].sort((e,t)=>e.event.created_at-t.event.created_at)},[Wt,Vt]),{visibleRoots:Kt,floodedRoots:qt}=(0,Q.useMemo)(()=>{if(Ut.size===0)return{visibleRoots:Gt,floodedRoots:[]};let e=[],t=[];for(let n of Gt)(Ut.has(n.event.id)?t:e).push(n);return{visibleRoots:e,floodedRoots:t}},[Gt,Ut]),{config:Jt}=Dt(),Zt=Jt.nip85StatsPubkey;(0,Q.useEffect)(()=>{if(!Ht||Ht.length===0||!Zt)return;let t=new Map;for(let n of Ht){let r=jt?Fr(n)??e.id:n.tags.find(([e])=>e===`e`)?.[1];r&&t.set(r,(t.get(r)??0)+1)}for(let[e,n]of t){let t=r.getQueryData([`nip85-event-stats`,e,Zt]);(!t||t.commentCount===0)&&r.setQueryData([`nip85-event-stats`,e,Zt],e=>({commentCount:Math.max(e?.commentCount??0,n),repostCount:e?.repostCount??0,reactionCount:e?.reactionCount??0,zapCount:e?.zapCount??0,zapAmount:e?.zapAmount??0}))}},[Ht,jt,e.id,r,Zt]);let[Qt,B]=(0,Q.useState)(!1),[H,en]=(0,Q.useState)(!1),[tn,nn]=(0,Q.useState)(!1),[rn,an]=(0,Q.useState)(`reposts`),{user:on}=$t(),sn=(0,Q.useMemo)(()=>ut?Po(e):null,[e,ut]),un=ut&&!!on&&on.pubkey!==e.pubkey&&!!sn?.socialOpen&&sn?.stage!==`egg`,{state:pn,trigger:J}=Ba(),vn=(0,Q.useCallback)(e=>{let t=Va[e];t&&J(t)},[J]),yn=(0,Q.useMemo)(()=>St||ye||be||tt||ct||ie?Mr(e):void 0,[e,St,ye,be,tt,ct,ie]),bn=yn?.id,xn=(0,Q.useMemo)(()=>{if(Mt)return e.tags.find(([e])=>e===`I`)?.[1]},[e,Mt]),Sn=(0,Q.useMemo)(()=>{if(!Mt)return qo(e)},[e,Mt]),Cn=(0,Q.useMemo)(()=>{if(!Mt||e.tags.find(([e])=>e===`K`)?.[1]!==`0`)return;let t=(e.tags.find(([e])=>e===`A`)??e.tags.find(([e])=>e===`a`))?.[1];return In(t)?.pubkey},[e,Mt]),wn=(0,Q.useMemo)(()=>{if(!Mt||e.tags.find(([e])=>e===`K`)?.[1]!==`34550`)return;let t=(e.tags.find(([e])=>e===`A`)??e.tags.find(([e])=>e===`a`))?.[1];return In(t)},[e,Mt]),Tn=(0,Q.useMemo)(()=>{if(ae){let t=e.tags.find(([e])=>e===`a`),n=In(t?.[1]);return n?{kind:n.kind,pubkey:n.pubkey,identifier:n.identifier,relayHint:t?.[2]||void 0}:void 0}if(!Mt||xn||Cn||wn)return;let t=e.tags.find(([e])=>e===`A`)??e.tags.find(([e])=>e===`a`),n=In(t?.[1]);if(!n)return;let r=t?.[0]===`A`?e.tags.find(([e])=>e===`K`)?.[1]:e.tags.find(([e])=>e===`k`)?.[1],i=r?parseInt(r,10):n.kind;if(!isNaN(i))return{kind:i,pubkey:n.pubkey,identifier:n.identifier,relayHint:t?.[2]||void 0}},[e,Mt,ae,xn,Cn,wn]),Dn=(0,Q.useRef)(null),On=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!bn||!Dn.current)return;let e=Dn.current;e.scrollIntoView({block:`start`}),e.style.transition=`background-color 0.3s ease`,e.style.backgroundColor=`hsl(var(--primary) / 0.06)`;let t=setTimeout(()=>{e.style.backgroundColor=``,setTimeout(()=>{e.style.transition=``},300)},1500),n=On.current;if(!n)return()=>clearTimeout(t);let r=new ResizeObserver(()=>{e.scrollIntoView({block:`start`})});r.observe(n);let i=setTimeout(()=>r.disconnect(),5e3);return()=>{r.disconnect(),clearTimeout(i),clearTimeout(t)}},[bn]);let Y=e.tags.find(([e])=>e===`client`),kn=e=>{an(e),nn(!0)},An=(Ot?.quotes.length??0)||(z?.quotes??0),jn=(z?.reposts??0)+(z?.quotes??0),Mn=z?.reposts||An||z?.reactions||z?.zapCount?(0,$.jsxs)(`div`,{className:`flex items-center gap-x-3 py-2 sidebar:py-2.5 mt-2 sidebar:mt-3 text-xs sidebar:text-sm text-muted-foreground`,children:[z?.reposts?(0,$.jsxs)(`button`,{onClick:()=>kn(`reposts`),className:`shrink-0 whitespace-nowrap hover:underline transition-colors`,children:[(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:Si(z.reposts)}),` `,`Repost`,z.reposts===1?``:`s`]}):null,An?(0,$.jsxs)(`button`,{onClick:()=>kn(`quotes`),className:`shrink-0 whitespace-nowrap hover:underline transition-colors`,children:[(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:Si(An)}),` `,`Quote`,An===1?``:`s`]}):null,z?.reactions?(0,$.jsxs)(`button`,{onClick:()=>kn(`reactions`),className:`shrink-0 whitespace-nowrap inline-flex items-center gap-1 hover:[&>span:first-child]:underline transition-colors`,children:[(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:Si(z.reactions)}),At.length>0?(0,$.jsx)(`span`,{className:`inline-flex items-center`,children:At.map((e,t)=>(0,$.jsx)(mn,{emoji:e,className:`h-4 w-4 object-contain leading-none`},t))}):`Like${z.reactions===1?``:`s`}`]}):null,z?.zapCount?(0,$.jsxs)(`button`,{onClick:()=>kn(`zaps`),className:`shrink-0 whitespace-nowrap hover:underline transition-colors`,children:[(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:Si(z.zapCount)}),` `,`Zap`,z.zapCount===1?``:`s`]}):null,(0,$.jsxs)(`span`,{className:`ml-auto min-w-0 flex items-center gap-1.5`,children:[Y?.[1]&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{to:`/client/${encodeURIComponent(Y[1])}`,className:`hover:underline truncate min-w-0`,onClick:e=>e.stopPropagation(),children:Y[1]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`})]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:gf(e.created_at)})]})]}):(0,$.jsxs)(`div`,{className:`py-2 sidebar:py-2.5 mt-2 sidebar:mt-3 text-xs sidebar:text-sm text-muted-foreground flex items-center gap-1.5`,children:[Y?.[1]&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{to:`/client/${encodeURIComponent(Y[1])}`,className:`hover:underline truncate min-w-0`,onClick:e=>e.stopPropagation(),children:Y[1]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`})]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:gf(e.created_at)})]});return(0,$.jsxs)(`div`,{children:[xn&&(0,$.jsx)(Ir,{identifier:xn}),Cn&&(0,$.jsx)(Br,{pubkey:Cn}),wn&&(0,$.jsx)(Vr,{addr:wn}),Tn&&!bn&&(0,$.jsx)(Nf,{addr:Tn,relays:Tn.relayHint?[Tn.relayHint]:void 0}),Sn&&(0,$.jsx)(Ir,{identifier:`isbn:${Sn}`}),bn&&(0,$.jsx)(`div`,{ref:On,children:(0,$.jsx)(Pf,{eventId:bn,relays:yn?.relayHint?[yn.relayHint]:void 0,authorHint:yn?.authorHint,collapseAfter:ye||be||tt||ct||ie?0:void 0})}),ye&&(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-pink-500/10 shrink-0 text-xl leading-none`,children:(0,$.jsx)(gn,{content:e.content,tags:e.tags,className:`h-6 w-6 object-contain`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:c.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-6 rounded-full shrink-0`}),(0,$.jsx)(X,{className:`h-4 w-28`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:u,className:`size-6`,children:[(0,$.jsx)(G,{src:l?.picture,alt:d}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:d[0]?.toUpperCase()})]})})}),(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`font-bold text-sm hover:underline truncate`,children:c.data?.event?(0,$.jsx)(hn,{tags:c.data.event.tags,children:d}):d})}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`reacted`})]})})]}),(()=>{let t=dn(e);return t?.url?(0,$.jsx)(Au,{url:t.url,name:t.name,className:`mt-2 rounded-xl border border-border bg-secondary/30 px-3 py-2.5`}):null})(),Mn,(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`-mx-4 px-4`}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]}),be&&(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-accent/10 shrink-0`,children:(0,$.jsx)(gi,{className:`size-5 text-accent`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:c.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-6 rounded-full shrink-0`}),(0,$.jsx)(X,{className:`h-4 w-28`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:u,className:`size-6`,children:[(0,$.jsx)(G,{src:l?.picture,alt:d}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:d[0]?.toUpperCase()})]})})}),(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`font-bold text-sm hover:underline truncate`,children:c.data?.event?(0,$.jsx)(hn,{tags:c.data.event.tags,children:d}):d})}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`reposted`})]})})]}),Mn,(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`-mx-4 px-4`}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]}),tt&&(()=>{let t=Math.floor(fr(e)/1e3),n=ur(e);return(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-amber-500/10 shrink-0`,children:(0,$.jsx)(Pe,{className:`size-5 text-amber-500 fill-amber-500`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:b.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-6 rounded-full shrink-0`}),(0,$.jsx)(X,{className:`h-4 w-28`})]}):(0,$.jsxs)($.Fragment,{children:[v&&(0,$.jsx)(En,{pubkey:v,asChild:!0,children:(0,$.jsx)(q,{to:w,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:S,className:`size-6`,children:[(0,$.jsx)(G,{src:x?.picture,alt:C}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:C[0]?.toUpperCase()})]})})}),v&&(0,$.jsx)(En,{pubkey:v,asChild:!0,children:(0,$.jsx)(q,{to:w,className:`font-bold text-sm hover:underline truncate`,children:b.data?.event?(0,$.jsx)(hn,{tags:b.data.event.tags,children:C}):C})}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`zapped`}),t>0&&(0,$.jsx)(`span`,{className:`text-sm font-semibold text-amber-500 shrink-0`,children:kt(t)})]})})]}),n&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground italic pl-[52px]`,children:[`"`,n,`"`]}),Mn,(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`-mx-4 px-4`}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]})})(),ct&&(()=>{let t=dt(e),n=T?.amountSats??t,r=T===void 0,i=T===null,a=e.content,o=at(e),s=o.length>1;return(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-amber-500/10 shrink-0`,children:(0,$.jsx)(Pe,{className:`size-5 text-amber-500 fill-amber-500`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 flex-wrap`,children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:u,className:`size-6`,children:[(0,$.jsx)(G,{src:l?.picture,alt:d}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-[10px]`,children:d[0]?.toUpperCase()})]})})}),(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`font-bold text-sm hover:underline truncate`,children:c.data?.event?(0,$.jsx)(hn,{tags:c.data.event.tags,children:d}):d})}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`zapped`,s&&` ${o.length} people`]}),n>0&&(0,$.jsx)(`span`,{className:`text-sm font-semibold text-amber-500 shrink-0`,children:kt(n)}),i?(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:`· unverified`}):r?(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:`· verifying…`}):null]})]}),s&&(0,$.jsx)(`div`,{className:`mt-2 pl-[52px]`,children:(0,$.jsx)(L,{pubkeys:o,size:`md`,maxVisible:8})}),a&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground italic pl-[52px]`,children:[`“`,a,`”`]}),Mn,(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`-mx-4 px-4`}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]})})(),lt&&(()=>{let t={};try{t=JSON.parse(e.content)}catch{}return(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsx)(tr,{pubkey:e.pubkey,metadata:t}),(0,$.jsx)(`div`,{className:`py-2 sidebar:py-2.5 mt-3 text-xs sidebar:text-sm text-muted-foreground`,children:gf(e.created_at)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1 border-t border-b border-border -mx-4 px-4`,children:[(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:`Reply`,onClick:()=>en(!0),children:[(0,$.jsx)(ke,{className:`size-5`}),z?.replies?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(z.replies)}):null]}),(0,$.jsx)(so,{event:e,children:e=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 p-2 rounded-full transition-colors ${e?`text-accent hover:text-accent/80 hover:bg-accent/10`:`text-muted-foreground hover:text-accent hover:bg-accent/10`}`,title:e?`Undo repost`:`Repost`,children:[(0,$.jsx)(gi,{className:`size-5`}),jn?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(jn)}):null]})}),(0,$.jsx)(oo,{eventId:e.id,eventPubkey:e.pubkey,eventKind:e.kind,reactedEvent:e,reactionCount:z?.reactions}),(0,$.jsx)(`button`,{className:`p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors sidebar:hidden`,title:`Share`,onClick:ne,children:(0,$.jsx)(we,{className:`size-5`})}),(0,$.jsx)(`button`,{className:`p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:`More`,onClick:()=>B(!0),children:(0,$.jsx)(ce,{className:`size-5`})})]}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]})})(),et&&(0,$.jsxs)(`article`,{ref:Dn,className:`px-4 pt-3 pb-0`,children:[(0,$.jsx)(ot,{event:e}),(0,$.jsx)(`div`,{className:`py-2 sidebar:py-2.5 mt-2 sidebar:mt-3 text-xs sidebar:text-sm text-muted-foreground flex items-center gap-1.5`,children:(0,$.jsx)(`span`,{children:gf(e.created_at)})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1 border-t border-b border-border -mx-4 px-4`,children:[(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:`Reply`,onClick:()=>en(!0),children:[(0,$.jsx)(ke,{className:`size-5`}),z?.replies?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(z.replies)}):null]}),(0,$.jsx)(so,{event:e,children:e=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 p-2 rounded-full transition-colors ${e?`text-accent hover:text-accent/80 hover:bg-accent/10`:`text-muted-foreground hover:text-accent hover:bg-accent/10`}`,title:e?`Undo repost`:`Reposts`,children:[(0,$.jsx)(gi,{className:`size-5`}),jn?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Si(jn)}):null]})}),(0,$.jsx)(oo,{eventId:e.id,eventPubkey:e.pubkey,eventKind:e.kind,reactedEvent:e,reactionCount:z?.reactions}),(0,$.jsx)(`button`,{className:`p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors sidebar:hidden`,title:`Share`,onClick:ne,children:(0,$.jsx)(we,{className:`size-5`})}),(0,$.jsx)(`button`,{className:`p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:`More`,onClick:()=>B(!0),children:(0,$.jsx)(ce,{className:`size-5`})})]}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]}),ie&&(0,$.jsxs)(`div`,{ref:Dn,children:[(0,$.jsx)(xa,{className:`border-b-0 pb-0`,icon:(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`shrink-0`,children:(0,$.jsxs)(K,{shape:u,className:`size-10`,children:[(0,$.jsx)(G,{src:l?.picture,alt:d}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:d[0]?.toUpperCase()})]})})}),actorRow:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`font-bold text-sm hover:underline truncate`,children:c.data?.event?(0,$.jsx)(hn,{tags:c.data.event.tags,children:d}):d})}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:`voted`})]}),children:E&&(0,$.jsx)(`p`,{className:`text-sm font-semibold mt-0.5 truncate`,children:E})}),(0,$.jsx)(`div`,{className:`px-4`,children:Mn}),(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`mx-4`}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]}),!ye&&!be&&!et&&!tt&&!ct&&!lt&&!ie&&(0,$.jsxs)(`article`,{ref:Dn,className:V(`relative px-4 pt-3 pb-0`,O&&`overflow-hidden`),children:[O&&D&&(0,$.jsx)(Fi,{variant:D}),Be&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:y,action:la(e,{created:`published an app`,updated:`updated an app`,fallback:`published an app`})}),Le&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:y,action:la(e,{created:`published a Zapstore app`,updated:`updated a Zapstore app`,fallback:`published a Zapstore app`})}),Re&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:y,action:la(e,{created:`published a Zapstore release`,updated:`updated a Zapstore release`,fallback:`published a Zapstore release`})}),ze&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:y,action:`published a Zapstore asset`}),Ie&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:s,action:la(e,{created:`deployed an`,updated:`redeployed an`,fallback:`deployed an`}),noun:`nsite`,nounRoute:`/development`}),se&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:De,action:`heard a`,noun:`bird`}),ue&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:re,action:la(e,{created:`drew a`,updated:`redrew a`,fallback:`drew a`}),noun:`constellation`}),ae&&(0,$.jsx)(ma,{pubkey:e.pubkey,icon:_i,action:`found a`,noun:`treasure`,nounRoute:`/treasures`}),(0,$.jsx)(`div`,{className:`flex items-center gap-3`,children:c.isLoading?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{className:`size-11 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-36`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsxs)(q,{to:_,className:`relative shrink-0`,children:[(0,$.jsxs)(K,{shape:u,className:`size-11`,children:[(0,$.jsx)(G,{src:l?.picture,alt:d}),(0,$.jsx)(U,{className:`bg-primary/20 text-primary text-sm`,children:d[0].toUpperCase()})]}),p&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute -top-3 -right-1.5 z-10 rotate-[18deg]`,children:(0,$.jsx)(Pr,{className:`size-8 drop-shadow-sm`,pomScale:1.15})})]})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(En,{pubkey:e.pubkey,asChild:!0,children:(0,$.jsx)(q,{to:_,className:`font-bold text-[15px] hover:underline block truncate`,children:c.data?.event?(0,$.jsx)(hn,{tags:c.data.event.tags,children:d}):d})}),g&&(0,$.jsx)(Sa,{nip05:g,pubkey:e.pubkey,className:`text-sm text-muted-foreground`})]}),l?.bot&&(0,$.jsx)(`span`,{className:`text-sm text-primary`,title:`Bot account`,children:`🤖`}),oe&&(0,$.jsx)(Ji,{event:e})]})}),e.kind===1111&&(0,$.jsx)(Yi,{event:e}),e.kind===1311&&(0,$.jsx)(R,{event:e}),e.kind===df&&(0,$.jsx)(Af,{event:e}),(0,$.jsx)(qe,{fallback:(0,$.jsx)(Tt,{}),sentryLevel:`error`,sentryTags:{errorBoundary:`post-detail`,kind:e.kind},resetKeys:[e.id],children:(0,$.jsx)(Ua,{event:e,children:(0,$.jsx)($e,{pubkey:e.pubkey,children:xe?(0,$.jsx)(Da,{event:e,variant:`detail`,fullBleed:!0}):Se?(0,$.jsx)(Of,{event:e}):pe?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(Jd,{event:e,className:`mt-3`})}):N?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(Yd,{event:e,expanded:!0})}):me?(0,$.jsx)(wd,{event:e}):he?(0,$.jsx)($i,{event:e}):ge?(0,$.jsx)(Oa,{event:e}):_e?(0,$.jsx)(pa,{event:e,expanded:!0}):ve?(0,$.jsx)(ea,{event:e}):Ce?(0,$.jsx)(Ud,{event:e}):Te?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ua,{event:e})}):Oe?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(sa,{event:e,preview:!1})}):Ae?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(tf,{event:e,preview:!1})})}):Me?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ef,{event:e,preview:!1})})}):je?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ki,{event:e,preview:!1})}):Ne?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)($d,{event:e,preview:!1})})}):Ee?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(da,{event:e,preview:!1})}):Fe?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-32 w-full rounded-lg`}),children:(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(Qd,{event:e,preview:!1})})}):Ie?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(na,{event:e,autoPlayKey:h})}):Le?(0,$.jsx)(`div`,{className:`mt-3 rounded-xl border border-border overflow-hidden px-4 pt-4 pb-4`,children:(0,$.jsx)(_a,{event:e})}):Re?(0,$.jsx)(`div`,{className:`mt-3 rounded-xl border border-border overflow-hidden px-4 pt-4 pb-4`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(oa,{}),children:(0,$.jsx)(ia,{event:e})})}):ze?(0,$.jsx)(`div`,{className:`mt-3 rounded-xl border border-border overflow-hidden px-4 pt-4 pb-4`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Ca,{}),children:(0,$.jsx)(fa,{event:e})})}):Be?(0,$.jsx)(ra,{event:e}):Ve?(0,$.jsx)(wt,{event:e}):He?(0,$.jsx)(it,{event:e}):Ue?(0,$.jsx)(yt,{event:e}):We?(0,$.jsx)(ta,{event:e,expanded:!0}):Ge?(0,$.jsx)(Hi,{event:e,expanded:!0}):Ke?(0,$.jsx)(Mi,{event:e,expanded:!0}):Je?(0,$.jsx)(Ni,{event:e,expanded:!0}):P?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(qi,{event:e,expanded:!0})}):F?(0,$.jsx)(Ct,{event:e,expanded:!0}):I?(0,$.jsx)(nt,{event:e,expanded:!0}):Xe?(0,$.jsx)(Ki,{event:e,expanded:!0}):Ze?(0,$.jsx)(Ta,{event:e,expanded:!0}):Qe?(0,$.jsx)(ji,{event:e,expanded:!0}):ut?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(X,{className:`h-24 w-full rounded-lg`}),children:(0,$.jsx)(Xd,{event:e,lookMode:`follow-pointer`,interactionReaction:pn})}):gt?(0,$.jsx)(va,{event:e}):k||A||j||ae||oe||se||le||ue||M||de||fe?(0,$.jsxs)($.Fragment,{children:[k&&(0,$.jsx)(kf,{event:e}),A&&(0,$.jsx)(ca,{event:e}),j&&(0,$.jsx)(Pi,{event:e}),ae&&(0,$.jsx)(Li,{event:e}),oe&&(0,$.jsx)(Ii,{event:e}),se&&(0,$.jsx)(Ui,{event:e}),le&&(0,$.jsx)(Vi,{event:e,expanded:!0}),ue&&(0,$.jsx)(Bi,{event:e}),M&&(0,$.jsx)(Gi,{event:e}),de&&(0,$.jsx)(zi,{event:e,expanded:!0}),fe&&(0,$.jsx)(Ai,{event:e})]}):Et?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ft,{event:e,expanded:!0})}):(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(pt,{event:e,className:`text-[15px] leading-relaxed`})})})})}),Mn,(0,$.jsx)(tu,{event:e,onReply:()=>en(!0),onMore:()=>B(!0),className:`-mx-4 px-4`,compact:un,extraButtons:un?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zd,{event:e,companion:sn,onInteractionSuccess:vn})}):void 0}),(0,$.jsx)(Na,{event:e,open:Qt,onOpenChange:B}),(0,$.jsx)(Lr,{event:e,open:H,onOpenChange:en}),(0,$.jsx)(Vu,{target:e,open:tn,onOpenChange:nn,initialTab:rn})]}),(0,$.jsx)(`div`,{className:`pb-16 sidebar:pb-0`,children:Bt?(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(If,{},t))}):Gt.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cs,{roots:Kt}),(0,$.jsx)(os,{roots:qt})]}):bn?null:(0,$.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:`No replies yet. Be the first to reply!`})})]})}function Mf({to:e}){let t=(0,$.jsx)(`div`,{className:`px-4 pt-3 pb-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,$.jsx)(`div`,{className:`inline-flex items-center justify-center size-10 rounded-full bg-muted/60 shrink-0`,children:(0,$.jsx)(Fe,{className:`size-5 text-muted-foreground`})}),(0,$.jsx)(`div`,{className:`w-0.5 flex-1 mt-2 bg-foreground/20`})]}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0 pb-4`,children:(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:[`This post couldn't be loaded. It may be on a relay you're not connected to.`,e&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`text-primary font-medium`,children:`View post`})]})]})})]})});return e?(0,$.jsx)(q,{to:e,className:`block hover:bg-secondary/30 transition-colors`,children:t}):t}function Nf({addr:e,relays:t}){let{data:n,isLoading:r}=qr(e,t);if(r)return(0,$.jsx)(`div`,{className:`px-4 pt-3 pb-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsx)(`div`,{className:`w-0.5 flex-1 mt-2 bg-foreground/20`})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pb-4 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-3 w-16`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})]})});if(!n){let n=cr({identifier:e.identifier,pubkey:e.pubkey,kind:e.kind,relays:t});return(0,$.jsx)(Mf,{to:n?`/${n}`:void 0})}return(0,$.jsx)(ya,{event:n,threaded:!0})}function Pf({eventId:e,relays:t,authorHint:n,depth:r=0,collapseAfter:i}){let{data:a,isLoading:o}=Jr(e,t,n),[s,c]=(0,Q.useState)(!1),l=(0,Q.useMemo)(()=>a?Mr(a):void 0,[a]),u=l?.id,d=(0,Q.useMemo)(()=>{if(!a||a.kind!==1111||u)return;let e=a.tags.find(([e])=>e===`A`)??a.tags.find(([e])=>e===`a`),t=In(e?.[1]);if(!(!t||t.kind===0||t.kind===34550))return{addr:t,relayHint:e?.[2]||void 0}},[a,u]),f=i!==void 0&&r>=i&&u&&!s;if(o)return(0,$.jsx)(`div`,{className:`px-4 pt-3 pb-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsx)(`div`,{className:`w-0.5 flex-1 mt-2 bg-foreground/20`})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pb-4 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{className:`h-4 w-24`}),(0,$.jsx)(X,{className:`h-3 w-16`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]})]})]})});if(!a){let r=or({id:e,relays:t,author:n});return(0,$.jsx)(Mf,{to:r?`/${r}`:void 0})}return(0,$.jsxs)($.Fragment,{children:[d&&(0,$.jsx)(Nf,{addr:d.addr,relays:d.relayHint?[d.relayHint]:void 0}),u&&r<20&&(f?(0,$.jsxs)(`button`,{onClick:()=>c(!0),className:`flex items-center gap-3 px-4 py-2 w-full hover:bg-secondary/30 transition-colors`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center w-10`,children:[(0,$.jsx)(`div`,{className:`w-0.5 h-2 bg-foreground/20 rounded-full`}),(0,$.jsx)(`div`,{className:`size-1.5 rounded-full bg-foreground/30 my-0.5`}),(0,$.jsx)(`div`,{className:`size-1.5 rounded-full bg-foreground/20 my-0.5`}),(0,$.jsx)(`div`,{className:`size-1.5 rounded-full bg-foreground/10 my-0.5`}),(0,$.jsx)(`div`,{className:`w-0.5 h-2 bg-foreground/20 rounded-full`})]}),(0,$.jsx)(`span`,{className:`text-sm text-primary font-medium`,children:`Show earlier posts`})]}):(0,$.jsx)(Pf,{eventId:u,relays:l?.relayHint?[l.relayHint]:void 0,authorHint:l?.authorHint,depth:r+1,collapseAfter:i})),(0,$.jsx)(ya,{event:a,threaded:!0})]})}function Ff(){return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`px-4 pt-3 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(X,{className:`size-11 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-28`}),(0,$.jsx)(X,{className:`h-3 w-36`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-4/5`}),(0,$.jsx)(X,{className:`h-4 w-3/5`})]}),(0,$.jsx)(X,{className:`mt-3 w-full h-64 rounded-2xl`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2.5 mt-3`,children:[(0,$.jsx)(X,{className:`h-4 w-16`}),(0,$.jsx)(X,{className:`h-4 w-12`}),(0,$.jsx)(X,{className:`h-4 w-32 ml-auto`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-2 border-t border-b border-border -mx-4 px-4`,children:[(0,$.jsx)(X,{className:`size-[34px] rounded-full`}),(0,$.jsx)(X,{className:`size-[34px] rounded-full`}),(0,$.jsx)(X,{className:`size-[34px] rounded-full`}),(0,$.jsx)(X,{className:`size-[34px] rounded-full`}),(0,$.jsx)(X,{className:`size-[34px] rounded-full`})]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(If,{},t))})]})}function If(){return(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(X,{className:`size-10 rounded-full shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{className:`h-4 w-20`}),(0,$.jsx)(X,{className:`h-3 w-28`}),(0,$.jsx)(X,{className:`h-3 w-6`})]}),(0,$.jsx)(X,{className:`h-3 w-24`}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-4 w-full`}),(0,$.jsx)(X,{className:`h-4 w-3/4`})]}),(0,$.jsxs)(`div`,{className:`flex gap-12 mt-1`,children:[(0,$.jsx)(X,{className:`h-4 w-6`}),(0,$.jsx)(X,{className:`h-4 w-6`}),(0,$.jsx)(X,{className:`h-4 w-6`}),(0,$.jsx)(X,{className:`h-4 w-6`})]})]})]})})}var Lf=/^[0-9a-f]{64}$/;function Rf(e){return!!(e.includes(`@`)||e.includes(`.`)&&!e.startsWith(`npub1`)&&!e.startsWith(`nprofile1`))}function zf({hex:e}){let{nostr:t}=P(),{data:n,isLoading:r}=I({queryKey:[`hex-resolve`,e],queryFn:async()=>(await t.query([{ids:[e],limit:1}])).length>0?`event`:(await t.query([{kinds:[0],authors:[e],limit:1}])).length>0?`pubkey`:`event`,staleTime:1/0});return r||!n?(0,$.jsx)(xf,{children:(0,$.jsx)(Ff,{})}):n===`pubkey`?(0,$.jsx)(Il,{}):(0,$.jsx)(vf,{eventId:e})}function Bf(){let{nip19:e}=un();if(!e)return(0,$.jsx)(ko,{});if(Rf(e))return(0,$.jsx)(Il,{});if(Lf.test(e))return(0,$.jsx)(zf,{hex:e});let t;try{t=F.decode(e)}catch{return(0,$.jsx)(ko,{})}let{type:n}=t;switch(n){case`npub`:case`nprofile`:return(0,$.jsx)(Il,{});case`note`:return(0,$.jsx)(vf,{eventId:t.data});case`nevent`:{let e=t.data;return(0,$.jsx)(vf,{eventId:e.id,relays:e.relays,authorHint:e.author})}case`naddr`:{let e=t.data;return(0,$.jsx)(yf,{addr:{kind:e.kind,pubkey:e.pubkey,identifier:e.identifier},relays:e.relays})}default:return(0,$.jsx)(ko,{})}}export{Bf as NIP19Page}; // @license-end