const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-D9LDI3pu.js","assets/dist-DQ_zK-Nr.js","assets/ImageCropDialog-Bf-7Rd4a.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BjbcRgLk.js","assets/jsx-runtime-By8HlURe.js","assets/react-intl-DZWxPhxo.js","assets/button-PfnADMEc.js","assets/utils-BFSTDHdM.js","assets/dist-Dpfwv2h4.js","assets/dist-DvXXZeEa.js","assets/dist-DEYuuXMO.js","assets/Combination-CjNgozRb.js","assets/dialog-CV-ki2ew.js","assets/dist-HCKlYXPm.js","assets/react-dom-B3NAB_6u.js","assets/dist-D7Bu0-nC.js","assets/dist-CcIWO21i2.js","assets/dist-CPSwqoBy.js","assets/dist-BiDubxw8.js","assets/dist-CxcvWxxD2.js","assets/dist-CDe9cWnA.js","assets/dist-VfIIxYhK.js","assets/dist-CGiXP6ew.js","assets/slider-MhLD4Ugr.js","assets/dist-kXp6QuJv.js","assets/dist-l851fJFf.js","assets/dist-3TtKm3JK.js","assets/dist-C7V3QC0v.js","assets/dist-C2J943E6.js","assets/ThemeSelector-DtIUEiRe.js","assets/dist-DPmmj29U.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useQuery-CQCUTxAw.js","assets/useTheme-DAiZ1C6g.js","assets/useAppContext-ZpOJAKgd.js","assets/useEncryptedSettings-Mj6Bzp-m.js","assets/useMutation-Du3NQIud.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-boOMG5Xx.js","assets/preload-helper-CZgWQFsJ.js","assets/fontLoader-B9KxicFi.js","assets/sanitizeUrl-Bk5f35GN.js","assets/useNostrPublish-D1pQ9KV-.js","assets/input-CspJi8Oq.js","assets/collapsible-D6IpicA3.js","assets/dist-Ds1tJnF3.js","assets/usePortalContainer-DQGL8y5W.js","assets/textarea-BgTH9QGZ.js","assets/label-vPn5dXR9.js","assets/switch-DKbY1cT2.js","assets/haptics-Cp_uF-bV.js","assets/BackgroundPicker-BYDRqHa7.js","assets/popover-CpFQm40Y.js","assets/dist-CKGV8nry.js","assets/dist-CogQAcR-.js","assets/useUploadFile-geM_X2W-.js","assets/appBlossom-CsMDSd4h.js","assets/resizeImage-LOlp-rx5.js","assets/web-BALG1lv4.js","assets/esm-CGtja3l7.js","assets/EmbeddedPost-DITW2flc.js","assets/EmbeddedNote-BIqVJ_l6.js","assets/ErrorBoundary-CeoYY2tU.js","assets/encryptedFile-DKFYUsvG.js","assets/downloadFile-kpATXaJi.js","assets/nostrId-DcIQ4FCD.js","assets/letterTypes-BPWQWRGQ.js","assets/avatar-BQAt2c6L.js","assets/chunk-62JRHF6Z-BC2Zeguv.js","assets/customEmoji-kpim4Htm.js","assets/hashtag-DjDKS0mr.js","assets/CustomEmoji-I2Dzbi7x.js","assets/useProfileUrl-CaWgk1iO.js","assets/useNip05Resolve-DffiSbg0.js","assets/profileUrl-DpJiPx2H.js","assets/BioContent-DDUa8M5F.js","assets/useFollowActions-DsgUKin8.js","assets/ExternalFavicon-C4RKLGFC.js","assets/useUserStatus-B8wcD2cC.js","assets/parseAddr-CsIsUI6W.js","assets/skeleton-CVls4GW9.js","assets/useAuthors-D2-iLlS9.js","assets/storageKey-Hu6452Ya.js","assets/safeNip19-BZNpFefA.js","assets/useEventInteractions-D6e37IFo.js","assets/nsiteSubdomain-DmdGxq_K.js","assets/tooltip-ihPDheAv.js","assets/timeAgo-BXjjbyXp.js","assets/getDisplayName-B6lnEGRj.js","assets/letterUtils-rB1MsAOm.js","assets/optimisticEvent-1jcgWuWv.js","assets/useLinkPreview-BkYXhPdP.js","assets/appRelays-Clm5NPIe.js","assets/packUtils-2qvnOK3p.js","assets/relayList-BL1oPXvf.js","assets/memorycard-MlvJNhop.js","assets/EmbeddedArticleCard-DcmW__gy.js","assets/articleHelpers-Dhr_Z8YP.js","assets/EmbeddedPublicationCard-CB7mdYv1.js","assets/bitcoinMoney-BhQyBHpS.js","assets/esplora-CScU9uce.js","assets/countries-Du6BjHuX.js","assets/campaign-DQCR5kmK.js","assets/quiz-C4N9ueCX.js","assets/extraKinds-CF0LI2P1.js","assets/sidebarItems-BUQKy0PN.js","assets/WikipediaIcon-Df-eqPdn.js","assets/BlueskyIcon-imVay4Hn.js","assets/formatNumber-D1ols1S-.js","assets/browser-B_X_RtOd.js","assets/imeta-AKViBfwk.js","assets/formatTime-CT4ZmnVr.js","assets/browser-C1AyMpfR.js","assets/LayoutContext-CseIvyNG.js","assets/useInView-DH5wwDuH.js","assets/useCustomEmojis-Dt5wlrd3.js","assets/EmbeddedNote-C_xrnWud.css","assets/useLocalStorage-CLIGOX6B.js","assets/useLanguage--9xPt4K_.js","assets/ComposeDialogContent-DiIapF7b.js","assets/useSearchProfiles-B9G_eYtw.js","assets/useIsMobile-brkrNavj.js","assets/useShareOrigin-CbCLa1kb.js","assets/useFeedSettings-BgA2vWPo.js","assets/birthday-CoMNDhVK.js","assets/DecryptedImage-DwsS1fNG.js","assets/wikimedia-CCPyM-j2.js","assets/WidgetSidebar-CCOWgym0.js","assets/scroll-area-C7R5cbXG.js","assets/companion-BH2LoWmw.js","assets/blobbi-tV-LVZhE.js","assets/useStatusReaction-CeCr5ITa.js","assets/blobbi-shop-items-CNXfdKej.js","assets/BlobbiStageVisual-Dd-i9Ybg.js","assets/purify.es-DCh266OY.js","assets/BlobbiStageVisual-ZqmrGSeZ.css","assets/interaction-B62ECaS4.js","assets/blobbi-action-utils-iVOeMboU.js","assets/EmojiPacksPage-U7yj16V_.js","assets/useInfiniteQuery-D8okYDlC.js","assets/NoteCard-D2oNQMft.js","assets/ProfileCard-DQLNVDBD.js","assets/dropdown-menu-DFQx4ARb.js","assets/musicHelpers-B9zs9cce.js","assets/NoteMoreMenu-3p8z2oYh.js","assets/useMuteList-CircRxPI.js","assets/radio-group-B1VhA2GH.js","assets/dist-QlrhncJe.js","assets/alert-dialog-CeTXY_OC.js","assets/separator-b5OgNKgY.js","assets/useUserLists-DfjIOk3O.js","assets/qrcode-BozHOxi9.js","assets/useInteractionReaction-yS8fuYfx.js","assets/badge-CmNUd8lU.js","assets/colorMomentUtils-Bpys-FvF.js","assets/contentWarning-CNDzjeMP.js","assets/streamStatus-DVDPiDhw.js","assets/useRelayInfo-vo6x6CNq.js","assets/GitSiteLinks-Qp1PbuLj.js","assets/useOpenPost-BwUmNKcO.js","assets/useRepostStatus-B31cmi_e.js","assets/useBitcoinSigner-FZ_QaYrL.js","assets/checkbox-PjbMGVRG.js","assets/RepostMenu-Cxcb2_YK.js","assets/lib-BtieP5-E.js","assets/lib-DhF-PQbN.js","assets/useTrending-Chl2smhy.js","assets/vineGlobalMute-Du-DhONT.js","assets/SubHeaderBar-3es_mHJE.js","assets/usePageRefresh-DfuHEbb5.js","assets/useMutedAuthorFilter-CJzmJTvY.js","assets/card-s_jiNeB6.js","assets/PageHeader-oqdc3zZd.js","assets/useInfiniteScroll-gIQ7qiQj.js","assets/deduplicateEvents-BUUuuRQu.js","assets/KindInfoButton-3-8ziMHh.js","assets/useEmojiPacks-kv7BZJAU.js","assets/HomePage-De2EtDwq.js","assets/AdvancedSettingsPage-CWHWhqVO.js","assets/RequestToVanishDialog-BEPSSQKk.js","assets/useLoginActions-DN9mAG_d.js","assets/select-CCwlMI4l.js","assets/WalletSettings-C9k5o7Fz.js","assets/useWallet-B7BoZiO5.js","assets/AIChatPage-DMXptGBZ.js","assets/useShakespeare-wXUiKAwb.js","assets/ArchivePage-DJYP4fd5.js","assets/ArticleEditorPage-D4pDpdea.js","assets/slugify-DtAAsCyV.js","assets/BadgesPage-CdfG-8k3.js","assets/helpContent-D0r-ot2m.js","assets/usePendingBadges-DwyALGFF.js","assets/SortableList-CAerxC_w.js","assets/BlobbiPage-BLGQm_rC.js","assets/useBlobbiUseInventoryItem-WwM4DC2B.js","assets/useBlobbiInteractions-BLqS6Kj4.js","assets/ItemCarousel-BvL_DIgg.js","assets/FloatingSocialHearts-B41ZB2oO.js","assets/BlueskyPage-BfCZNpiE.js","assets/BookmarksPage-OZO0MFoB.js","assets/BooksPage-pnYcOWfe.js","assets/bookstr-BBZy-aJu.js","assets/ChangelogPage-DNsJi6Gj.js","assets/ClientFeedPage-CdkSMTZR.js","assets/ClientMetrics-Df82rpeu.js","assets/chart-BMx2sB-S.js","assets/ContentPage-D8R_pUZs.js","assets/HelpTip-C21oihWD.js","assets/ContentSettings-oSA5_wyz.js","assets/accordion-Dxa7b6N3.js","assets/SavedFeedFiltersEditor-MGOkPo8W.js","assets/ContentSettingsPage-CnN2hcDR.js","assets/CSAEPolicyPage-D27zM5-U.js","assets/DataSettingsPage-CCIji56I.js","assets/DomainFeedPage-ayXHWaHW.js","assets/EventsFeedPage-BxuEi6vA.js","assets/ExternalContentPage-DlkSaAyY.js","assets/GeotagPage-DKjW_4RP.js","assets/TagFeedPage-B7xvyVRz.js","assets/HashtagPage-DZBUjooO.js","assets/HelpPage-se4YD6Fh.js","assets/FollowAllSplitButton-D2qPYCXz.js","assets/KindFeedPage-CJY6q1zV.js","assets/LetterComposePage-DmfXfGM_.js","assets/useStationeryColors-BxGOhPpo.js","assets/useLetterPreferences-DWPSaz42.js","assets/LetterEditor-I0UG7aQd.js","assets/LetterStickers-Ci4lr-Bn.js","assets/LetterPreferencesPage-Btj1k7OR.js","assets/LettersPage-CxVo42ey.js","assets/LetterDetailSheet-l3iEWrFH.js","assets/MagicSettingsPage-CmOviiY0.js","assets/MemoryCardsPage-DGz2KY0V.js","assets/MusicPage-fgpGLZNe.js","assets/MusicTrackRow-CTPwsTeM.js","assets/NetworkSettingsPage-DezXkJNZ.js","assets/NIP19Page-DcS1jRRH.js","assets/toggle-group-DdeThNE3.js","assets/bitcoin-CZvT_Ikr.js","assets/silentPaymentsCore-DNoThJua.js","assets/ProfileRightSidebar-DkzDFCsa.js","assets/mediaUtils-B4-_lbmN.js","assets/MediaCollage-CU9m9VFu.js","assets/CommentsSheet-DgJYzl0m.js","assets/usePublishProfileTabs-BFPoTEuQ.js","assets/NotificationSettings-CnQ_u9eZ.js","assets/NotificationsPage-BI3BQ3K3.js","assets/PhotosFeedPage-BJJpDi4r.js","assets/PodcastsFeedPage-XJjMU1Nx.js","assets/PrivacyPolicyPage-DfPfWknQ.js","assets/ProfileSettings-cWB1AMJt.js","assets/credentialManager-Dv_8gYNN.js","assets/usePaymentTargets-CPvmCEzN.js","assets/RelayPage-CMC8280U.js","assets/SearchPage-BlgCFvFy.js","assets/NewPostsPill-BaedKv8h.js","assets/SettingsPage-wzcKruPh.js","assets/SharePage-BKckwPDb.js","assets/ThemesPage-CF4nSA77.js","assets/TreasuresPage-BByQ-acA.js","assets/QuizzesPage-ClDF0_zI.js","assets/CreateQuizPage-BK-AMC86.js","assets/TrendsPage-CTluRsDQ.js","assets/ClientUsersChart-Bh24QkSW.js","assets/UserListsPage--HgkTA_I.js","assets/VideosFeedPage-CmAi78FQ.js","assets/VinesFeedPage-x_0HGxDm.js","assets/WalletPage-BrKsD0N_.js","assets/alert-8XHA_vtM.js","assets/ZapSuccessScreen-CqNFXyZ7.js","assets/WalletSettingsPage-BZCW-BH2.js","assets/WebxdcFeedPage-JkIXIn6T.js","assets/webxdcMeta-BE41E4P0.js","assets/WikipediaPage-BjPAd7Ag.js","assets/useWikipediaFeatured-Dw_bIeQR.js","assets/WorldPage-CGNJksI9.js","assets/RemoteLoginSuccessPage-RdWRi3wH.js","assets/esm-Dx0xmOVX.js"])))=>i.map(i=>d[i]); import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";import{$ as r,$r as i,Cr as a,Ct as o,Di as s,E as c,Ei as l,En as u,Et as d,Ft as f,Gr as p,Ht as m,In as h,Jr as g,Kr as _,Ln as v,M as y,Nn as b,Nt as x,Ot as S,Q as C,Qt as w,T,Ur as E,Wr as D,Wt as O,Xn as k,Xr as ee,Y as A,_r as j,a as M,an as N,b as te,br as ne,bt as re,c as P,cn as F,cr as I,ft as L,gt as R,hi as ie,ht as ae,ii as oe,ki as se,kt as ce,ln as le,mr as ue,mt as de,nn as fe,pi as pe,pn as me,qr as he,rn as ge,rr as _e,rt as ve,si as ye,sr as be,wn as xe,x as Se,xr as Ce,yn as we}from"./lucide-icons-BjbcRgLk.js";import{t as Te}from"./react-dom-B3NAB_6u.js";import{n as Ee,r as De,t as Oe}from"./useNip05Resolve-DffiSbg0.js";import{t as ke}from"./jsx-runtime-By8HlURe.js";import{i as Ae,n as je,r as Me,t as Ne}from"./ErrorBoundary-CeoYY2tU.js";import{t as z}from"./preload-helper-CZgWQFsJ.js";import{A as Pe,D as Fe,O as Ie,a as Le,b as Re,d as ze,f as Be,g as Ve,i as He,n as Ue,r as We,t as Ge,u as Ke,v as qe}from"./dist-DPmmj29U.js";import{a as Je,d as Ye,i as Xe,l as Ze,r as Qe,s as $e,t as et,u as tt,x as nt}from"./esm-CRVqHnq2.js";import{i as rt,t as it}from"./sha256-Cx9u8cje.js";import{A as at,D as ot,E as st,I as ct,L as lt,M as ut,O as dt,P as ft,S as pt,_ as mt,h as ht,j as gt,k as _t,m as vt,t as yt,x as bt,y as xt}from"./useQuery-CQCUTxAw.js";import{n as St,t as Ct}from"./useMutation-Du3NQIud.js";import{n as wt,t as Tt}from"./useInfiniteQuery-D8okYDlC.js";import{L as Et,gt as Dt,ht as Ot,lt as kt,vt as At}from"./EmbeddedNote-BIqVJ_l6.js";import{t as jt}from"./useLocalStorage-CLIGOX6B.js";import{n as Mt,t as Nt}from"./useAppContext-ZpOJAKgd.js";import{L as Pt,R as Ft,c as It,d as Lt,f as Rt,g as zt,h as Bt,i as Vt,j as Ht,m as Ut,n as Wt,o as Gt,p as Kt,r as qt,t as Jt,w as Yt}from"./useTheme-DAiZ1C6g.js";import{a as Xt,i as Zt,n as Qt,o as $t,r as en,t as tn}from"./useEncryptedSettings-Mj6Bzp-m.js";import{n as nn,t as rn}from"./fontLoader-B9KxicFi.js";import{r as an}from"./sanitizeUrl-Bk5f35GN.js";import{a as on,i as sn,n as cn,o as ln,r as B}from"./react-intl-DZWxPhxo.js";import{a as un,i as dn,r as fn,t as pn}from"./useLanguage--9xPt4K_.js";import{n as mn,o as hn,r as gn,t as _n}from"./dist-DQ_zK-Nr.js";import{n as vn}from"./credentialManager-Dv_8gYNN.js";import{a as yn,r as bn,t as xn}from"./encryptedFile-DKFYUsvG.js";import{a as Sn}from"./downloadFile-kpATXaJi.js";import{t as Cn}from"./fetchFreshEvent-Kkz3MzZN.js";import{c as wn,d as Tn,f as En,l as Dn,m as On,n as kn,o as An,p as jn,s as Mn,t as V,u as Nn}from"./useCurrentUser-boOMG5Xx.js";import{t as H}from"./utils-BFSTDHdM.js";import{n as Pn,r as Fn,t as In}from"./NewPostsPill-BaedKv8h.js";import{t as Ln}from"./dist-DEYuuXMO.js";import{t as Rn}from"./button-PfnADMEc.js";import{t as zn}from"./useNostrPublish-D1pQ9KV-.js";import{t as Bn}from"./nostrId-DcIQ4FCD.js";import{i as Vn,n as Hn,r as Un}from"./useFollowActions-DsgUKin8.js";import{a as Wn,i as Gn,o as Kn,r as qn,s as Jn,t as Yn}from"./appRelays-Clm5NPIe.js";import{o as Xn}from"./letterTypes-BPWQWRGQ.js";import{l as Zn,n as Qn,o as $n,r as er,s as tr,t as nr}from"./avatar-BQAt2c6L.js";import{a as U,c as rr,i as ir,l as ar,n as or,o as sr,r as cr,s as lr,t as ur}from"./chunk-62JRHF6Z-BC2Zeguv.js";import{n as dr}from"./CustomEmoji-I2Dzbi7x.js";import{t as fr}from"./profileUrl-DpJiPx2H.js";import{n as pr,t as mr}from"./useProfileUrl-CaWgk1iO.js";import{t as hr}from"./ExternalFavicon-C4RKLGFC.js";import{t as gr}from"./useUserStatus-B8wcD2cC.js";import{a as _r,r as vr}from"./haptics-Cp_uF-bV.js";import{t as yr}from"./input-CspJi8Oq.js";import{a as br,i as xr,n as Sr,r as Cr,t as wr}from"./dropdown-menu-DFQx4ARb.js";import{t as Tr}from"./usePortalContainer-DQGL8y5W.js";import{i as Er,r as Dr,t as Or}from"./popover-CpFQm40Y.js";import{t as kr}from"./skeleton-CVls4GW9.js";import{t as Ar}from"./ProfileCard-DQLNVDBD.js";import{t as jr}from"./useAuthors-D2-iLlS9.js";import{n as Mr,r as Nr}from"./appBlossom-CsMDSd4h.js";import{t as Pr}from"./storageKey-Hu6452Ya.js";import{n as Fr,r as Ir,t as Lr}from"./useMuteList-CircRxPI.js";import{t as Rr}from"./useLoginActions-DN9mAG_d.js";import{n as zr,r as Br,t as Vr}from"./LoginFlow-CnOkE_pG.js";import{t as Hr}from"./useUploadFile-geM_X2W-.js";import{n as Ur}from"./safeNip19-BZNpFefA.js";import{l as Wr}from"./useEventInteractions-D6e37IFo.js";import{n as Gr,o as Kr,r as qr,t as Jr,u as Yr}from"./nsiteSubdomain-DmdGxq_K.js";import{_ as Xr,a as Zr,c as Qr,f as $r,i as ei,l as ti,o as ni,r as ri,u as ii}from"./ComposeDialogContent-DiIapF7b.js";import{t as ai}from"./WikipediaIcon-Df-eqPdn.js";import{t as oi}from"./BlueskyIcon-imVay4Hn.js";import{r as si}from"./tooltip-ihPDheAv.js";import{t as ci}from"./esplora-CScU9uce.js";import{i as li,o as ui,s as di}from"./musicHelpers-B9zs9cce.js";import{a as fi,c as pi,n as mi,o as hi,r as gi,s as _i,t as vi}from"./dist-HCKlYXPm.js";import{a as yi,c as bi,i as xi,n as Si,t as Ci}from"./dialog-CV-ki2ew.js";import{t as wi}from"./textarea-BgTH9QGZ.js";import{B as Ti,E as Ei,F as Di,H as Oi,L as W,N as ki,P as Ai,R as ji,U as Mi,V as Ni,k as Pi,z as Fi}from"./EmbeddedPost-DITW2flc.js";import{t as Ii}from"./getDisplayName-B6lnEGRj.js";import{n as Li,r as Ri,t as zi}from"./optimisticEvent-1jcgWuWv.js";import{i as Bi,n as Vi,r as Hi,t as Ui}from"./useLinkPreview-BkYXhPdP.js";import{i as Wi,n as Gi}from"./countries-Du6BjHuX.js";import{a as Ki,c as qi,f as Ji,l as Yi,s as Xi}from"./extraKinds-CF0LI2P1.js";import{_ as Zi,a as Qi,c as $i,d as ea,f as ta,g as na,h as ra,l as ia,m as aa,o as oa,p as sa,s as ca,u as la}from"./sidebarItems-BUQKy0PN.js";import{t as ua}from"./browser-B_X_RtOd.js";import{c as da}from"./imeta-AKViBfwk.js";import{a as fa,c as pa,i as ma,l as ha,n as ga,r as _a,s as va,t as ya}from"./LayoutContext-CseIvyNG.js";import{t as ba}from"./useInView-DH5wwDuH.js";import{it as xa,nt as Sa,r as Ca,rt as wa,tt as Ta}from"./NoteCard-D2oNQMft.js";import{n as Ea,t as Da}from"./useSearchProfiles-B9G_eYtw.js";import{s as Oa}from"./NoteMoreMenu-3p8z2oYh.js";import{t as ka}from"./useShareOrigin-CbCLa1kb.js";import{t as Aa}from"./useFeedSettings-BgA2vWPo.js";import{i as ja,n as Ma,r as Na,t as Pa}from"./SubHeaderBar-3es_mHJE.js";import{t as Fa}from"./usePageRefresh-DfuHEbb5.js";import{t as Ia}from"./useMutedAuthorFilter-CJzmJTvY.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var La=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Ra=n(((e,t)=>{t.exports=La()})),za=n((e=>{var t=Ra(),n=se(),r=Te();function i(e){var t=`https://react.dev/errors/`+e;if(1re||(e.current=ne[re],ne[re]=null,re--)}function I(e,t){re++,ne[re]=e.current,e.current=t}var L=P(null),R=P(null),ie=P(null),ae=P(null);function oe(e,t){switch(I(ie,t),I(R,e),I(L,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}F(L),I(L,e)}function ce(){F(L),F(R),F(ie)}function le(e){e.memoizedState!==null&&I(ae,e);var t=L.current,n=Hd(t,e.type);t!==n&&(I(R,e),I(L,n))}function ue(e){R.current===e&&(F(L),F(R)),ae.current===e&&(F(ae),Qf._currentValue=te)}var de,fe;function pe(e){if(de===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);de=t&&t[1]||``,fe=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{me=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?pe(n):``}function ge(e,t){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe(`Lazy`);case 13:return e.child!==t&&t!==null?pe(`Suspense Fallback`):pe(`Suspense`);case 19:return pe(`SuspenseList`);case 0:case 15:return he(e.type,!1);case 11:return he(e.type.render,!1);case 1:return he(e.type,!0);case 31:return pe(`Activity`);default:return``}}function _e(e){try{var t=``,n=null;do t+=ge(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var ve=Object.prototype.hasOwnProperty,ye=t.unstable_scheduleCallback,be=t.unstable_cancelCallback,xe=t.unstable_shouldYield,Se=t.unstable_requestPaint,Ce=t.unstable_now,we=t.unstable_getCurrentPriorityLevel,Ee=t.unstable_ImmediatePriority,De=t.unstable_UserBlockingPriority,Oe=t.unstable_NormalPriority,ke=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,je=t.log,Me=t.unstable_setDisableYieldValue,Ne=null,z=null;function Pe(e){if(typeof je==`function`&&Me(e),z&&typeof z.setStrictMode==`function`)try{z.setStrictMode(Ne,e)}catch{}}var Fe=Math.clz32?Math.clz32:Re,Ie=Math.log,Le=Math.LN2;function Re(e){return e>>>=0,e===0?32:31-(Ie(e)/Le|0)|0}var ze=256,Be=262144,Ve=4194304;function He(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ue(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=He(n))):i=He(o):i=He(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=He(n))):i=He(o)):i=He(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function We(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ge(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ke(){var e=Ve;return Ve<<=1,!(Ve&62914560)&&(Ve=4194304),e}function qe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Je(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ye(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),cn=!1;if(sn)try{var ln={};Object.defineProperty(ln,"passive",{get:function(){cn=!0}}),window.addEventListener(`test`,ln,ln),window.removeEventListener(`test`,ln,ln)}catch{cn=!1}var B=null,un=null,dn=null;function fn(){if(dn)return dn;var e,t=un,n=t.length,r,i=`value`in B?B.value:B.textContent,a=i.length;for(e=0;e=Hn),Gn=` `,Kn=!1;function qn(e,t){switch(e){case`keyup`:return Bn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Jn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Yn=!1;function Xn(e,t){switch(e){case`compositionend`:return Jn(t);case`keypress`:return t.which===32?(Kn=!0,Gn):null;case`textInput`:return e=t.data,e===Gn&&Kn?null:e;default:return null}}function Zn(e,t){if(Yn)return e===`compositionend`||!Vn&&qn(e,t)?(e=fn(),dn=un=B=null,Yn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=vr(n)}}function br(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?br(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Pt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pt(e.document)}return t}function Sr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Cr=sn&&`documentMode`in document&&11>=document.documentMode,wr=null,Tr=null,Er=null,Dr=!1;function Or(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Dr||wr==null||wr!==Pt(r)||(r=wr,`selectionStart`in r&&Sr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Er&&_r(Er,r)||(Er=r,r=Td(Tr,`onSelect`),0>=o,i-=o,bi=1<<32-Fe(t)+i|n<m?(h=d,d=null):h=d.sibling;var g=p(i,d,s[m],c);if(g===null){d===null&&(d=h);break}e&&d&&g.alternate===null&&t(i,d),a=o(g,a,m),u===null?l=g:u.sibling=g,u=g,d=h}if(m===s.length)return n(i,d),W&&Si(i,m),l;if(d===null){for(;mh?(g=m,m=null):g=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=g);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=g}if(v.done)return n(a,m),W&&Si(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return W&&Si(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=_(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),W&&Si(a,h),u}function x(e,r,o,c){if(typeof o==`object`&&o&&o.type===g&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===g){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&Sa(l)===r.type){n(e,r.sibling),c=a(r,o.props),ka(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===g?(c=si(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=oi(o.type,o.key,o.props,null,e.mode,c),ka(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ui(o,e.mode,c),c.return=e,e=c}return s(e);case T:return o=Sa(o),x(e,r,o,c)}if(j(o))return v(e,r,o,c);if(k(o)){if(l=k(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return x(e,r,Oa(o),c);if(o.$$typeof===b)return x(e,r,Xi(e,o),c);Aa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ci(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Da=0;var i=x(e,t,n,r);return Ea=null,i}catch(t){if(t===ga||t===va)throw t;var a=ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ma=ja(!0),Na=ja(!1),Pa=!1;function Fa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ia(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function La(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,J&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=$r(e),Qr(e,null,n),t}return Yr(e,r,t,n),$r(e)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}function Va(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ha=!1;function Ua(){if(Ha){var e=sa;if(e!==null)throw e}}function Wa(e,t,n,r){Ha=!1;var i=e.updateQueue;Pa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(X&p)===p:(r&p)===p){p!==0&&p===oa&&(Ha=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Pa=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Wl|=o,e.lanes=o,e.memoizedState=d}}function G(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function K(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=M.T,s={};M.T=s,As(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ks(e,t,ua(c,r),fu(e)):ks(e,t,r,fu(e))}catch(n){ks(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function ys(){}function bs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=xs(e).queue;vs(e,a,t,te,n===null?ys:function(){return Ss(e),n(r)})}function xs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jo,lastRenderedState:te},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ss(e){var t=xs(e);t.next===null&&(t=e.alternate.memoizedState),ks(e,t.next.queue,{},fu())}function Cs(){return Yi(Qf)}function ws(){return Eo().memoizedState}function Ts(){return Eo().memoizedState}function Es(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=La(n);var r=za(t,e,n);r!==null&&(mu(r,t,n),Ba(r,t,n)),t={cache:na()},e.payload=t;return}t=t.return}}function Ds(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},js(e)?Ms(t,n):(n=Xr(e,t,n,r),n!==null&&(mu(n,e,r),Ns(n,t,r)))}function Os(e,t,n){ks(e,t,n,fu())}function ks(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(js(e))Ms(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,gr(s,o))return Yr(e,t,i,0),Ll===null&&Jr(),!1}catch{}if(n=Xr(e,t,i,r),n!==null)return mu(n,e,r),Ns(n,t,r),!0}return!1}function As(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},js(e)){if(t)throw Error(i(479))}else t=Xr(e,n,r,2),t!==null&&mu(t,e,2)}function js(e){var t=e.alternate;return e===q||t!==null&&t===q}function Ms(e,t){lo=co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ns(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}var Ps={readContext:Yi,use:ko,useCallback:go,useContext:go,useEffect:go,useImperativeHandle:go,useLayoutEffect:go,useInsertionEffect:go,useMemo:go,useReducer:go,useRef:go,useState:go,useDebugValue:go,useDeferredValue:go,useTransition:go,useSyncExternalStore:go,useId:go,useHostTransitionStatus:go,useFormState:go,useActionState:go,useOptimistic:go,useMemoCache:go,useCacheRefresh:go};Ps.useEffectEvent=go;var Fs={readContext:Yi,use:ko,useCallback:function(e,t){return To().memoizedState=[e,t===void 0?null:t],e},useContext:Yi,useEffect:as,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),rs(4194308,4,ds.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rs(4194308,4,e,t)},useInsertionEffect:function(e,t){rs(4,2,e,t)},useMemo:function(e,t){var n=To();t=t===void 0?null:t;var r=e();if(uo){Pe(!0);try{e()}finally{Pe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=To();if(n!==void 0){var i=n(t);if(uo){Pe(!0);try{n(t)}finally{Pe(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ds.bind(null,q,e),[r.memoizedState,e]},useRef:function(e){var t=To();return e={current:e},t.memoizedState=e},useState:function(e){e=Vo(e);var t=e.queue,n=Os.bind(null,q,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ps,useDeferredValue:function(e,t){return gs(To(),e,t)},useTransition:function(){var e=Vo(!1);return e=vs.bind(null,q,e.queue,!0,!1),To().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=q,a=To();if(W){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ll===null)throw Error(i(349));X&127||Io(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,as(Ro.bind(null,r,o,e),[e]),r.flags|=2048,ts(9,{destroy:void 0},Lo.bind(null,r,o,n,t),null),n},useId:function(){var e=To(),t=Ll.identifierPrefix;if(W){var n=xi,r=bi;n=(r&~(1<<32-Fe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=fo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[it]=t,o[at]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&kc(t)}}return Pc(t),Ac(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ie.current,Fi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Di,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[it]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Mi(t,!0)}else e=Bd(e).createTextNode(r),e[it]=t,t.stateNode=e}return Pc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Fi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[it]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),e=!1}else n=Li(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(no(t),t):(no(t),null);if(t.flags&128)throw Error(i(558))}return Pc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Fi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[it]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),a=!1}else a=Li(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(no(t),t):(no(t),null)}return no(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Mc(t,t.updateQueue),Pc(t),null);case 4:return ce(),e===null&&xd(t.stateNode.containerInfo),Pc(t),null;case 10:return Ui(t.type),Pc(t),null;case 19:if(F(ro),r=t.memoizedState,r===null)return Pc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Nc(r,!1);else{if(Ul!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=io(e),o!==null){for(t.flags|=128,Nc(r,!1),e=o.updateQueue,t.updateQueue=e,Mc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ai(n,e),n=n.sibling;return I(ro,ro.current&1|2),W&&Si(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ce()>eu&&(t.flags|=128,a=!0,Nc(r,!1),t.lanes=4194304)}else{if(!a)if(e=io(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Mc(t,e),Nc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!W)return Pc(t),null}else 2*Ce()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,a=!0,Nc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Pc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ce(),e.sibling=null,n=ro.current,I(ro,a?n&1|2:n&1),W&&Si(t,r.treeForkCount),e);case 22:case 23:return no(t),Ya(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Pc(t),t.subtreeFlags&6&&(t.flags|=8192)):Pc(t),n=t.updateQueue,n!==null&&Mc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&F(fa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ui(ta),Pc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Ic(e,t){switch(Ti(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ui(ta),ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ue(t),null;case 31:if(t.memoizedState!==null){if(no(t),t.alternate===null)throw Error(i(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(no(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return F(ro),null;case 4:return ce(),null;case 10:return Ui(t.type),null;case 22:case 23:return no(t),Ya(),e!==null&&F(fa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ui(ta),null;case 25:return null;default:return null}}function Lc(e,t){switch(Ti(t),t.tag){case 3:Ui(ta),ce();break;case 26:case 27:case 5:ue(t);break;case 4:ce();break;case 31:t.memoizedState!==null&&no(t);break;case 13:no(t);break;case 19:F(ro);break;case 10:Ui(t.type);break;case 22:case 23:no(t),Ya(),e!==null&&F(fa);break;case 24:Ui(ta)}}function Rc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Q(t,t.return,e)}}function zc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Q(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Q(t,t.return,e)}}function Bc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{K(t,n)}catch(t){Q(e,e.return,t)}}}function Vc(e,t,n){n.props=Hs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Q(e,t,n)}}function Hc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Q(e,t,n)}}function Uc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Q(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Q(e,t,n)}else n.current=null}function Wc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Q(e,e.return,t)}}function Gc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[at]=t}catch(t){Q(e,e.return,t)}}function Kc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Kc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Zt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,n),e=e.sibling;e!==null;)Jc(e,t,n),e=e.sibling}function Yc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Yc(e,t,n),e=e.sibling;e!==null;)Yc(e,t,n),e=e.sibling}function Xc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[it]=e,t[at]=n}catch(t){Q(e,e.return,t)}}var Zc=!1,Qc=!1,$c=!1,el=typeof WeakSet==`function`?WeakSet:Set,tl=null;function nl(e,t){if(e=e.containerInfo,Rd=sp,e=xr(e),Sr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,tl=t;tl!==null;)if(t=tl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,tl=e;else for(;tl!==null;){switch(t=tl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(o,r,n),o[it]=e,_t(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=yr(s,h),v=yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,M.T=null,n=cu,cu=null;var o=iu,s=ou;if(ru=0,au=iu=null,ou=0,J&6)throw Error(i(331));var c=J;if(J|=4,Ml(o.current),wl(o,o.current,s,n),J=c,rd(0,!1),z&&typeof z.onPostCommitFiberRoot==`function`)try{z.onPostCommitFiberRoot(Ne,o)}catch{}return!0}finally{N.p=a,M.T=r,Bu(e,t)}}function Uu(e,t,n){t=fi(n,t),t=Js(e.stateNode,t,2),e=za(e,t,2),e!==null&&(Je(e,2),nd(e))}function Q(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=fi(n,e),n=Ys(2),r=za(t,n,2),r!==null&&(Xs(n,r,t,e),Je(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Il;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Vl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ll===e&&(X&n)===n&&(Ul===4||Ul===3&&(X&62914560)===X&&300>Ce()-Ql?!(J&2)&&xu(e,0):Kl|=n,Jl===X&&(Jl=0)),nd(e)}function Ku(e,t){t===0&&(t=Ke()),e=Zr(e,t),e!==null&&(Je(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return ye(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Fe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=X,a=Ue(r,r===Ll?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||We(r,a)||(n=!0,cd(r,a));r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=Ce(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}ru!==0&&ru!==5||rd(e,!1),td!==0&&(td=0)}function od(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=It(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+It(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+It(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+It(n.imageSizes)+`"]`)):i+=`[href="`+It(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+It(r)+`"][href="`+It(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),_t(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=gt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);_t(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=gt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),_t(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=gt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),_t(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ie.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=gt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=gt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=gt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+It(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),_t(t),e.head.appendChild(t))}function Pf(e){return`[src="`+It(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+It(n.href)+`"]`);if(r)return t.instance=r,_t(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),_t(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,_t(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),_t(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,_t(a),a):(r=n,(a=mf.get(o))&&(r=f({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),_t(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,_t(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),_t(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=za()}))();AbortSignal.any||(AbortSignal.any=function(e){if(e.length===0)return new AbortController().signal;if(e.length===1)return e[0];for(let t of e)if(t.aborted){let e=new AbortController;return e.abort(t.reason),e.signal}let t=new AbortController,n=e=>{let n=e.target;t.abort(n.reason)};for(let t of e)t.addEventListener(`abort`,n,{once:!0});return t.signal.addEventListener(`abort`,()=>{for(let t of e)t.removeEventListener(`abort`,n)},{once:!0}),t.signal}),AbortSignal.timeout||(AbortSignal.timeout=function(e){let t=new AbortController;return setTimeout(()=>{t.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`))},e),t.signal});var Va=class extends lt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??dt(r,t),a=this.get(i);return a||(a=new mt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){xt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>at(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>at(e,t)):t}notify(e){xt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){xt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){xt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ha=class extends lt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new St({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ua(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ua(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ua(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ua(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){xt.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>_t(t,e))}findAll(e={}){return this.getAll().filter(t=>_t(e,t))}notify(e){xt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return xt.batch(()=>Promise.all(e.map(e=>e.continue().catch(gt))))}};function Ua(e){return e.options.scope?.id}var Wa=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Va,this.#t=e.mutationCache||new Ha,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=pt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=bt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ft(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=st(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return xt.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;xt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return xt.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=xt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(gt).catch(gt)}invalidateQueries(e,t={}){return xt.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=xt.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(gt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(gt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ft(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gt).catch(gt)}fetchInfiniteQuery(e){return e.behavior=wt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gt).catch(gt)}ensureInfiniteQueryData(e){return e.behavior=wt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return bt.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ot(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ut(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ot(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ut(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=dt(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ct&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},G=t(se(),1),K=ke(),Ga=`nostr:active-pubkey`,Ka=`nostr:app-config:claimed-by`,qa=`nostr:app-config`;function Ja(){try{return localStorage.getItem(Ga)}catch{return null}}var Ya=Ja(),Xa=new Set;function Za(){return Ya}function Qa(e){if(e!==Ya){Ya=e;try{e?localStorage.setItem(Ga,e):localStorage.removeItem(Ga)}catch{}for(let e of[...Xa])e()}}function $a(e){return Xa.add(e),()=>{Xa.delete(e)}}function eo(e,t){return t?`${e}:${t}`:e}function to(e,t){try{let n=eo(e,t);if(localStorage.getItem(n)!==null)return;let r=localStorage.getItem(Ka);if(r!==null&&r!==t)return;let i=localStorage.getItem(e);if(i===null)return;localStorage.setItem(n,i),localStorage.setItem(Ka,t)}catch{}}function no(){let{logins:e}=We(),t=e[0]?.pubkey??null;return(0,G.useLayoutEffect)(()=>{Qa(t)},[t]),null}function ro(e){let{children:t,storageKey:n,defaultConfig:r}=e,i=(0,G.useSyncExternalStore)($a,Za),[a,o]=jt((0,G.useMemo)(()=>(i&&to(n,i),eo(n,i)),[n,i]),{},{serialize:JSON.stringify,deserialize:e=>{let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n={};for(let e of Object.keys(t)){let r=Zt.shape[e];if(r){let i=r.safeParse(t[e]);i.success&&(n[e]=i.data)}}if(!n.blossomServerMetadata){let e=t.blossomServers;if(Array.isArray(e)){let t=Re(Ie().url()).safeParse(e);t.success&&t.data.length>0&&(n.blossomServerMetadata={servers:t.data,updatedAt:0})}}return n}}),s=(0,G.useCallback)(e=>{Za()===i&&o(e)},[o,i]),c=(0,G.useMemo)(()=>({...r,...a,feedSettings:{...r.feedSettings,...a.feedSettings}}),[r,a]),l=(0,G.useMemo)(()=>({config:c,updateConfig:s}),[c,s]);return io(c.theme,c.customTheme,c.themes),ao(c.theme,c.customTheme,c.themes),oo(c.theme,c.customTheme,c.themes),so(c.theme,c.customTheme,c.themes),(0,K.jsx)(Mt.Provider,{value:l,children:t})}function io(e,t,n){(0,G.useLayoutEffect)(()=>{function r(){let r=Ut(e),i;i=Lt(r===`custom`?t?.colors??Rt.dark:Bt(r,n).colors);let a=document.getElementById(`theme-vars`);a||(a=document.createElement(`style`),a.id=`theme-vars`,document.head.appendChild(a)),a.textContent=i,document.documentElement.className=r,document.body.removeAttribute(`style`)}if(r(),e===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`);return e.addEventListener(`change`,r),()=>e.removeEventListener(`change`,r)}},[e,t,n])}function ao(e,t,n){let r=Ut(e),i=r===`custom`?t:Bt(r,n),a=i?.font?.family,o=i?.font?.url,s=i?.titleFont?.family,c=i?.titleFont?.url;(0,G.useEffect)(()=>{rn(a?{family:a,url:o}:void 0)},[e,a,o]),(0,G.useEffect)(()=>{nn(s?{family:s,url:c}:void 0)},[e,s,c])}var q=`theme-background`;function oo(e,t,n){let r=Ut(e),i=r===`custom`?t:Bt(r,n),a=i?.background?.url,o=i?.background?.mode??`cover`;(0,G.useEffect)(()=>{let e=document.getElementById(q);if(!a){e?.remove();return}e||(e=document.createElement(`style`),e.id=q,document.head.appendChild(e));let t;return t=o===`tile`?`body { background-image: url("${a}"); background-repeat: repeat; background-size: auto; }`:`body { background-image: url("${a}"); background-size: cover; background-repeat: no-repeat; background-position: center; background-attachment: fixed; }`,e.textContent=t,()=>{document.getElementById(q)?.remove()}},[e,a,o])}function so(e,t,n){let r=Ut(e),i=(r===`custom`?t?.colors??Rt.dark:Bt(r,n).colors).primary,a=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=!1;async function t(){if(!a.current)try{let e=await(await fetch(`/logo.svg`)).text(),t=new Blob([e],{type:`image/svg+xml`});a.current=URL.createObjectURL(t)}catch{return}if(e)return;let t=document.createElement(`canvas`);t.width=128,t.height=128;let n=t.getContext(`2d`);if(!n)return;let r=new Image;if(r.src=a.current,await new Promise((e,t)=>{r.onload=()=>e(),r.onerror=()=>t()}),e)return;let{h:o,s,l:c}=Pt(i),[l,u,d]=Ht(o,s,c);n.fillStyle=Ft(l,u,d),n.fillRect(0,0,128,128),n.globalCompositeOperation=`destination-in`,n.drawImage(r,0,0,128,128);let f=t.toDataURL(`image/png`),p=document.querySelector(`link[rel="icon"]`);p&&(p.type=`image/png`,p.href=f)}return t(),()=>{e=!0}},[i])}function co(e){if(!fn(e))return{locale:e};let t=un(e);return t?{locale:e,messages:t}:null}function lo({children:e}){let{locale:t}=pn(),[n,r]=(0,G.useState)(()=>co(t));return(0,G.useEffect)(()=>{if(n?.locale===t)return;let e=co(t);if(e){r(e);return}let i=!1;return dn(t).then(e=>{i||r({locale:t,messages:e})}).catch(()=>{i||r({locale:t})}),()=>{i=!0}},[t,n]),(0,G.useEffect)(()=>{n&&(document.documentElement.lang=n.locale)},[n]),n?(0,K.jsx)(cn,{locale:n.locale,defaultLocale:`en`,messages:n.messages,onError:e=>{e.code!==`MISSING_TRANSLATION`&&console.error(e)},children:e}):null}function uo({src:e,size:t=`w-40`,className:n}){return(0,K.jsx)(`div`,{className:`${t} shrink-0 bg-primary opacity-90 ${n??``}`,style:{maskImage:`url(${e})`,maskSize:`contain`,maskRepeat:`no-repeat`,maskPosition:`center`,WebkitMaskImage:`url(${e})`,WebkitMaskSize:`contain`,WebkitMaskRepeat:`no-repeat`,WebkitMaskPosition:`center`,aspectRatio:`1 / 1`}})}var fo;(function(e){e[e.Sunday=1]=`Sunday`,e[e.Monday=2]=`Monday`,e[e.Tuesday=3]=`Tuesday`,e[e.Wednesday=4]=`Wednesday`,e[e.Thursday=5]=`Thursday`,e[e.Friday=6]=`Friday`,e[e.Saturday=7]=`Saturday`})(fo||={});var po=hn(`LocalNotifications`,{web:()=>z(()=>import(`./web-D9LDI3pu.js`).then(e=>new e.LocalNotificationsWeb),__vite__mapDeps([0,1]))}),mo=[1,6,16,7,8,9735,8333,9802,7849,1111,1222,1244,Xn];function ho(e){let t=e??{},n=[];return t.reactions!==!1&&n.push(7),t.reposts!==!1&&n.push(6,16),t.zaps!==!1&&n.push(9735,8333),t.mentions!==!1&&n.push(1),t.comments!==!1&&n.push(1111,1222,1244),t.badges!==!1&&n.push(8),t.letters!==!1&&n.push(Xn),t.highlights!==!1&&n.push(9802),t.quizzes!==!1&&n.push(7849),n.length>0?n:[...mo]}var go=hn(`DittoNotification`);async function _o(){if(_n.getPlatform()!==`android`)return!0;try{let{ignoring:e}=await go.isIgnoringBatteryOptimizations();return e}catch{return!0}}async function vo(){if(_n.getPlatform()!==`android`)return!0;try{let{ignoring:e}=await go.requestIgnoreBatteryOptimizations();return e}catch(e){return console.error(`[notifications] Failed to request battery optimization exemption:`,e),_o()}}function yo(){let{user:e}=V(),{config:t}=Nt(),{settings:n}=en(),{data:r}=Hn(),i=n?.notificationPreferences,a=n?.notificationsEnabled??!0,o=n?.notificationStyle??`push`,s=(0,G.useMemo)(()=>ho(i),[i]),c=(0,G.useMemo)(()=>r?.pubkeys??[],[r?.pubkeys]),l=i?.onlyFollowing===!0&&c.length>0?c:void 0;(0,G.useEffect)(()=>{if(!_n.isNativePlatform())return;if(!e||!a){go.configure({});return}let n=Jn(t.relayMetadata,t.useAppRelays,t.useUserRelays).relays.filter(e=>e.read).map(e=>e.url);n.length!==0&&go.configure({userPubkey:e.pubkey,relayUrls:n,enabledKinds:s,notificationStyle:o,...l?{authors:l}:{}})},[e,t.relayMetadata,t.useAppRelays,t.useUserRelays,a,o,s,l])}var bo=`ditto:notif-prompt-shown`,xo=`ditto:battery-exemption-nudged-at`,So=1440*60*1e3;function Co(e){try{return localStorage.getItem(e)}catch{return null}}function wo(e,t){try{localStorage.setItem(e,t)}catch{}}function To(){return Date.now()-(Number(Co(xo))||0)>=So}async function Eo(e,t){return _n.getPlatform()!==`android`||!e||!t||!To()?!1:!await _o()}async function Do(){try{let{display:e}=await po.requestPermissions();return e===`granted`}catch{return!1}}function Oo(){let{user:e}=V(),{settings:t}=en(),n=t?.notificationsEnabled??!0,r=t?.notificationStyle===`persistent`,[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(0),c=(0,G.useCallback)(e=>{a(t=>t.includes(e)?t:[...t,e])},[]),l=(0,G.useCallback)(()=>{a(e=>e.slice(1)),s(e=>e+1)},[]);(0,G.useEffect)(()=>{if(!_n.isNativePlatform()||!e)return;let t=!1;return(async()=>{try{let{display:e}=await po.checkPermissions();if(t)return;if(e!==`granted`){(e===`prompt`||e===`prompt-with-rationale`)&&!Co(bo)&&c(`notifications`);return}await Eo(r,n)&&(t||c(`battery`))}catch{}})(),()=>{t=!0}},[e,r,n,c]);let u=i[0];return(0,G.useEffect)(()=>{u===`notifications`&&wo(bo,`1`),u===`battery`&&wo(xo,String(Date.now()))},[u]),u?(0,K.jsxs)(ko,{index:o,total:o+i.length,stepKey:u,children:[u===`notifications`&&(0,K.jsx)(jo,{onDone:async e=>{e&&await Eo(r,n)&&c(`battery`),l()}}),u===`battery`&&(0,K.jsx)(Mo,{onDone:l})]}):null}function ko({index:e,total:t,stepKey:n,children:r}){return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-background`,children:[(0,K.jsx)(`div`,{className:`h-1 bg-muted`,children:(0,K.jsx)(`div`,{className:`h-full bg-primary transition-all duration-500 ease-out`,style:{width:`${t>0?(e+1)/t*100:100}%`}})}),(0,K.jsx)(`div`,{className:`flex-1 flex flex-col overflow-y-auto`,children:(0,K.jsx)(`div`,{className:H(`w-full mx-auto my-auto px-6 py-12 max-w-md`,`animate-in fade-in slide-in-from-right-4 duration-300`),children:r},n)})]})}function Ao({glyph:e,title:t,description:n,children:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-8 text-center`,children:[(0,K.jsx)(`div`,{className:`flex size-20 items-center justify-center rounded-2xl bg-primary/10 text-primary`,children:e}),(0,K.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-foreground`,children:t}),(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:n})]}),r]})}function jo({onDone:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsx)(Ao,{glyph:(0,K.jsx)(pe,{className:`size-9`}),title:(0,K.jsx)(B,{id:`loginSetup.notifications.title`,defaultMessage:`Stay in the loop`}),description:(0,K.jsx)(B,{id:`loginSetup.notifications.description`,defaultMessage:`Get notified about replies, mentions and reactions even when the app is closed.`}),children:(0,K.jsxs)(`div`,{className:`w-full space-y-3`,children:[(0,K.jsx)(Rn,{size:`lg`,className:`h-12 w-full rounded-full text-base font-medium`,onClick:async()=>{n(!0);try{e(await Do())}finally{n(!1)}},disabled:t,children:(0,K.jsx)(B,{id:`loginSetup.notifications.enable`,defaultMessage:`Enable notifications`})}),(0,K.jsx)(Rn,{variant:`ghost`,className:`w-full text-muted-foreground`,onClick:()=>e(!1),disabled:t,children:(0,K.jsx)(B,{id:`loginSetup.notNow`,defaultMessage:`Not now`})})]})})}function Mo({onDone:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsx)(Ao,{glyph:(0,K.jsx)(ie,{className:`size-9`}),title:(0,K.jsx)(B,{id:`loginSetup.battery.title`,defaultMessage:`Keep it connected`}),description:(0,K.jsx)(B,{id:`loginSetup.battery.description`,defaultMessage:`Android's battery optimization suspends Ditto's background connection, which silently stops notifications. Allowing background usage keeps them arriving.`}),children:(0,K.jsxs)(`div`,{className:`w-full space-y-3`,children:[(0,K.jsx)(Rn,{size:`lg`,className:`h-12 w-full rounded-full text-base font-medium`,onClick:async()=>{n(!0);try{await vo()}catch{}finally{n(!1),e()}},disabled:t,children:(0,K.jsx)(B,{id:`loginSetup.battery.allow`,defaultMessage:`Allow background usage`})}),(0,K.jsx)(Rn,{variant:`ghost`,className:`w-full text-muted-foreground`,onClick:e,disabled:t,children:(0,K.jsx)(B,{id:`loginSetup.notNow`,defaultMessage:`Not now`})})]})})}var No=8e3;function Po(e,t){try{return localStorage.getItem(Pr(e,`sync-done:${t}`))===`1`}catch{return!1}}function Fo(){let{nostr:e}=Ge(),{user:t}=V(),{config:n,updateConfig:r}=Nt(),i=ht(),[a,o]=(0,G.useState)(()=>t&&Po(n.appId,t.pubkey)?`complete`:`idle`),s=(0,G.useRef)(!1),c=(0,G.useCallback)(()=>{if(t)try{localStorage.setItem(Pr(n.appId,`sync-done:${t.pubkey}`),`1`)}catch{}},[t,n.appId]),l=(0,G.useRef)({config:n,updateConfig:r,markSyncComplete:c});return(0,G.useEffect)(()=>{l.current={config:n,updateConfig:r,markSyncComplete:c}}),(0,G.useEffect)(()=>{if(!t){o(`idle`),s.current=!1;return}if(Po(n.appId,t.pubkey)){o(`complete`);return}if(s.current)return;s.current=!0,o(`syncing`);let r=new AbortController,a=setTimeout(()=>r.abort(),No);return(async()=>{let s=!1;try{let[a,o,c,u]=await Promise.all([e.query([{kinds:[10002],authors:[t.pubkey],limit:1}],{signal:r.signal}).catch(()=>[]),e.query([{kinds:[10063],authors:[t.pubkey],limit:1}],{signal:r.signal}).catch(()=>[]),e.query([{kinds:[30078],authors:[t.pubkey],"#d":[`${n.appId}/metadata`],limit:1}],{signal:r.signal}).catch(()=>[]),e.query([{kinds:[1e4],authors:[t.pubkey],limit:1}],{signal:r.signal}).catch(()=>[])]);if(a.length>0){let e=a[0];if(i.setQueryData([`relayList`,t.pubkey],e),e.created_at>l.current.config.relayMetadata.updatedAt){let t=e.tags.filter(([e])=>e===`r`).map(([,e,t])=>({url:e.replace(/\/+$/,``),read:!t||t===`read`,write:!t||t===`write`}));t.length>0&&(l.current.updateConfig(n=>({...n,relayMetadata:{relays:t,updatedAt:e.created_at}})),s=!0)}}if(o.length>0){let e=o[0];if(i.setQueryData([`blossomServerList`,t.pubkey],e),e.created_at>l.current.config.blossomServerMetadata.updatedAt){let t=Nr(e);t.length>0&&(l.current.updateConfig(n=>({...n,blossomServerMetadata:{servers:t,updatedAt:e.created_at}})),s=!0)}}if(c.length>0&&c[0].content&&t.signer.nip44){let e=c[0];try{let n=await t.signer.nip44.decrypt(t.pubkey,e.content),r=JSON.parse(n),a=$t.safeParse(r);a.success||console.warn(`Encrypted settings failed validation during initial sync:`,a.error.issues);let o=a.success?a.data:{};l.current.updateConfig(e=>{let t={...e};return o.theme&&(t.theme=o.theme),o.customTheme&&(t.customTheme=o.customTheme),o.autoShareTheme!==void 0&&(t.autoShareTheme=o.autoShareTheme),o.useAppRelays!==void 0&&(t.useAppRelays=o.useAppRelays),o.useUserRelays!==void 0&&(t.useUserRelays=o.useUserRelays),o.feedSettings&&(t.feedSettings={...e.feedSettings,...o.feedSettings}),o.contentWarningPolicy&&(t.contentWarningPolicy=o.contentWarningPolicy),o.exemptFollowsFromFilters!==void 0&&(t.exemptFollowsFromFilters=o.exemptFollowsFromFilters),o.sidebarOrder&&o.sidebarOrder.length>0&&(t.sidebarOrder=o.sidebarOrder),o.sidebarWidgets&&(t.sidebarWidgets=o.sidebarWidgets),o.homePage&&(t.homePage=o.homePage),o.corsProxy&&(t.corsProxy=o.corsProxy),o.faviconUrl&&(t.faviconUrl=o.faviconUrl),o.linkPreviewUrl&&(t.linkPreviewUrl=o.linkPreviewUrl),o.currencyDisplay&&(t.currencyDisplay=o.currencyDisplay),t}),i.setQueryData([`encryptedSettings`,t.pubkey],e),i.setQueryData([`parsedSettings`,e.id],o),o.lastSync&&Qt(t.pubkey,o.lastSync),s=!0}catch(e){console.error(`Failed to decrypt settings during initial sync:`,e),s=!0}}if(u.length>0){let e=u[0];i.setQueryData([`muteList`,t.pubkey],e);let r=Lr(e.tags),a=[];if(e.content)try{let n=e.content.includes(`?iv=`),r=null;n&&t.signer.nip04?r=await t.signer.nip04.decrypt(t.pubkey,e.content):!n&&t.signer.nip44&&(r=await t.signer.nip44.decrypt(t.pubkey,e.content)),r&&(a=Lr(JSON.parse(r)))}catch(e){console.error(`Failed to decrypt mute list during initial sync:`,e)}let o=new Set,c=[];for(let e of[...r,...a]){let t=`${e.type}:${e.value}`;o.has(t)||(o.add(t),c.push(e))}i.setQueryData([`muteItems`,e.id],c),Fr(n.appId,t.pubkey,c),s=!0}}catch(e){e instanceof Error&&e.name===`AbortError`?console.warn(`Initial sync timed out`):console.error(`Initial sync failed:`,e)}clearTimeout(a),s?(o(`found`),setTimeout(()=>{l.current.markSyncComplete(),o(`complete`)},1200)):o(`not-found`)})(),()=>{clearTimeout(a),r.abort()}},[t,e,n.appId,i]),{phase:a,markComplete:(0,G.useCallback)(()=>{c(),o(`complete`)},[c])}}var Io=64*1024;function Lo(e,t){if(e===`image/gif`)return!0;if(e===`image/webp`){for(let e=12;e+4<=Math.min(t.length,1024);e++)if(t[e]===65&&t[e+1]===78&&t[e+2]===73&&t[e+3]===77)return!0;return!1}if(e===`image/png`||e===`image/apng`){for(let e=8;e+4<=Math.min(t.length,4096);e++){if(t[e]===97&&t[e+1]===99&&t[e+2]===84&&t[e+3]===76)return!0;if(t[e]===73&&t[e+1]===68&&t[e+2]===65&&t[e+3]===84)return!1}return!1}return!1}var Ro=(0,G.lazy)(()=>z(()=>import(`./ImageCropDialog-Bf-7Rd4a.js`).then(e=>({default:e.ImageCropDialog})),__vite__mapDeps([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]))),zo=(0,G.lazy)(()=>z(()=>import(`./ThemeSelector-DtIUEiRe.js`).then(e=>({default:e.ThemeGrid})),__vite__mapDeps([30,3,4,5,31,32,33,34,35,36,37,38,39,40,41,1,42,43,44,8,7,9,10,11,45,46,47,16,17,20,21,15,22,23,48,13,14,18,19,12,49,50,51,25,52,28,53,54,55,56,57,58,59])));function Bo({children:e}){let{user:t}=V(),{phase:n,markComplete:r}=Fo(),{isLoading:i}=en(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(!1),u=(0,G.useCallback)(()=>c(!0),[]),d=(0,G.useCallback)(()=>{c(!1),r()},[r]),f=(0,G.useMemo)(()=>({startSignup:u}),[u]);return s?(0,K.jsxs)(zr.Provider,{value:f,children:[a&&(0,K.jsx)(`div`,{className:`invisible`,children:e}),(0,K.jsx)(Ko,{onComplete:d,onPreload:()=>o(!0),isSignup:!0})]}):t?n===`syncing`||n===`found`?(0,K.jsx)(zr.Provider,{value:f,children:(0,K.jsx)(Vo,{phase:n})}):n===`not-found`?(0,K.jsxs)(zr.Provider,{value:f,children:[a&&(0,K.jsx)(`div`,{className:`invisible`,children:e}),(0,K.jsx)(Ko,{onComplete:r,onPreload:()=>o(!0)})]}):n===`complete`&&i&&!l.current&&!(t&&tn(t.pubkey)>0)?(0,K.jsx)(zr.Provider,{value:f,children:(0,K.jsx)(Vo,{phase:`syncing`})}):(l.current=!0,(0,K.jsxs)(zr.Provider,{value:f,children:[e,(0,K.jsx)(Oo,{})]})):(l.current=!1,(0,K.jsx)(zr.Provider,{value:f,children:e}))}function Vo({phase:e}){return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-8 px-6 text-center max-w-sm`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-primary/10 animate-ping opacity-30`}),(0,K.jsx)(Fn,{size:72,className:`relative`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,K.jsxs)(`div`,{className:`relative w-10 h-10`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-[2.5px] border-primary/20`}),(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-[2.5px] border-transparent border-t-primary animate-spin`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e===`found`?`Settings restored`:`Syncing your settings...`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`found`?`Welcome back! Loading your experience...`:`Checking for your preferences across devices`})]})]}),e===`syncing`&&(0,K.jsx)(`div`,{className:`flex gap-1.5`,children:[0,1,2].map(e=>(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-primary/40 animate-pulse`,style:{animationDelay:`${e*200}ms`}},e))}),e===`found`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-primary`,children:[(0,K.jsx)(he,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`All set`})]})]})})}var Ho=39089,Uo=[`781a1527055f74c1f70230f10384609b34548f8ab6a0a6caa74025827f9fdae5`,`532d830dffe09c13e75e8b145c825718fc12b0003f61d61e9077721c7fff93cb`],Wo=[`theme`,`keygen`,`download`,`profile`,`follows`,`outro`],Go=[`theme`,`follows`,`outro`];function Ko({onComplete:e,onPreload:t,isSignup:n=!1}){let{nostr:r}=Ge(),{config:i}=Nt(),{user:a}=V(),o=Rr(),{setTheme:s,applyCustomTheme:c}=Jt(),l=n?Wo:Go,[u,d]=(0,G.useState)(l[0]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(``),v=(0,G.useMemo)(()=>{if(g)try{let e=tt.decode(g);return e.type===`nsec`?$e(e.data):void 0}catch{return}},[g]);(0,G.useEffect)(()=>{if(n)return Wt(),()=>qt()},[n]);let y=(0,G.useSyncExternalStore)($a,Za),b=(0,G.useRef)(!1),[x,S]=(0,G.useState)(!1);(0,G.useEffect)(()=>{!n||b.current||x||v&&(a?.pubkey!==v||y!==v||S(!0))},[n,v,a?.pubkey,y,x]),(0,G.useEffect)(()=>{if(!x||b.current)return;b.current=!0,qt();let e=Vt();e?.customTheme?c(e.customTheme):e?.theme&&s(e.theme)},[x,c,s]);let C=l.indexOf(u)/(l.length-1)*100,w=(0,G.useCallback)(e=>d(e),[]),T=(0,G.useCallback)(()=>{let e=l.indexOf(u);e{let e=l.indexOf(u);e>0&&d(l[e-1])},[u,l]),D=(0,G.useCallback)(()=>{let e=Xe(),t=tt.nsecEncode(e);_(t),T()},[T]),O=(0,G.useCallback)(async()=>{try{let e=tt.decode(g);if(e.type!==`nsec`)throw Error(`Invalid nsec`);let t=$e(e.data);await vn(tt.npubEncode(t),g,i.appName)===`saved-to-file`&&An({title:`Secret key saved`,description:`Your secret key was saved to the Documents folder on your device.`}),o.nsec(g),T()}catch{An({title:`Save failed`,description:`Could not save the key. Please copy it manually.`,variant:`destructive`})}},[g,o,T,i.appName]),k=(0,G.useCallback)(async()=>{p(!0);let e=!1;if(a)try{let t=await r.query([{kinds:[3],authors:[a.pubkey],limit:1}],{signal:AbortSignal.timeout(5e3)});t.length>0&&(e=t[0].tags.filter(([e])=>e===`p`).length>0)}catch{e=!0}h(e),p(!1),w(e?`outro`:`follows`)},[a,r,w]);return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background`,children:[(0,K.jsx)(`div`,{className:`h-1 bg-muted`,children:(0,K.jsx)(`div`,{className:`h-full bg-primary transition-all duration-500 ease-out`,style:{width:`${C}%`}})}),(0,K.jsx)(`div`,{className:`flex-1 flex flex-col overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:H(`w-full mx-auto my-auto px-6 py-12`,u===`follows`?`max-w-2xl`:`max-w-md`),children:[u===`keygen`&&(0,K.jsx)(qo,{onGenerate:D}),u===`download`&&(0,K.jsx)(Jo,{nsec:g,onContinue:O}),u===`profile`&&(0,K.jsx)(Yo,{onNext:k,isSaving:f,expectedPubkey:v}),u===`theme`&&(0,K.jsx)(Xo,{onNext:n?T:k,onBack:E,isFirst:n&&l.indexOf(`theme`)===0,isSaving:!n&&f}),u===`follows`&&m===!1&&(0,K.jsx)(Qo,{onNext:e=>{e&&t(),w(`outro`)},onBack:E,expectedPubkey:v}),u===`outro`&&(0,K.jsx)(ns,{onComplete:e})]})})]})}function qo({onGenerate:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-8 animate-in fade-in slide-in-from-bottom-4 duration-500`,children:[(0,K.jsx)(Fn,{size:80}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Create your account`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed max-w-xs mx-auto`,children:`Your identity on Nostr is a cryptographic key. We'll generate one for you now.`})]}),(0,K.jsxs)(Rn,{size:`lg`,className:`w-full max-w-xs gap-2 rounded-full h-12`,onClick:e,children:[`Generate my key`,(0,K.jsx)(D,{className:`w-4 h-4`})]})]})}function Jo({nsec:e,onContinue:t}){let{config:n}=Nt(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-400`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Your secret key`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This secret key controls your account on `,n.appName,`. You'll need it to log in later. Without it, you'll lose your account.`]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(yr,{type:r?`text`:`password`,value:e,readOnly:!0,onFocus:e=>e.currentTarget.select(),onClick:e=>e.currentTarget.select(),className:`pr-10 font-mono text-base md:text-sm`}),(0,K.jsx)(Rn,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-full px-3 hover:bg-transparent`,onClick:()=>i(!r),children:r?(0,K.jsx)(I,{className:`h-4 w-4 text-muted-foreground`}):(0,K.jsx)(be,{className:`h-4 w-4 text-muted-foreground`})})]}),r&&(0,K.jsx)(`div`,{className:`p-3 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-800 animate-in fade-in slide-in-from-top-1 duration-200`,children:(0,K.jsxs)(`p`,{className:`text-xs text-amber-900 dark:text-amber-300`,children:[`NEVER share your secret key with anyone. Avoid screenshotting your key or pasting it anywhere except a password manager. If shared, others will be able to access your account.`,` `,(0,K.jsx)(`a`,{href:`https://soapbox.pub/blog/managing-nostr-keys/`,onClick:e=>{e.preventDefault(),Sn(`https://soapbox.pub/blog/managing-nostr-keys/`)},className:`underline underline-offset-2 hover:no-underline`,children:`Learn more`})]})}),(0,K.jsx)(Rn,{size:`lg`,className:`w-full gap-2 rounded-full h-12`,onClick:async()=>{if(!a){o(!0);try{await t()}finally{o(!1)}}},disabled:a,children:a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{className:`w-4 h-4 animate-spin`}),` Saving…`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{className:`w-4 h-4`}),` Save Key`]})})]})}function Yo({onNext:e,isSaving:t=!1,expectedPubkey:n}){let{user:r}=V(),i=ht(),{mutateAsync:a,isPending:o}=zn(),{mutateAsync:s,isPending:c}=Hr(),l=(0,G.useRef)(null),u=(0,G.useRef)(`picture`),[d,f]=(0,G.useState)({name:``,about:``,picture:``,banner:``,website:``,shape:``}),[p,m]=(0,G.useState)(null),h=(0,G.useCallback)(e=>{u.current=e,l.current?.click()},[]),g=(0,G.useCallback)(async(e,t)=>{try{let[[,n]]=await s(e);f(e=>({...e,[t]:n}))}catch{An({title:`Upload failed`,description:`Please try again.`,variant:`destructive`})}},[s]),_=(0,G.useCallback)(async e=>{let t=e.target.files?.[0];if(!t)return;e.target.value=``;let n=u.current,r=new Uint8Array(await t.slice(0,Io).arrayBuffer());if(Lo(t.type,r)){await g(t,n);return}m({imageSrc:URL.createObjectURL(t),aspect:n===`picture`?1:3,field:n})},[g]),v=(0,G.useCallback)(async e=>{if(!p)return;let{field:t,imageSrc:n}=p;URL.revokeObjectURL(n),m(null);let r=new File([e],`${t}.jpg`,{type:`image/jpeg`});await g(r,t)},[p,g]),y=(0,G.useCallback)(()=>{p&&URL.revokeObjectURL(p.imageSrc),m(null)},[p]),b=(0,G.useCallback)(async()=>{if(r){if(n&&r.pubkey!==n){An({title:`Profile not saved`,description:`The new account is not active yet, so your profile was not published (this prevents overwriting another account). You can update it later from settings.`,variant:`destructive`});return}if(Object.values(d).some(e=>e))try{let{shape:e,...t}=d,n={...t};e&&Zn(e)&&(n.shape=e);for(let e in n)n[e]===``&&delete n[e];await a({kind:0,content:JSON.stringify(n),tags:[]}),i.invalidateQueries({queryKey:[`logins`]}),i.invalidateQueries({queryKey:[`author`,r.pubkey]})}catch{An({title:`Profile failed`,description:`Your account was created but profile setup failed. You can update it later.`,variant:`destructive`})}e()}},[r,d,a,i,e,n]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-400`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(uo,{src:`/profile-intro.png`}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Set up your profile`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tell people a bit about yourself. You can always change this later.`})]})]}),(0,K.jsx)(`input`,{ref:l,type:`file`,accept:`image/*`,className:`hidden`,onChange:_}),p&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Ro,{open:!0,imageSrc:p.imageSrc,aspect:p.aspect,title:p.field===`picture`?`Crop Profile Picture`:`Crop Banner`,onCancel:y,onCrop:v})}),(0,K.jsx)(`div`,{className:H(o&&`opacity-50 pointer-events-none`),children:(0,K.jsx)(Ar,{metadata:d,onChange:e=>f(t=>({...t,...e})),onPickImage:h,onAvatarShape:e=>f(t=>({...t,shape:e})),showNip05:!1})}),c&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(F,{className:`size-3.5 animate-spin`}),` Uploading image…`]}),(0,K.jsx)(Rn,{onClick:b,className:`w-full rounded-full h-11 gap-1.5`,disabled:o||c||t,children:o||t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{className:`w-4 h-4 animate-spin`}),` Saving…`]}):(0,K.jsxs)(K.Fragment,{children:[`Continue `,(0,K.jsx)(D,{className:`w-4 h-4`})]})})]})}function Xo({onNext:e,onBack:t,isFirst:n=!1,isSaving:r=!1}){let{theme:i,customTheme:a,themes:o}=Jt(),s=Ut(i),c=(s===`custom`?a:Bt(s,o))?.background?.url;return(0,K.jsxs)(K.Fragment,{children:[c&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-0 bg-cover bg-center opacity-50 transition-all duration-700`,style:{backgroundImage:`url(${c})`}}),(0,K.jsxs)(`div`,{className:H(`relative z-10 flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-400`,`sm:rounded-2xl sm:transition-[background-color,backdrop-filter] sm:duration-700`,c?`sm:bg-background/60 sm:backdrop-blur-md sm:-mx-4 sm:px-4 sm:py-4`:``),children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Choose your look`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a theme that feels right.`})]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(kr,{className:`h-24 w-full rounded-xl`}),children:(0,K.jsx)(zo,{columns:`scroll`,limit:9})}),n?(0,K.jsx)(Rn,{onClick:e,className:`w-full rounded-full h-11 gap-1.5`,disabled:r,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{className:`w-4 h-4 animate-spin`}),` Saving...`]}):(0,K.jsxs)(K.Fragment,{children:[`Continue `,(0,K.jsx)(D,{className:`w-4 h-4`})]})}):(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(Rn,{variant:`ghost`,onClick:t,className:`flex-1 rounded-full h-11`,disabled:r,children:`Back`}),(0,K.jsx)(Rn,{onClick:e,className:`flex-1 rounded-full h-11 gap-1.5`,disabled:r,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{className:`w-4 h-4 animate-spin`}),` Saving...`]}):(0,K.jsxs)(K.Fragment,{children:[`Continue `,(0,K.jsx)(D,{className:`w-4 h-4`})]})})]})]})]})}function Zo(e){let t=t=>e.tags.find(([e])=>e===t)?.[1];return{title:t(`title`)||t(`name`)||`Untitled Pack`,description:t(`description`)||t(`summary`)||``,image:t(`image`)||t(`thumb`)||t(`banner`),pubkeys:e.tags.filter(([e])=>e===`p`).map(([,e])=>e)}}function Qo({onNext:e,onBack:t,expectedPubkey:n}){let{nostr:r}=Ge(),{user:i}=V(),{mutateAsync:a}=zn(),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(!0),[u,d]=(0,G.useState)(new Set),[f,p]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await r.query([{kinds:[Ho],authors:Uo,limit:100}],{signal:AbortSignal.timeout(8e3)}),n=new Map;for(let e of t){let t=e.tags.find(([e])=>e===`d`)?.[1]??``,r=`${e.pubkey}:${t}`,i=n.get(r);(!i||e.created_at>i.created_at)&&n.set(r,e)}let i=[...n.values()].filter(e=>e.tags.some(([e])=>e===`p`)).sort((e,t)=>t.created_at-e.created_at);e||s(i)}catch(e){console.warn(`Failed to fetch suggested follow packs:`,e)}finally{e||l(!1)}})(),()=>{e=!0}},[r]);let m=(0,G.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,G.useCallback)(async()=>{if(i){if(u.size===0){e(!1);return}if(n&&i.pubkey!==n){An({title:`Follows not saved`,description:`The new account is not active yet, so your follows were not saved (this prevents modifying another account). You can follow people later from the app.`,variant:`destructive`}),e(!1);return}p(!0);try{let t=new Set;for(let e of o)if(u.has(e.id))for(let[n,r]of e.tags)n===`p`&&r&&t.add(r);let n=await Cn(r,{kinds:[3],authors:[i.pubkey]}),s=n?.tags.filter(([e])=>e===`p`)??[],c=n?.tags.filter(([e])=>e!==`p`)??[],l=new Set(s.map(([,e])=>e)),d=[...t].filter(e=>!l.has(e)).map(e=>[`p`,e]);await a({kind:3,content:n?.content??``,tags:[...c,...s,...d],prev:n??void 0}),e(!0)}catch(t){console.error(`Failed to follow packs:`,t),An({title:`Couldn't save your follows`,description:`Something went wrong. You can follow people later from the app.`,variant:`destructive`}),e(!1)}finally{p(!1)}}},[i,r,a,n,o,u,e]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-400`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Find your people`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your feed is empty! Pick a few packs that look interesting — tap to select, then continue to follow everyone in them at once.`})]}),c?(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:Array.from({length:6}).map((e,t)=>(0,K.jsx)(ts,{},t))}):o.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-6`,children:`Couldn't load suggestions right now. You can find follow packs later in the app.`}):(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:o.map(e=>(0,K.jsx)($o,{event:e,selected:u.has(e.id),onToggle:()=>m(e.id)},e.id))}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(Rn,{variant:`ghost`,onClick:t,disabled:f,className:`flex-1 rounded-full h-11`,children:`Back`}),(0,K.jsx)(Rn,{onClick:h,disabled:f,className:`flex-1 rounded-full h-11 gap-1.5`,children:f?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(F,{className:`w-4 h-4 animate-spin`}),`Following...`]}):(0,K.jsxs)(K.Fragment,{children:[u.size>0?`Follow ${u.size} pack${u.size===1?``:`s`}`:`Skip for now`,(0,K.jsx)(D,{className:`w-4 h-4`})]})})]})]})}function $o({event:e,selected:t,onToggle:n}){let{title:r,pubkeys:i}=(0,G.useMemo)(()=>Zo(e),[e]),a=(0,G.useMemo)(()=>i.slice(0,4),[i]),{data:o}=jr(a);return(0,K.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:H(`group relative text-left rounded-xl ring-1 overflow-hidden transition-all`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,`motion-safe:active:scale-[0.98]`,t?`ring-2 ring-primary bg-primary/5`:`ring-border hover:ring-foreground/20 hover:bg-muted/40`),children:[(0,K.jsx)(`div`,{className:H(`absolute top-2 right-2 z-10 size-5 rounded-full flex items-center justify-center transition-colors`,t?`bg-primary text-primary-foreground`:`bg-background/80 ring-1 ring-border text-transparent group-hover:text-muted-foreground`),children:(0,K.jsx)(he,{className:`w-3 h-3`,strokeWidth:3})}),(0,K.jsxs)(`div`,{className:`p-3 space-y-2.5`,children:[(0,K.jsx)(`div`,{className:`pr-6`,children:(0,K.jsx)(`h3`,{className:`font-semibold text-sm leading-snug line-clamp-2`,children:r})}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(`div`,{className:`flex -space-x-2`,children:a.map(e=>{let t=o?.get(e),n=t?.metadata?.name||t?.metadata?.display_name||`Anonymous`;return(0,K.jsx)(es,{src:t?.metadata?.picture,name:n},e)})}),i.length>a.length&&(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`+`,i.length-a.length]})]})]})]})}function es({src:e,name:t,metadata:n}){return(0,K.jsxs)(nr,{className:`size-7 ring-2 ring-background`,shape:$n(n),children:[(0,K.jsx)(er,{src:e,alt:t}),(0,K.jsx)(Qn,{className:`bg-primary/15 text-primary text-[10px]`,children:t[0]?.toUpperCase()})]})}function ts(){return(0,K.jsx)(`div`,{className:`rounded-xl ring-1 ring-border overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`p-3 space-y-2.5`,children:[(0,K.jsx)(kr,{className:`h-4 w-24`}),(0,K.jsx)(`div`,{className:`flex -space-x-2`,children:Array.from({length:4}).map((e,t)=>(0,K.jsx)(kr,{className:`size-7 rounded-full ring-2 ring-background`},t))})]})})}function ns({onComplete:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-8 animate-in fade-in slide-in-from-bottom-4 duration-500`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Fn,{size:72}),(0,K.jsx)(`div`,{className:`absolute -bottom-1 -right-1 bg-primary/10 rounded-full p-1.5`,children:(0,K.jsx)(u,{className:`w-5 h-5 text-primary fill-primary`})})]}),(0,K.jsxs)(`div`,{className:`space-y-3 max-w-xs`,children:[(0,K.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`You're all set`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed`,children:`That's it! Go find something wonderful, share something fun, and make yourself at home.`})]}),(0,K.jsxs)(Rn,{size:`lg`,className:`w-full max-w-xs gap-2 rounded-full h-12`,onClick:e,children:[`Let's go`,(0,K.jsx)(D,{className:`w-4 h-4`})]})]})}function rs(){return yo(),null}var is=50,as=class{executeBatch;pending=[];scheduled=!1;constructor(e){this.executeBatch=e}request(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}this.pending.push({key:e,resolve:n,reject:r,signal:t}),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush()))})}async flush(){let e=this.pending;if(this.pending=[],this.scheduled=!1,e.length===0)return;let t=e.filter(e=>!e.signal?.aborted),n=e.filter(e=>e.signal?.aborted);for(let e of n)e.reject(e.signal.reason);if(t.length===0)return;let r=[],i=new Set;for(let e of t)i.has(e.key)||(i.add(e.key),r.push(e.key));let a=new AbortController,o=t.map(e=>e.signal).filter(Boolean);if(o.length>0&&o.length===t.length){let e=()=>{o.every(e=>e.aborted)&&a.abort(o[0].reason)};for(let t of o)t.addEventListener(`abort`,e,{once:!0})}try{let e=new Map,n=[];for(let e=0;e{let n=await this.executeBatch(t,a.signal);for(let[t,r]of n)e.set(t,r)}));for(let n of t)n.signal?.aborted?n.reject(n.signal.reason):n.resolve(e.get(n.key))}catch(e){for(let n of t)n.reject(e)}}};function os(e){return Object.keys(e).every(e=>e===`ids`||e===`limit`)&&Array.isArray(e.ids)&&e.ids.length===1}var ss=new Set([0,3,1e4,10001,10002,10003,10015,10030,10063,15683,16767,16769]);function cs(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`limit`)&&e.kinds?.length===1&&ss.has(e.kinds[0])&&e.authors?.length===1&&e.limit!==void 0}var ls=class{pool;pending=[];scheduled=!1;constructor(e){this.pool=e}request(e,t,n){return new Promise((r,i)=>{if(n?.aborted){i(n.reason);return}this.pending.push({pubkey:e,kind:t,resolve:r,reject:i,signal:n}),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush()))})}async flush(){let e=this.pending;if(this.pending=[],this.scheduled=!1,e.length===0)return;let t=e.filter(e=>!e.signal?.aborted);for(let t of e.filter(e=>e.signal?.aborted))t.reject(t.signal.reason);if(t.length===0)return;let n=new Map;for(let{pubkey:e,kind:r}of t)n.has(e)||n.set(e,new Set),n.get(e).add(r);let r=new Map;for(let[e,t]of n){let n=[...t].sort((e,t)=>e-t).join(`,`);r.has(n)||r.set(n,{kinds:[...t].sort((e,t)=>e-t),pubkeys:[]}),r.get(n).pubkeys.push(e)}let i=new AbortController,a=t.map(e=>e.signal).filter(Boolean);if(a.length>0&&a.length===t.length){let e=()=>{a.every(e=>e.aborted)&&i.abort(a[0].reason)};for(let t of a)t.addEventListener(`abort`,e,{once:!0})}let o=new Map;try{await Promise.all([...r.values()].map(async({kinds:e,pubkeys:t})=>{let n=await this.pool.query([{kinds:e,authors:t,limit:e.length*t.length}],{signal:i.signal});for(let e of t)o.has(e)||o.set(e,new Map);for(let e of n){let t=o.get(e.pubkey);if(!t)continue;let n=t.get(e.kind);(!n||e.created_at>n.created_at)&&t.set(e.kind,e)}}))}catch(e){for(let n of t)n.reject(e);return}let s=[...r.values()].filter(({kinds:e})=>e.includes(0)).flatMap(({pubkeys:e})=>e).filter(e=>!o.get(e)?.get(0));if(s.length>0&&!i.signal.aborted)try{let e=[];for(let t=0;t{let t=await this.pool.query([{kinds:[0],authors:e,limit:e.length}],{signal:i.signal});for(let e of t){o.has(e.pubkey)||o.set(e.pubkey,new Map);let t=o.get(e.pubkey),n=t.get(0);(!n||e.created_at>n.created_at)&&t.set(0,e)}}))}catch{}for(let e of t)e.signal?.aborted?e.reject(e.signal.reason):e.resolve(o.get(e.pubkey)?.get(e.kind))}};function us(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`#e`||e===`limit`)&&e.kinds?.length===1&&e.kinds[0]===7&&e.authors?.length===1&&e[`#e`]!==void 0&&Array.isArray(e[`#e`])&&e[`#e`].length===1}function ds(e){let t=Object.keys(e),n=e.kinds;if(!n||n.length===0)return!1;let r=e[`#e`];return t.every(e=>e===`kinds`||e===`authors`||e===`#e`||e===`limit`)&&n.every(e=>e===6||e===16)&&e.authors?.length===1&&r!==void 0&&Array.isArray(r)&&r.length===1}function fs(e){return Object.keys(e).every(e=>e===`kinds`||e===`#e`||e===`limit`)&&Array.isArray(e.kinds)&&e.kinds.length>0&&!e.authors&&e[`#e`]!==void 0&&Array.isArray(e[`#e`])&&e[`#e`].length===1}function ps(e){return e[`#e`][0]}function ms(e){if(e.length<2)return null;let t=null;for(let n of e){let e=Object.keys(n),r=e.every(e=>e===`kinds`||e===`#e`||e===`limit`)&&n[`#e`]!==void 0&&Array.isArray(n[`#e`])&&n[`#e`].length===1,i=e.every(e=>e===`kinds`||e===`#q`||e===`limit`)&&n[`#q`]!==void 0&&Array.isArray(n[`#q`])&&n[`#q`].length===1;if(!r&&!i)return null;let a=r?n[`#e`][0]:n[`#q`][0];if(t===null)t=a;else if(a!==t)return null}return t}function hs(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`#d`||e===`limit`)&&e.kinds?.length===1&&e.authors?.length===1&&e[`#d`]!==void 0&&Array.isArray(e[`#d`])&&e[`#d`].length===1}var gs=class{pool;replaceableCollector;eventCollector;reactionCollectors=new Map;repostCollectors=new Map;dTagCollectors=new Map;eTagCollectors=new Map;multiFilterCollectors=new Map;store;loggedInPubkeys=new Set;followedPubkeys;constructor(e,t){this.pool=e,this.store=t,this.replaceableCollector=new ls(e),this.eventCollector=new as((e,t)=>this.executeEventBatch(e,t))}setLoggedInPubkeys(e){let t=new Set(e.filter(Bn));t.size===this.loggedInPubkeys.size&&[...t].every(e=>this.loggedInPubkeys.has(e))||(this.loggedInPubkeys=t,this.followedPubkeys=void 0)}getFollowedPubkeys(e){return this.followedPubkeys??=(async()=>{let t=[...this.loggedInPubkeys];if(t.length===0)return new Set;let n=await e.query([{kinds:[3],authors:t}]),r=new Set;for(let e of n)if(this.loggedInPubkeys.has(e.pubkey))for(let[t,n]of e.tags)t===`p`&&Bn(n)&&r.add(n);return r})(),this.followedPubkeys}shouldCache(e,t){return this.loggedInPubkeys.has(e.pubkey)?!0:Be.replaceable(e.kind)?t.has(e.pubkey):!1}cacheEvents(e){let t=this.store;!t||e.length===0||(async()=>{try{let n=await this.getFollowedPubkeys(t),r=e.filter(e=>this.shouldCache(e,n));if(r.length===0)return;await Promise.all(r.map(e=>t.event(e))),r.some(e=>e.kind===3&&this.loggedInPubkeys.has(e.pubkey))&&(this.followedPubkeys=void 0)}catch{}})()}async query(e,t){let n=await this.queryInner(e,t);return this.cacheEvents(n),n}async queryInner(e,t){if(e.length===1){let n=e[0];if(os(n)){let e=await this.eventCollector.request(n.ids[0],t?.signal);return e?[e]:[]}if(cs(n)){let e=await this.replaceableCollector.request(n.authors[0],n.kinds[0],t?.signal);return e?[e]:[]}if(us(n)){let e=n.authors[0],r=n[`#e`][0],i=this.reactionCollectors.get(e);i||(i=new as((t,n)=>this.executeReactionBatch(e,t,n)),this.reactionCollectors.set(e,i));let a=await i.request(r,t?.signal);return a?[a]:[]}if(ds(n)){let e=n.authors[0],r=n[`#e`][0],i=`${e}:${[...n.kinds].sort().join(`,`)}`,a=this.repostCollectors.get(i);a||(a=new as((t,r)=>this.executeRepostBatch(e,n.kinds,t,r)),this.repostCollectors.set(i,a));let o=await a.request(r,t?.signal);return o?[o]:[]}if(fs(n)){let e=ps(n),r=[...n.kinds].sort().join(`,`),i=n.limit??50,a=`${r}:${i}`,o=this.eTagCollectors.get(a);return o||(o=new as((e,t)=>this.executeETagBatch(n.kinds,e,i,t)),this.eTagCollectors.set(a,o)),o.request(e,t?.signal)}if(hs(n)){let e=n.kinds[0],r=n.authors[0],i=n[`#d`][0],a=`${e}:${r}`,o=this.dTagCollectors.get(a);o||(o=new as((t,n)=>this.executeDTagBatch(e,r,t,n)),this.dTagCollectors.set(a,o));let s=await o.request(i,t?.signal);return s?[s]:[]}}let n=ms(e);if(n!==null){let r=e.map(e=>Object.keys(e).sort().map(t=>t===`#e`||t===`#q`?t:`${t}:${JSON.stringify(e[t])}`).join(`|`)).join(`;;`),i=this.multiFilterCollectors.get(r);return i||(i=new as((t,n)=>this.executeMultiFilterBatch(e,t,n)),this.multiFilterCollectors.set(r,i)),i.request(n,t?.signal)}return this.pool.query(e,t)}async event(e,t){await this.pool.event(e,t),this.cacheEvents([e])}req(e,t){let n=this.pool.req(e,t),r=this.cacheEvents.bind(this);return(async function*(){for await(let e of n)e[0]===`EVENT`&&r([e[2]]),yield e})()}relay(e){return this.pool.relay(e)}group(e){return this.pool.group(e)}close(){return this.pool.close()}async executeRepostBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:t,authors:[e],"#e":n,limit:n.length}],{signal:r}),o=new Map;for(let e of a){let t=e.tags.find(([e])=>e===`e`)?.[1];if(!t)continue;let n=o.get(t);(!n||e.created_at>n.created_at)&&o.set(t,e)}for(let e of n)i.set(e,o.get(e))}catch{for(let e of n)i.set(e,void 0)}return i}async executeEventBatch(e,t){let n=new Map;try{let r=await this.pool.query([{ids:e,limit:e.length}],{signal:t}),i=new Map;for(let e of r)i.set(e.id,e);for(let t of e)n.set(t,i.get(t))}catch{for(let t of e)n.set(t,void 0)}return n}async executeReactionBatch(e,t,n){let r=new Map;try{let i=await this.pool.query([{kinds:[7],authors:[e],"#e":t,limit:t.length}],{signal:n}),a=new Map;for(let e of i){let t=e.tags.findLast(([e])=>e===`e`)?.[1];if(!t)continue;let n=a.get(t);(!n||e.created_at>n.created_at)&&a.set(t,e)}for(let e of t)r.set(e,a.get(e))}catch{for(let e of t)r.set(e,void 0)}return r}async executeDTagBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:[e],authors:[t],"#d":n,limit:n.length}],{signal:r}),o=new Map;for(let e of a){let t=e.tags.find(([e])=>e===`d`)?.[1];if(!t)continue;let n=o.get(t);(!n||e.created_at>n.created_at)&&o.set(t,e)}for(let e of n)i.set(e,o.get(e))}catch{for(let e of n)i.set(e,void 0)}return i}async executeETagBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:e,"#e":t,limit:t.length*n}],{signal:r}),o=new Map,s=new Set(t);for(let e of a)for(let t of e.tags)if(t[0]===`e`&&s.has(t[1])){let n=o.get(t[1])??[];n.push(e),o.set(t[1],n)}for(let e of t)i.set(e,o.get(e)??[])}catch{for(let e of t)i.set(e,[])}return i}async executeMultiFilterBatch(e,t,n){let r=new Map;try{let i=e.map(e=>{let n={...e},r=n;return r[`#e`]!==void 0&&(r[`#e`]=t,n.limit&&(n.limit*=t.length)),r[`#q`]!==void 0&&(r[`#q`]=t,n.limit&&(n.limit*=t.length)),n}),a=await this.pool.query(i,{signal:n}),o=new Map,s=new Set(t);for(let e of a){let t=new Set;for(let n of e.tags)(n[0]===`e`||n[0]===`q`)&&s.has(n[1])&&t.add(n[1]);for(let n of t){let t=o.get(n)??[];t.push(e),o.set(n,t)}}for(let e of t)r.set(e,o.get(e)??[])}catch{for(let e of t)r.set(e,[])}return r}},_s=`events`,vs=1,ys=256,bs={createdAt:`by-created_at`,pubkey:`by-pubkey`,kind:`by-kind`,pubkeyKind:`by-pubkey-kind`,tag:`by-tag`},xs=class e{pendingWrites=new Map;pendingResolvers=[];flushScheduled=!1;indexTags;db;constructor(t,n={}){this.db=e.openDatabase(t),this.indexTags=n.indexTags??e.indexTags}static async openDatabase(e){if(typeof indexedDB>`u`)return null;try{return await De(e,vs,{upgrade(e){let t=e.createObjectStore(_s,{keyPath:`id`});t.createIndex(bs.createdAt,`created_at`),t.createIndex(bs.pubkey,[`pubkey`,`created_at`]),t.createIndex(bs.kind,[`kind`,`created_at`]),t.createIndex(bs.pubkeyKind,[`pubkey`,`kind`,`created_at`]),t.createIndex(bs.tag,`_tagsCreated`,{multiEntry:!0})}})}catch{return null}}getDB(){return this.db}static indexTags(e){return e.tags.filter(([e,t])=>e.length===1&&!!t&&t.length<200)}event(e,t){if(Be.ephemeral(e.kind))return Promise.resolve();this.pendingWrites.set(e.id,e);let n=new Promise(e=>{this.pendingResolvers.push(e)});return this.scheduleFlush(),n}scheduleFlush(){if(this.flushScheduled)return;this.flushScheduled=!0;let e=()=>void this.flushWrites();typeof requestIdleCallback==`function`?requestIdleCallback(e,{timeout:1e3}):setTimeout(e,0)}async flushWrites(){this.flushScheduled=!1;let e=[...this.pendingWrites.values()],t=this.pendingResolvers;this.pendingWrites=new Map,this.pendingResolvers=[];let n=await this.getDB();if(!n||e.length===0){for(let e of t)e();return}try{let t=n.transaction(_s,`readwrite`),r=t.objectStore(_s),i=await this.resolveSupersession(r,e);for(let t of e){let e=i.get(t.id);if(e!==null){if(e)for(let t of e)r.delete(t);r.put(this.toStored(t))}}await this.applyDeletions(r,e),await t.done}catch{}finally{for(let e of t)e()}}async resolveSupersession(t,n){let r=new Map,i=new Map;for(let t of n){if(!Be.replaceable(t.kind)&&!Be.addressable(t.kind)){r.set(t.id,void 0);continue}let n=Be.addressable(t.kind)?e.getDTag(t):``,a=`${t.kind}:${t.pubkey}:${n}`;(i.get(a)??i.set(a,[]).get(a)).push(t)}let a=[...i.values()],o=await Promise.all(a.map(([e])=>t.index(bs.pubkeyKind).getAll(IDBKeyRange.bound([e.pubkey,e.kind,0],[e.pubkey,e.kind,1/0]))));return a.forEach((t,n)=>{let i=Be.addressable(t[0].kind)?e.getDTag(t[0]):``,a=o[n].filter(t=>!Be.addressable(t.kind)||e.getDTag(t)===i),s=t.reduce((t,n)=>e.isNewer(n,t)?n:t);for(let e of t)e!==s&&r.set(e.id,null);let c=[],l=!1;for(let t of a)if(t.id!==s.id){if(e.isNewer(t,s)){l=!0;break}c.push(t.id)}r.set(s.id,l?null:c)}),r}async applyDeletions(t,n){let r=n.filter(e=>e.kind===5);if(r.length!==0){for(let n of r)for(let[r,i]of n.tags)if(r===`e`){if(!i)continue;let e=await t.get(i);e&&e.pubkey===n.pubkey&&t.delete(i)}else if(r===`a`){if(!i)continue;let[r,a,...o]=i.split(`:`),s=Number(r);if(!Number.isInteger(s)||a!==n.pubkey)continue;let c=o.join(`:`),l=await t.index(bs.pubkeyKind).getAll(IDBKeyRange.bound([a,s,0],[a,s,1/0]));for(let r of l)Be.addressable(r.kind)&&e.getDTag(r)!==c||r.created_at>n.created_at||t.delete(r.id)}}}async query(t,n){let r=await this.getDB();if(!r)return[];let i=new Map;try{let a=r.transaction(_s,`readonly`).objectStore(_s),o=await Promise.all(t.map(e=>this.queryFilter(a,new Ss(e),n?.signal)));for(let t of o)for(let n of t)i.set(n.id,e.fromStored(n))}catch(e){if(n?.signal?.aborted)throw e;return[]}return[...i.values()].sort(e.compareNewest)}async queryFilter(t,n,r){if(n.neverMatch)return[];let i=n.limit??1/0;if(i<=0)return[];r?.throwIfAborted();let a=e.planScan(n),o=e=>a.indexOnly?n.matchesTime(e.created_at):n.matches(e);if(a.ids){let n=(await Promise.all(a.ids.map(e=>t.get(e)))).filter(e=>e!==void 0&&o(e));return n.sort(e.compareNewest),n.length>i?n.slice(0,i):n}if(n.searchKeywords)return e.searchScan(t,a,o,i,r);if(i===1/0){let n=await Promise.all(a.cursors.map(({indexName:e,range:n})=>(e?t.index(e):t).getAll(n)));r?.throwIfAborted();let i=a.disjoint?void 0:new Set,s=[];for(let e of n)for(let t of e){if(i){if(i.has(t.id))continue;i.add(t.id)}o(t)&&s.push(t)}return s.sort(e.compareNewest),s}let s=(await Promise.all(a.cursors.map(({indexName:e,range:n})=>(e?t.index(e):t).openCursor(n,`prev`)))).filter(e=>e!==null),c=a.disjoint?void 0:new Set,l=[];for(;s.length>0&&l.lengths[e].value.created_at&&(e=t);let t=s[e],n=t.value;!c?.has(n.id)&&o(n)&&(c?.add(n.id),l.push(n)),await t.continue()===null&&s.splice(e,1)}return l.sort(e.compareNewest),l}static async searchScan(t,n,r,i,a){let o=await Promise.all(n.cursors.map(n=>e.searchScanCursor(t,n,r,i,a))),s=n.disjoint?void 0:new Set,c=[];for(let e of o)for(let t of e){if(s){if(s.has(t.id))continue;s.add(t.id)}c.push(t)}return c.sort(e.compareNewest),c.length>i?c.slice(0,i):c}static async searchScanCursor(e,{indexName:t,range:n},r,i,a){let o=t?e.index(t):e,s=[],c=await o.openKeyCursor(n,`prevunique`);for(;c!==null&&s.length=0&&s.length0){let r=e.tags.reduce((e,t)=>t.values.length({indexName:bs.tag,range:IDBKeyRange.bound([r.name,e,t],[r.name,e,n])}))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<1e3){let r=[];for(let i of e.authors)for(let a of e.kinds)r.push({indexName:bs.pubkeyKind,range:IDBKeyRange.bound([i,a,t],[i,a,n])});return{indexOnly:e.indexOnly,disjoint:!0,cursors:r}}return e.authors?{indexOnly:e.indexOnly&&!e.kinds,disjoint:!0,cursors:e.authors.map(e=>({indexName:bs.pubkey,range:IDBKeyRange.bound([e,t],[e,n])}))}:e.kinds?{indexOnly:e.indexOnly,disjoint:!0,cursors:e.kinds.map(e=>({indexName:bs.kind,range:IDBKeyRange.bound([e,t],[e,n])}))}:{indexOnly:e.indexOnly,disjoint:!0,cursors:[{indexName:bs.createdAt,range:IDBKeyRange.bound(t,n)}]}}async count(t,n){let r=await this.getDB();if(!r)return{count:0,approximate:!1};if(t.length===1){let n=new Ss(t[0]);if(n.neverMatch)return{count:0,approximate:!1};if(n.limit===void 0&&n.indexOnly){let t=e.planScan(n);if(t.disjoint&&!t.ids)try{let e=r.transaction(_s,`readonly`).objectStore(_s);return{count:(await Promise.all(t.cursors.map(({indexName:t,range:n})=>(t?e.index(t):e).count(n)))).reduce((e,t)=>e+t,0),approximate:!1}}catch{}}}return{count:(await this.query(t,n)).length,approximate:!1}}async remove(e,t){let n=await this.getDB();if(!n)return;let r=await this.query(e,t);try{let e=n.transaction(_s,`readwrite`);await Promise.all(r.map(t=>e.store.delete(t.id))),await e.done}catch{}}async close(){(await this.getDB())?.close()}toStored(e){let t=[],n=new Set;for(let[r,i]of this.indexTags(e)){if(typeof r!=`string`||typeof i!=`string`)continue;let a=`${r}\0${i}`;n.has(a)||(n.add(a),t.push([r,i,e.created_at]))}return t.length>0?{...e,_tagsCreated:t}:{...e}}static fromStored(e){if(!(`_tagsCreated`in e))return e;let{_tagsCreated:t,...n}=e;return n}static getDTag(e){return e.tags.find(([e])=>e===`d`)?.[1]??``}static isNewer(e,t){return e.created_at>t.created_at?!0:e.created_att.id):t.created_at-e.created_at}[Symbol.toStringTag]=`NIndexedDB`},Ss=class{ids;authors;kinds;tags;search;searchKeywords;since;until;limit;idSet;authorSet;kindSet;neverMatch;indexOnly;constructor(e){let t=!1,n=0,r=[];for(let[i,a]of Object.entries(e)){if(Array.isArray(a)&&a.length===0){t=!0;continue}if(i===`ids`)this.ids=Cs(a),n++;else if(i===`authors`)this.authors=Cs(a),n++;else if(i===`kinds`)this.kinds=ws(a),n++;else if(i===`since`)this.since=a;else if(i===`until`)this.until=a;else if(i===`limit`)this.limit=a;else if(i===`search`)this.search=a;else if(i.startsWith(`#`)&&i.length>=2){let e=Cs(a);r.push({name:i.slice(1),values:e,valueSet:new Set(e)}),n++}}if(this.tags=r,this.neverMatch=t,this.idSet=this.ids&&new Set(this.ids),this.authorSet=this.authors&&new Set(this.authors),this.kindSet=this.kinds&&new Set(this.kinds),this.search!==void 0){let e=[],t=[];for(let n of Ve.parseInput(this.search)){if(typeof n!=`string`)continue;let r=n.toLowerCase();r.startsWith(`-`)?r.length>1&&t.push(r.slice(1)):r.length>0&&e.push(r)}(e.length>0||t.length>0)&&(this.searchKeywords={required:e,negated:t})}this.indexOnly=!this.searchKeywords&&(n<=1||n===2&&!!this.authors&&!!this.kinds)}matchesTime(e){return!(this.since!==void 0&&ethis.until)}matches(e){if(this.neverMatch||!this.matchesTime(e.created_at)||this.idSet&&!this.idSet.has(e.id)||this.authorSet&&!this.authorSet.has(e.pubkey)||this.kindSet&&!this.kindSet.has(e.kind))return!1;for(let{name:t,valueSet:n}of this.tags)if(!e.tags.some(([e,r])=>e===t&&n.has(r)))return!1;if(this.searchKeywords){let t=e.content.toLowerCase();for(let e of this.searchKeywords.required)if(!t.includes(e))return!1;for(let e of this.searchKeywords.negated)if(t.includes(e))return!1}return!0}};function Cs(e){return[...new Set(e)].sort()}function ws(e){return[...new Set(e)].sort((e,t)=>e-t)}var Ts=`nostr`;function Es(){try{indexedDB?.deleteDatabase(`ditto-events`)}catch{}}var Ds=e=>{let{children:t}=e,{config:n}=Nt(),{logins:r}=We(),i=(0,G.useRef)(void 0),a=(0,G.useRef)(void 0);a.current??=new xs(Ts);let o=(0,G.useRef)(void 0);o.current??=new Xr;let s=(0,G.useRef)(Jn(n.relayMetadata,n.useAppRelays,n.useUserRelays)),c=(0,G.useRef)(void 0),l=r[0];c.current=(0,G.useMemo)(()=>{if(l)try{switch(l.type){case`nsec`:return He.fromNsecLogin(l).signer;case`bunker`:return He.fromBunkerLogin(l,i.current).signer;case`extension`:return He.fromExtensionLogin(l).signer;case`x-android-signer`:{let{packageName:e}=l.data;return new kn(e,l.pubkey)}default:return}}catch{return}},[l]),(0,G.useEffect)(()=>{s.current=Jn(n.relayMetadata,n.useAppRelays,n.useUserRelays)},[n.relayMetadata,n.useAppRelays,n.useUserRelays]),i.current||=new ze({open(e){let t=new URL(e);return new Ke(t.href,{verifyEvent:o.current.verify,auth:async e=>{let n=c.current;if(!n)throw Error(`AUTH failed: no signer available (user not logged in)`);return n.signEvent({kind:22242,content:``,tags:[[`relay`,t.href],[`challenge`,e]],created_at:Math.floor(Date.now()/1e3)})}})},reqRouter(e){let t=new Map;if(e.some(e=>`search`in e))return new Map(qn.map(t=>[t,e]));if(e.every(e=>e?.kinds?.length===1&&e?.kinds[0]===34236))return new Map([...qn,Gn].map(t=>[t,e]));let n=s.current.relays.filter(e=>e.read).map(e=>e.url),r=[32267,30063,3063],i=[...r,...Wr,30817,...Jr,31990];if(e.every(e=>e?.kinds?.length&&e.kinds.every(e=>i.includes(e)))){let t=new Set;e.some(e=>e.kinds?.some(e=>r.includes(e)))&&t.add(Kn),e.some(e=>e.kinds?.some(e=>Wr.includes(e)))&&t.add(Wn);for(let e of n)t.add(e);return new Map([...t].map(t=>[t,e]))}for(let r of n)t.set(r,e);return t},eventRouter(e){let t=s.current.relays.filter(e=>e.write).map(e=>e.url);return[...new Set(t)]},eoseTimeout:300});let u=(0,G.useRef)(void 0);return!u.current&&i.current&&(u.current=new gs(i.current,a.current),u.current.setLoggedInPubkeys(r.map(e=>e.pubkey))),(0,G.useEffect)(()=>{u.current?.setLoggedInPubkeys(r.map(e=>e.pubkey))},[r]),(0,G.useEffect)(()=>()=>{i.current&&i.current.close()},[]),(0,G.useEffect)(()=>{Es()},[]),(0,K.jsx)(Ue.Provider,{value:{nostr:u.current??i.current},children:(0,K.jsx)(On.Provider,{value:a.current,children:t})})},Os=[{id:`trends`,label:`Trending`,description:`Top trending hashtags with sparkline charts`,icon:y,defaultHeight:320,minHeight:200,maxHeight:600,category:`discovery`,href:`/trends`},{id:`hot-posts`,label:`Hot Posts`,description:`Top posts from the Hot feed`,icon:k,defaultHeight:350,minHeight:200,maxHeight:600,category:`discovery`,href:`/trends`},{id:`wikipedia`,label:`Wikipedia`,description:`Today's featured article from Wikipedia`,icon:ai,defaultHeight:350,minHeight:200,maxHeight:600,category:`discovery`,href:`/wikipedia`},{id:`bluesky`,label:`Bluesky`,description:`Trending posts from Bluesky`,icon:oi,defaultHeight:400,minHeight:250,maxHeight:700,category:`discovery`,href:`/bluesky`},{id:`nostr-clients`,label:`Nostr Clients`,description:`Distinct authors per client over the last 30 days`,icon:g,defaultHeight:300,minHeight:200,maxHeight:500,category:`discovery`,href:`/trends`},{id:`blobbi`,label:`Blobbi`,description:`Your virtual pet companion`,icon:ue,defaultHeight:350,minHeight:200,maxHeight:500,category:`personal`,href:`/blobbi`},{id:`status`,label:`Status`,description:`Your current status, editable inline`,icon:A,defaultHeight:80,minHeight:60,maxHeight:120,category:`personal`,href:`/profile`},{id:`ai-chat`,label:`AI Chat`,description:`Chat with Shakespeare AI`,icon:oe,defaultHeight:300,minHeight:200,maxHeight:700,category:`personal`,href:`/ai-chat`,fillHeight:!0},{id:`feed:photos`,label:`Photos`,description:`Recent photos from your feed`,icon:ee,defaultHeight:400,minHeight:250,maxHeight:700,category:`content`,href:`/photos`},{id:`feed:music`,label:`Music`,description:`Music tracks from your feed`,icon:O,defaultHeight:350,minHeight:250,maxHeight:700,category:`content`,href:`/music`},{id:`feed:articles`,label:`Articles`,description:`Long-form articles from your feed`,icon:ae,defaultHeight:350,minHeight:250,maxHeight:700,category:`content`,href:`/articles`},{id:`feed:events`,label:`Events`,description:`Upcoming calendar events`,icon:i,defaultHeight:300,minHeight:200,maxHeight:600,category:`content`,href:`/events`}],ks=new Map(Os.map(e=>[e.id,e])),As=[{id:`trends`},{id:`hot-posts`},{id:`wikipedia`}];function js(e){return ks.get(e)}var Ms={personal:`Personal`,content:`Content`,discovery:`Discovery`},Ns={trends:`trending`,"hot-posts":`hotPosts`,wikipedia:`wikipedia`,bluesky:`bluesky`,"nostr-clients":`nostrClients`,blobbi:`blobbi`,status:`status`,"ai-chat":`aiChat`,"feed:photos":`photo`,"feed:music":`music`,"feed:articles":`articles`,"feed:events":`events`};function Ps(e){return Ns[e]??e}function Fs(e){let t=ln(),n=ks.get(e);return n?t.formatMessage({id:`widgets.${Ps(e)}.title`,defaultMessage:n.label}):e}function Is(){let{nostr:e}=Ge(),{user:t}=V(),{config:n,updateConfig:r}=Nt(),i=ht(),{settings:a,isLoading:o,recentlyWritten:s}=en(),c=(0,G.useRef)(0),[l,u]=(0,G.useState)(!1),d=(0,G.useRef)(!1),f=(0,G.useRef)(void 0),p=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let e=t?.pubkey;if(f.current!==void 0&&e!==f.current){c.current=0,d.current=!1,p.current=!0;for(let e of[`user-reaction`,`user-repost`,`external-user-reaction`,`external-user-repost`,`feed`,`vines-follows`,`theme-feed`,`book-feed`])i.removeQueries({queryKey:[e]});for(let e of[`encryptedSettings`,`parsedSettings`,`notifications`,`notifications-unread`,`interests`,`muteList`,`muteItems`,`user-lists`,`bookmarks`,`bookmarked-events`,`custom-emojis`,`emoji-list`,`own-follow-packs`,`follow-list`,`relayList`,`blossomServerList`,`pinned-notes`,`my-rsvp`,`user-book-review`])i.invalidateQueries({queryKey:[e]});i.invalidateQueries({queryKey:[`nostr`,`logins`]})}f.current=e},[t?.pubkey,i]);let{data:m}=yt({queryKey:[`relayList`,t?.pubkey??``],queryFn:async({signal:n})=>t?(await e.query([{kinds:[10002],authors:[t.pubkey],limit:1}],{signal:n}))[0]??null:null,enabled:!!t,staleTime:300*1e3,gcTime:600*1e3,retry:1});(0,G.useEffect)(()=>{if(m&&m.created_at>n.relayMetadata.updatedAt){let e=m.tags.filter(([e])=>e===`r`).map(([,e,t])=>({url:e.replace(/\/+$/,``),read:!t||t===`read`,write:!t||t===`write`}));e.length>0&&(console.log(`Syncing relay list from Nostr:`,e),r(t=>({...t,relayMetadata:{relays:e,updatedAt:m.created_at}})))}},[m,n.relayMetadata.updatedAt,r]);let{data:h}=yt({queryKey:[`blossomServerList`,t?.pubkey??``],queryFn:async({signal:n})=>t?(await e.query([{kinds:[10063],authors:[t.pubkey],limit:1}],{signal:n}))[0]??null:null,enabled:!!t,staleTime:300*1e3,gcTime:600*1e3,retry:1});return(0,G.useEffect)(()=>{if(h&&h.created_at>n.blossomServerMetadata.updatedAt){let e=Nr(h);e.length>0&&(console.log(`Syncing Blossom server list from Nostr (kind 10063):`,e),r(t=>({...t,blossomServerMetadata:{servers:e,updatedAt:h.created_at}})))}},[h,n.blossomServerMetadata.updatedAt,r]),(0,G.useEffect)(()=>{if(!t||o)return;if(!a){p.current&&=(Po(n.appId,t.pubkey)&&r(e=>{let t=!1,n={...e};return e.theme!==`system`&&(n.theme=`system`,t=!0),e.customTheme!==void 0&&(n.customTheme=void 0,t=!0),(e.sidebarOrder??[]).length>0&&(n.sidebarOrder=[],t=!0),JSON.stringify(e.sidebarWidgets??[])!==JSON.stringify(As)&&(n.sidebarWidgets=As,t=!0),e.homePage!==`feed`&&(n.homePage=`feed`,t=!0),t?n:e}),!1);return}let e=a.lastSync||0;if(l||u(!0),s()){console.log(`Skipping settings sync - recent write`),c.current=e;return}if(e<=c.current)return;console.log(`Syncing encrypted settings from Nostr`,e),c.current=e;let i=p.current;if(p.current=!1,r(e=>{let t=!1,n={...e};if(a.theme?a.theme!==e.theme&&(n.theme=a.theme,t=!0):i&&(e.theme!==`system`&&(n.theme=`system`,t=!0),e.customTheme!==void 0&&(n.customTheme=void 0,t=!0)),a.customTheme&&JSON.stringify(a.customTheme)!==JSON.stringify(e.customTheme)?(n.customTheme=a.customTheme,t=!0):i&&!a.customTheme&&e.customTheme!==void 0&&(n.customTheme=void 0,t=!0),a.autoShareTheme!==void 0&&a.autoShareTheme!==e.autoShareTheme&&(n.autoShareTheme=a.autoShareTheme,t=!0),a.useAppRelays!==void 0&&a.useAppRelays!==e.useAppRelays&&(n.useAppRelays=a.useAppRelays,t=!0),a.useUserRelays!==void 0&&a.useUserRelays!==e.useUserRelays&&(n.useUserRelays=a.useUserRelays,t=!0),a.feedSettings){let r=e.feedSettings,i=a.feedSettings;Object.keys(i).some(e=>i[e]!==r?.[e])&&(n.feedSettings={...r,...i},t=!0)}return a.contentWarningPolicy&&a.contentWarningPolicy!==e.contentWarningPolicy&&(n.contentWarningPolicy=a.contentWarningPolicy,t=!0),a.exemptFollowsFromFilters!==void 0&&a.exemptFollowsFromFilters!==e.exemptFollowsFromFilters&&(n.exemptFollowsFromFilters=a.exemptFollowsFromFilters,t=!0),a.sidebarOrder&&JSON.stringify(a.sidebarOrder)!==JSON.stringify(e.sidebarOrder)&&(n.sidebarOrder=a.sidebarOrder,t=!0),a.sidebarWidgets&&JSON.stringify(a.sidebarWidgets)!==JSON.stringify(e.sidebarWidgets)?(n.sidebarWidgets=a.sidebarWidgets,t=!0):i&&!a.sidebarWidgets&&JSON.stringify(e.sidebarWidgets??[])!==JSON.stringify(As)&&(n.sidebarWidgets=As,t=!0),a.homePage&&a.homePage!==e.homePage&&(n.homePage=a.homePage,t=!0),a.corsProxy&&a.corsProxy!==e.corsProxy&&(n.corsProxy=a.corsProxy,t=!0),a.faviconUrl&&a.faviconUrl!==e.faviconUrl&&(n.faviconUrl=a.faviconUrl,t=!0),a.linkPreviewUrl&&a.linkPreviewUrl!==e.linkPreviewUrl&&(n.linkPreviewUrl=a.linkPreviewUrl,t=!0),a.currencyDisplay&&a.currencyDisplay!==e.currencyDisplay&&(n.currencyDisplay=a.currencyDisplay,t=!0),a.stripTrackingParams!==void 0&&a.stripTrackingParams!==e.stripTrackingParams&&(n.stripTrackingParams=a.stripTrackingParams,t=!0),t?n:e}),a.showGlobalFeed!==void 0){let e=Pr(n.appId,`showGlobalFeed`),t=localStorage.getItem(e),r=String(a.showGlobalFeed);t!==r&&localStorage.setItem(e,r)}if(a.showCommunityFeed!==void 0){let e=Pr(n.appId,`showCommunityFeed`),t=localStorage.getItem(e),r=String(a.showCommunityFeed);t!==r&&localStorage.setItem(e,r)}if(a.communityData){let e={domain:a.communityData.domain,label:a.communityData.label,userCount:a.communityData.userCount},t=Pr(n.appId,`community`),r=localStorage.getItem(t),i=JSON.stringify(e);r!==i&&(localStorage.setItem(t,i),localStorage.setItem(Pr(n.appId,`communityData`),JSON.stringify({names:a.communityData.nip05})))}t&&e>0&&Qt(t.pubkey,e)},[t,a,o,r,s,l,n.appId]),(0,G.useEffect)(()=>{if(!t||!n.autoShareTheme||d.current)return;d.current=!0;let i=new AbortController;return(async()=>{try{let n=await e.query([{kinds:[Gt],authors:[t.pubkey],limit:1}],{signal:i.signal});if(n.length===0)return;let a=It(n[0]);if(!a)return;let o={colors:a.colors,...a.font&&{font:a.font},...a.titleFont&&{titleFont:a.titleFont},...a.background&&{background:a.background}};r(e=>JSON.stringify(e.customTheme)===JSON.stringify(o)?e:{...e,customTheme:o})}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;console.error(`Failed to sync active profile theme:`,e)}})(),()=>i.abort()},[t,n.autoShareTheme,e,r]),null}function Ls(){let{nostr:e}=Ge(),{user:t}=V(),n=ht();return(0,G.useEffect)(()=>{if(!t)return;let r=new AbortController,i=Math.floor(Date.now()/1e3);return(async()=>{try{for await(let a of e.req([{kinds:[...mo],"#p":[t.pubkey],since:i}],{signal:r.signal}))if(a[0]===`EVENT`){if(a[2].pubkey===t.pubkey)continue;n.invalidateQueries({queryKey:[`notifications`,t.pubkey]}),n.invalidateQueries({queryKey:[`notifications-unread`,t.pubkey]})}}catch{}})(),()=>r.abort()},[e,t,n]),null}function Rs({children:e}){let{config:t}=Nt(),n=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{n.current||!t.plausibleDomain||(n.current=!0,z(async()=>{let{init:e}=await import(`./plausible-BCeIv-rh.js`);return{init:e}},[]).then(({init:e})=>{e({domain:t.plausibleDomain,...t.plausibleEndpoint&&{endpoint:t.plausibleEndpoint}})}).catch(console.error))},[t.plausibleDomain,t.plausibleEndpoint]),(0,K.jsx)(K.Fragment,{children:e})}function zs({children:e}){let{config:t}=Nt();return(0,G.useEffect)(()=>{let e=t.sentryDsn&&t.sentryEnabled;e&&!Ae()?Me(t.sentryDsn).catch(console.error):!e&&Ae()&&je().catch(console.error)},[t.sentryDsn,t.sentryEnabled]),(0,K.jsx)(K.Fragment,{children:e})}var Bs=/nsec1[a-z0-9]{58}/i;function Vs(){(0,G.useEffect)(()=>{function e(e){let t=e.clipboardData?.getData(`text`);if(!t||!Bs.test(t))return;let n=e.target;n.id===`nsec`||n.closest?.(`[data-nsec-allowed]`)||(e.preventDefault(),e.stopImmediatePropagation(),An({title:`Secret key detected`,description:`Your clipboard contains a secret key. Posting it publicly could give someone else full access to your account.`,variant:`destructive`}))}return document.addEventListener(`paste`,e,{capture:!0}),()=>document.removeEventListener(`paste`,e,{capture:!0})},[])}var Hs=hn(`SecureStoragePlugin`,{web:()=>z(()=>import(`./web-BALG1lv4.js`).then(e=>new e.SecureStoragePluginWeb),__vite__mapDeps([60,1]))}),Us={async getItem(e){if(!_n.isNativePlatform())return localStorage.getItem(e);try{let{value:t}=await Hs.get({key:e});return t}catch{let t=localStorage.getItem(e);return t===null?null:(await Hs.set({key:e,value:t}),localStorage.removeItem(e),t)}},async setItem(e,t){if(!_n.isNativePlatform()){localStorage.setItem(e,t);return}await Hs.set({key:e,value:t})},async removeItem(e){if(!_n.isNativePlatform()){localStorage.removeItem(e);return}try{await Hs.remove({key:e})}catch{}}};function Ws(e,t,n){let r=n?.serialize||JSON.stringify,i=n?.deserialize||JSON.parse,a=_n.isNativePlatform(),[o,s]=(0,G.useState)(()=>{if(a)return t;try{let n=localStorage.getItem(e);return n?i(n):t}catch(n){return console.warn(`Failed to load ${e} from localStorage:`,n),t}}),[c,l]=(0,G.useState)(!a),u=(0,G.useRef)(e);return u.current=e,(0,G.useEffect)(()=>{let n=!1;async function r(){try{if(a){let r=await Us.getItem(e);if(n||u.current!==e)return;s(r?i(r):t)}else{let r=localStorage.getItem(e);if(n||u.current!==e)return;s(r?i(r):t)}}catch(r){n||(console.warn(`Failed to load ${e} from secure storage:`,r),s(t))}finally{n||l(!0)}}return l(!1),r(),()=>{n=!0}},[e,a]),(0,G.useEffect)(()=>{if(a)return;let t=t=>{if(t.key===e&&t.newValue!==null)try{s(i(t.newValue))}catch(t){console.warn(`Failed to sync ${e} from localStorage:`,t)}};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e,a,i]),[o,t=>{let n=t=>{try{let n=r(t);a?Us.setItem(e,n).catch(t=>{console.warn(`Failed to save ${e} to secure storage:`,t)}):localStorage.setItem(e,n)}catch(t){console.warn(`Failed to serialize ${e}:`,t)}};t instanceof Function?s(e=>{let r=t(e);return r===e?e:(n(r),r)}):s(e=>t===e?e:(n(t),t))},c]}var Gs,Ks,{bech32:qs,hex:Js,utf8:Ys}=(Gs=function(e,t){function n(e){if(!Number.isSafeInteger(e))throw Error(`Wrong integer: ${e}`)}function r(...e){let t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),decode:e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0)}}function i(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`number`)throw Error(`alphabet.encode input should be an array of numbers`);return t.map(t=>{if(n(t),t<0||t>=e.length)throw Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`string`)throw Error(`alphabet.decode input should be array of strings`);return t.map(t=>{if(typeof t!=`string`)throw Error(`alphabet.decode: not string element=${t}`);let n=e.indexOf(t);if(n===-1)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function a(e=``){if(typeof e!=`string`)throw Error(`join separator should be string`);return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`string`)throw Error(`join.encode input should be array of strings`);for(let e of t)if(typeof e!=`string`)throw Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if(typeof t!=`string`)throw Error(`join.decode input should be string`);return t.split(e)}}}function o(e,t=`=`){if(n(e),typeof t!=`string`)throw Error(`padding chr should be string`);return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!=`string`)throw Error(`padding.encode input should be array of strings`);for(let e of n)if(typeof e!=`string`)throw Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!=`string`)throw Error(`padding.encode input should be array of strings`);for(let e of n)if(typeof e!=`string`)throw Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw Error(`Invalid padding: string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw Error(`Invalid padding: string has too much padding`);return n.slice(0,r)}}}function s(e){if(typeof e!=`function`)throw Error(`normalize fn should be function`);return{encode:e=>e,decode:t=>e(t)}}function c(e,t,r){if(t<2)throw Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw Error(`convertRadix: data should be array`);if(!e.length)return[];let i=0,a=[],o=Array.from(e);for(o.forEach(e=>{if(n(e),e<0||e>=t)throw Error(`Wrong integer: ${e}`)});;){let e=0,n=!0;for(let a=i;at?l(t,e%t):e,u=(e,t)=>e+(t-l(e,t));function d(e,t,r,i){if(!Array.isArray(e))throw Error(`convertRadix2: data should be array`);if(t<=0||t>32)throw Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw Error(`convertRadix2: wrong to=${r}`);if(u(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${u(t,r)}`);let a=0,o=0,s=2**r-1,c=[];for(let i of e){if(n(i),i>=2**t)throw Error(`convertRadix2: invalid data word=${i} from=${t}`);if(a=a<32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)c.push((a>>o-r&s)>>>0);a&=2**o-1}if(a=a<=t)throw Error(`Excess padding`);if(!i&&a)throw Error(`Non-zero padding: ${a}`);return i&&o>0&&c.push(a>>>0),c}function f(e){return n(e),{encode:t=>{if(!(t instanceof Uint8Array))throw Error(`radix.encode input should be Uint8Array`);return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`number`)throw Error(`radix.decode input should be array of strings`);return Uint8Array.from(c(t,e,256))}}}function p(e,t=!1){if(n(e),e<=0||e>32)throw Error(`radix2: bits should be in (0..32]`);if(u(8,e)>32||u(e,8)>32)throw Error(`radix2: carry overflow`);return{encode:n=>{if(!(n instanceof Uint8Array))throw Error(`radix2.encode input should be Uint8Array`);return d(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!=`number`)throw Error(`radix2.decode input should be array of strings`);return Uint8Array.from(d(n,e,8,t))}}}function m(e){if(typeof e!=`function`)throw Error(`unsafeWrapper fn should be function`);return function(...t){try{return e.apply(null,t)}catch{}}}function h(e,t){if(n(e),typeof t!=`function`)throw Error(`checksum fn should be function`);return{encode(n){if(!(n instanceof Uint8Array))throw Error(`checksum.encode: input should be Uint8Array`);let r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!(n instanceof Uint8Array))throw Error(`checksum.decode: input should be Uint8Array`);let r=n.slice(0,-e),i=t(r).slice(0,e),a=n.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`))),t.base64=r(p(6),i(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),o(6),a(``)),t.base64url=r(p(6),i(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),o(6),a(``));let g=e=>r(f(58),i(e),a(``));t.base58=g(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`),t.base58flickr=g(`123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ`),t.base58xrp=g(`rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz`);let _=[0,2,3,5,6,7,9,10,11];t.base58xmr={encode(e){let n=``;for(let r=0;rr(h(4,t=>e(e(t))),t.base58);let v=r(i(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),a(``)),y=[996825010,642813549,513874426,1027748829,705979059];function b(e){let t=e>>25,n=(33554431&e)<<5;for(let e=0;e>e&1)==1&&(n^=y[e]);return n}function x(e,t,n=1){let r=e.length,i=1;for(let t=0;t126)throw Error(`Invalid prefix (${e})`);i=b(i)^n>>5}i=b(i);for(let t=0;tn)throw TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);let r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let i=(e=r).lastIndexOf(`1`);if(i===0||i===-1)throw Error(`Letter "1" must be present between prefix and data only`);let a=e.slice(0,i),o=e.slice(i+1);if(o.length<6)throw Error(`Data must be at least 6 characters long`);let s=v.decode(o).slice(0,-6),c=x(a,s,t);if(!o.endsWith(c))throw Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:a,words:s}}return{encode:function(e,n,r=90){if(typeof e!=`string`)throw Error(`bech32.encode prefix should be string, not `+typeof e);if(!Array.isArray(n)||n.length&&typeof n[0]!=`number`)throw Error(`bech32.encode words should be array of numbers, not `+typeof n);let i=e.length+7+n.length;if(!1!==r&&i>r)throw TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${v.encode(n)}${x(e,n,t)}`},decode:o,decodeToBytes:function(e){let{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:m(o),fromWords:r,fromWordsUnsafe:a,toWords:i}}t.bech32=S(`bech32`),t.bech32m=S(`bech32m`),t.utf8={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},t.hex=r(p(4),i(`0123456789abcdef`),a(``),s(e=>{if(typeof e!=`string`||e.length%2)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));let C={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},w=`Invalid encoding type. Available types: ${Object.keys(C).join(`, `)}`;t.bytesToString=(e,t)=>{if(typeof e!=`string`||!C.hasOwnProperty(e))throw TypeError(w);if(!(t instanceof Uint8Array))throw TypeError(`bytesToString() expects Uint8Array`);return C[e].encode(t)},t.str=t.bytesToString,t.stringToBytes=(e,t)=>{if(!C.hasOwnProperty(e))throw TypeError(w);if(typeof t!=`string`)throw TypeError(`stringToBytes() expects string`);return C[e].decode(t)},t.bytes=t.stringToBytes},Gs(Ks={exports:{}},Ks.exports),Ks.exports),Xs={bech32:`bc`,pubKeyHash:0,scriptHash:5,validWitnessVersions:[0]},Zs={bech32:`tb`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},Qs={bech32:`tbs`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},$s={bech32:`bcrt`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},ec={bech32:`sb`,pubKeyHash:63,scriptHash:123,validWitnessVersions:[0]},tc=[`option_data_loss_protect`,`initial_routing_sync`,`option_upfront_shutdown_script`,`gossip_queries`,`var_onion_optin`,`gossip_queries_ex`,`option_static_remotekey`,`payment_secret`,`basic_mpp`,`option_support_large_channel`],nc={m:BigInt(1e3),u:BigInt(1e6),n:BigInt(1e9),p:BigInt(0xe8d4a51000)},rc=BigInt(`2100000000000000000`),ic=BigInt(1e11),ac={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27},oc={};for(let e=0,t=Object.keys(ac);eJs.encode(qs.fromWordsUnsafe(e)),16:e=>Js.encode(qs.fromWordsUnsafe(e)),13:e=>Ys.encode(qs.fromWordsUnsafe(e)),19:e=>Js.encode(qs.fromWordsUnsafe(e)),23:e=>Js.encode(qs.fromWordsUnsafe(e)),27:e=>Js.encode(qs.fromWordsUnsafe(e)),6:lc,24:lc,3:function(e){let t=[],n,r,i,a,o,s=qs.fromWordsUnsafe(e);for(;s.length>0;)n=Js.encode(s.slice(0,33)),r=Js.encode(s.slice(33,41)),i=parseInt(Js.encode(s.slice(41,45)),16),a=parseInt(Js.encode(s.slice(45,49)),16),o=parseInt(Js.encode(s.slice(49,51)),16),s=s.slice(51),t.push({pubkey:n,short_channel_id:r,fee_base_msat:i,fee_proportional_millionths:a,cltv_expiry_delta:o});return t},5:function(e){let t=e.slice().reverse().map(e=>[!!(1&e),!!(2&e),!!(4&e),!!(8&e),!!(16&e)]).reduce((e,t)=>e.concat(t),[]);for(;t.length<2*tc.length;)t.push(!1);let n={};tc.forEach((e,r)=>{let i;i=t[2*r]?`required`:t[2*r+1]?`supported`:`unsupported`,n[e]=i});let r=t.slice(2*tc.length);return n.extra_bits={start_bit:2*tc.length,bits:r,has_required:r.reduce((e,t,n)=>n%2==0?e||t:e||!1,!1)},n}};function cc(e){return t=>({tagCode:parseInt(e),words:qs.encode(`unknown`,t,2**53-1)})}function lc(e){return e.reverse().reduce((e,t,n)=>e+t*32**n,0)}var uc=e=>Uint8Array.from(e.match(/.{1,2}/g).map(e=>parseInt(e,16))),dc=e=>{if(!e)return null;try{let t=function(e,t){if(typeof e!=`string`)throw Error(`Lightning Payment Request must be string`);if(e.slice(0,2).toLowerCase()!==`ln`)throw Error(`Not a proper lightning payment request`);let n=[],r=qs.decode(e,2**53-1);e=e.toLowerCase();let i=r.prefix,a=r.words,o=e.slice(i.length+1),s=a.slice(-104);a=a.slice(0,-104);let c=i.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/);if(c&&!c[2]&&(c=i.match(/^ln(\S+)$/)),!c)throw Error(`Not a proper lightning payment request`);n.push({name:`lightning_network`,letters:`ln`});let l=c[1],u;switch(l){case Xs.bech32:u=Xs;break;case Zs.bech32:u=Zs;break;case Qs.bech32:u=Qs;break;case $s.bech32:u=$s;break;case ec.bech32:u=ec}if(!u||u.bech32!==l)throw Error(`Unknown coin bech32 prefix`);n.push({name:`coin_network`,letters:l,value:u});let d=c[2],f;d?(f=function(e,t){let n,r;if(e.slice(-1).match(/^[munp]$/))n=e.slice(-1),r=e.slice(0,-1);else{if(e.slice(-1).match(/^[^munp0-9]$/))throw Error(`Not a valid multiplier for the amount`);r=e}if(!r.match(/^\d+$/))throw Error(`Not a valid human readable amount`);let i=BigInt(r),a=n?i*ic/nc[n]:i*ic;if(n===`p`&&i%BigInt(10)!==BigInt(0)||a>rc)throw Error(`Amount is outside of valid range`);return a.toString()}(d+c[3]),n.push({name:`amount`,letters:c[2]+c[3],value:f})):f=null,n.push({name:`separator`,letters:`1`});let p=lc(a.slice(0,7)),m,h,g,_;for(a=a.slice(7),n.push({name:`timestamp`,letters:o.slice(0,7),value:p}),o=o.slice(7);a.length>0;){let e=a[0].toString();m=oc[e]||`unknown_tag`,h=sc[e]||cc(e),a=a.slice(1),g=lc(a.slice(0,2)),a=a.slice(2),_=a.slice(0,g),a=a.slice(g),n.push({name:m,tag:o[0],letters:o.slice(0,3+g),value:h(_)}),o=o.slice(3+g)}n.push({name:`signature`,letters:o.slice(0,104),value:Js.encode(qs.fromWordsUnsafe(s))}),o=o.slice(104),n.push({name:`checksum`,letters:o});let v={paymentRequest:e,sections:n,get expiry(){let e=n.find(e=>e.name===`expiry`);if(e)return y(`timestamp`)+e.value},get route_hints(){return n.filter(e=>e.name===`route_hint`).map(e=>e.value)}};for(let e in ac)e!==`route_hint`&&Object.defineProperty(v,e,{get:()=>y(e)});return v;function y(e){let t=n.find(t=>t.name===e);return t?t.value:void 0}}(e);if(!t||!t.sections)return null;let n=t.sections.find(e=>e.name===`payment_hash`);if(n?.name!==`payment_hash`||!n.value)return null;let r=n.value,i=0,a=t.sections.find(e=>e.name===`amount`);a?.name===`amount`&&a.value&&(i=parseInt(a.value)/1e3);let o=t.sections.find(e=>e.name===`timestamp`);if(o?.name!==`timestamp`||!o.value)return null;let s=o.value,c,l=t.sections.find(e=>e.name===`expiry`);l?.name===`expiry`&&(c=l.value);let u=t.sections.find(e=>e.name===`description`);return{paymentHash:r,satoshi:i,timestamp:s,expiry:c,description:u?.name===`description`?u?.value:void 0}}catch{return null}};function fc(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}var pc=e=>e instanceof Uint8Array,mc=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),hc=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);var gc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function _c(e){if(!pc(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;ne().update(vc(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}var xc=class extends yc{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=mc(this.buffer)}update(e){fc(this);let{view:t,buffer:n,blockLen:r}=this,i=(e=vc(e)).length;for(let a=0;a0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)})(e);let n=t.outputLen;if(e.lengthr-a&&(this.process(n,0),a=0);for(let e=a;e>i&a),s=Number(n&a),c=r?0:4;e.setUint32(t+(r?4:0),o,r),e.setUint32(t+c,s,r)})(n,r-8,BigInt(8*this.length),i),this.process(n,0);let o=mc(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;ee&t^e&n^t&n,Cc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),wc=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tc=new Uint32Array(64),Ec=class extends xc{constructor(){super(64,32,8,!1),this.A=0|wc[0],this.B=0|wc[1],this.C=0|wc[2],this.D=0|wc[3],this.E=0|wc[4],this.F=0|wc[5],this.G=0|wc[6],this.H=0|wc[7]}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|a,this.G=0|o,this.H=0|s}process(e,t){for(let n=0;n<16;n++,t+=4)Tc[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Tc[e-15],n=Tc[e-2],r=hc(t,7)^hc(t,18)^t>>>3;Tc[e]=(hc(n,17)^hc(n,19)^n>>>10)+Tc[e-7]+r+Tc[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=l+(hc(o,6)^hc(o,11)^hc(o,25))+((u=o)&s^~u&c)+Cc[e]+Tc[e]|0,d=(hc(n,2)^hc(n,13)^hc(n,22))+Sc(n,r,i)|0;l=c,c=s,s=o,o=a+t|0,a=i,i=r,r=n,n=t+d|0}var u;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Tc.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Dc=bc(()=>new Ec),Oc=class{constructor(e){if(this.paymentRequest=void 0,this.paymentHash=void 0,this.preimage=void 0,this.verify=void 0,this.satoshi=void 0,this.expiry=void 0,this.timestamp=void 0,this.createdDate=void 0,this.expiryDate=void 0,this.description=void 0,this.successAction=void 0,this.paymentRequest=e.pr,!this.paymentRequest)throw Error(`Invalid payment request`);let t=dc(this.paymentRequest);if(!t)throw Error(`Failed to decode payment request`);this.paymentHash=t.paymentHash,this.satoshi=t.satoshi,this.timestamp=t.timestamp,this.expiry=t.expiry,this.createdDate=new Date(1e3*this.timestamp),this.expiryDate=this.expiry?new Date(1e3*(this.timestamp+this.expiry)):void 0,this.description=t.description??null,this.verify=e.verify??null,this.preimage=e.preimage??null,this.successAction=e.successAction??null}async isPaid(){if(this.preimage)return this.validatePreimage(this.preimage);if(this.verify)return await this.verifyPayment();throw Error(`Could not verify payment`)}validatePreimage(e){if(!e||!this.paymentHash)return!1;try{let t=_c(Dc(uc(e)));return this.paymentHash===t}catch{return!1}}async verifyPayment(){try{if(!this.verify)throw Error(`LNURL verify not available`);let e=await fetch(this.verify);if(!e.ok)throw Error(`Verification request failed: ${e.status} ${e.statusText}`);let t=await e.json();return t.preimage&&(this.preimage=t.preimage),t.settled}catch(e){return console.error(`Failed to check LNURL-verify`,e),!1}}hasExpired(){let{expiryDate:e}=this;return!!e&&e.getTime(){if(e.tag!==`keysend`)throw Error(`Invalid keysend params`);if(e.status!==`OK`)throw Error(`Keysend status not OK`);if(!e.pubkey)throw Error(`Pubkey does not exist`);let t,n;return e.customData&&e.customData[0]&&(t=e.customData[0].customKey,n=e.customData[0].customValue),{destination:e.pubkey,customKey:t,customValue:n}};async function Ac({satoshi:e,comment:t,p:n,e:r,relays:i},a={}){let o=a.nostr||globalThis.nostr;if(!o)throw Error(`nostr option or window.nostr is not available`);let s=[[`relays`,...i],[`amount`,e.toString()]];n&&s.push([`p`,n]),r&&s.push([`e`,r]);let c={pubkey:await o.getPublicKey(),created_at:Math.floor(Date.now()/1e3),kind:9734,tags:s,content:t??``};return c.id=Nc(c),await o.signEvent(c)}function jc(e){if(typeof e.content!=`string`||typeof e.created_at!=`number`||!Array.isArray(e.tags))return!1;for(let t=0;t!!e&&Fc.test(e),Lc=({amount:e,min:t,max:n})=>e>0&&e>=t&&e<=n,Rc=async e=>{if(e.tag!==`payRequest`)throw Error(`Invalid pay service params`);let t=(e.callback+``).trim();if(!Ic(t))throw Error(`Callback must be a valid url`);let n=Math.ceil(Number(e.minSendable||0)),r=Math.floor(Number(e.maxSendable));if(!n||!r||n>r)throw Error(`Invalid pay service params`);let i,a;try{i=JSON.parse(e.metadata+``),a=_c(Dc(e.metadata+``))}catch{i=[],a=_c(Dc(`[]`))}let o=``,s=``,c=``,l=``;for(let e=0;e{let{boost:n}=e;t||={};let r=t.webln||globalThis.webln;if(!r)throw Error(`WebLN not available`);if(!r.keysend)throw Error(`Keysend not available in current WebLN provider`);let i=e.amount||Math.floor(n.value_msat/1e3),a={destination:e.destination,amount:i,customRecords:{7629169:JSON.stringify(n)}};return e.customKey&&e.customValue&&(a.customRecords[e.customKey]=e.customValue),await r.enable(),await r.keysend(a)},Vc=/^((?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*)|(?:".+"))@((?:\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(?:(?:[a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Hc=class{constructor(e,t){this.address=void 0,this.options=void 0,this.username=void 0,this.domain=void 0,this.pubkey=void 0,this.lnurlpData=void 0,this.keysendData=void 0,this.nostrData=void 0,this.nostrPubkey=void 0,this.nostrRelays=void 0,this.webln=void 0,this.address=e,this.options={proxy:`https://api.getalby.com/lnurl`},this.options=Object.assign(this.options,t),this.parse(),this.webln=this.options.webln}parse(){let e=Vc.exec(this.address.toLowerCase());e&&(this.username=e[1],this.domain=e[2])}getWebLN(){return this.webln||globalThis.webln}async fetch(){return this.options.proxy?this.fetchWithProxy():this.fetchWithoutProxy()}async fetchWithProxy(){let e=await fetch(`${this.options.proxy}/lightning-address-details?${new URLSearchParams({ln:this.address}).toString()}`);if(!e.ok)throw Error(`Failed to fetch lnurl info: ${e.status} ${e.statusText}`);let t=await e.json();await this.parseLnUrlPayResponse(t.lnurlp),this.parseKeysendResponse(t.keysend),this.parseNostrResponse(t.nostr)}async fetchWithoutProxy(){this.domain&&this.username&&await Promise.all([this.fetchLnurlData(),this.fetchKeysendData(),this.fetchNostrData()])}async fetchLnurlData(){let e=await fetch(this.lnurlpUrl());if(e.ok){let t=await e.json();await this.parseLnUrlPayResponse(t)}}async fetchKeysendData(){let e=await fetch(this.keysendUrl());if(e.ok){let t=await e.json();this.parseKeysendResponse(t)}}async fetchNostrData(){let e=await fetch(this.nostrUrl());if(e.ok){let t=await e.json();this.parseNostrResponse(t)}}lnurlpUrl(){return`https://${this.domain}/.well-known/lnurlp/${this.username}`}keysendUrl(){return`https://${this.domain}/.well-known/keysend/${this.username}`}nostrUrl(){return`https://${this.domain}/.well-known/nostr.json?name=${this.username}`}async generateInvoice(e){let t;if(this.options.proxy){let n=await fetch(`${this.options.proxy}/generate-invoice?${new URLSearchParams(zc({ln:this.address},e)).toString()}`);if(!n.ok)throw Error(`Failed to generate invoice: ${n.status} ${n.statusText}`);t=(await n.json()).invoice}else{if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);if(!this.lnurlpData.callback||!Ic(this.lnurlpData.callback))throw Error(`Valid callback does not exist in lnurlpData`);let n=new URL(this.lnurlpData.callback);n.search=new URLSearchParams(e).toString();let r=await fetch(n.toString());if(!r.ok)throw Error(`Failed to generate invoice: ${r.status} ${r.statusText}`);t=await r.json()}let n=t&&t.pr&&t.pr.toString();if(!n)throw Error(`Invalid pay service invoice`);let r={pr:n};if(t&&t.verify&&(r.verify=t.verify.toString()),t&&t.successAction&&typeof t.successAction==`object`){let{tag:e,message:n,description:i,url:a}=t.successAction;e===`message`?r.successAction={tag:e,message:n}:e===`url`&&(r.successAction={tag:e,description:i,url:a})}return new Oc(r)}async requestInvoice(e){if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);let t=1e3*e.satoshi,{commentAllowed:n,min:r,max:i}=this.lnurlpData;if(!Lc({amount:t,min:r,max:i}))throw Error(`Invalid amount`);if(e.comment&&n&&n>0&&e.comment.length>n)throw Error(`The comment length must be ${n} characters or fewer`);let a={amount:t.toString()};return e.comment&&(a.comment=e.comment),e.payerdata&&(a.payerdata=JSON.stringify(e.payerdata)),this.generateInvoice(a)}async boost(e,t=0){if(!this.keysendData)throw Error(`No keysendData available. Please call fetch() first.`);let{destination:n,customKey:r,customValue:i}=this.keysendData,a=this.getWebLN();if(!a)throw Error(`WebLN not available`);return Bc({destination:n,customKey:r,customValue:i,amount:t,boost:e},{webln:a})}async zapInvoice({satoshi:e,comment:t,relays:n,e:r},i={}){if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);if(!this.nostrPubkey)throw Error(`Nostr Pubkey is missing`);let a=this.nostrPubkey,o=1e3*e,{allowsNostr:s,min:c,max:l}=this.lnurlpData;if(!Lc({amount:o,min:c,max:l}))throw Error(`Invalid amount`);if(!s)throw Error(`Your provider does not support zaps`);let u=await Ac({satoshi:o,comment:t,p:a,e:r,relays:n},i),d={amount:o.toString(),nostr:JSON.stringify(u)};return await this.generateInvoice(d)}async zap(e,t={}){let n=this.zapInvoice(e,t),r=this.getWebLN();if(!r)throw Error(`WebLN not available`);return await r.enable(),r.sendPayment((await n).paymentRequest)}async parseLnUrlPayResponse(e){e&&(this.lnurlpData=await Rc(e))}parseKeysendResponse(e){e&&(this.keysendData=kc(e))}parseNostrResponse(e){e&&([this.nostrData,this.nostrPubkey,this.nostrRelays]=Pc(e,this.username))}};new class{constructor(e){this.storage=void 0,this.storage=e||{}}getItem(e){return this.storage[e]}setItem(e,t){this.storage[e]=t}};function Uc(){return Uc=Object.assign?Object.assign.bind():function(e){for(var t=1;tt.toString(16).padStart(2,`0`));function Gc(e){if(!(e instanceof Uint8Array))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n-1)throw Error(`hash router paths not supported`);let r=new URL(e);return t.name&&r.searchParams.set(`name`,t.name),r.searchParams.set(`pubkey`,n),t.returnTo&&r.searchParams.set(`return_to`,t.returnTo),t.budgetRenewal&&r.searchParams.set(`budget_renewal`,t.budgetRenewal),t.expiresAt&&r.searchParams.set(`expires_at`,Math.floor(t.expiresAt.getTime()/1e3).toString()),t.maxAmount&&r.searchParams.set(`max_amount`,t.maxAmount.toString()),t.requestMethods&&r.searchParams.set(`request_methods`,t.requestMethods.join(` `)),t.notificationTypes&&r.searchParams.set(`notification_types`,t.notificationTypes.join(` `)),t.isolated&&r.searchParams.set(`isolated`,`true`),t.metadata&&r.searchParams.set(`metadata`,JSON.stringify(t.metadata)),r}static fromAuthorizationUrl(t,n={},r){r||=Gc(Xe()),n.name||=document.location.host;let i=this.getAuthorizationUrl(t,n,$e(Kc(r))),a=window.outerHeight/2+window.screenY-300,o=window.outerWidth/2+window.screenX-200;return new Promise((t,n)=>{let s=window.open(i.toString(),`${document.title} - Wallet Connect`,`height=600,width=400,top=${a},left=${o}`);if(!s)return void n(Error(`failed to execute window.open`));let c=a=>{let o=a.data;o&&o.type===`nwc:success`&&a.origin===`${i.protocol}//${i.host}`&&(o.relayUrl||n(Error(`no relayUrl in response`)),o.walletPubkey||n(Error(`no walletPubkey in response`)),t(new e({relayUrl:o.relayUrl,walletPubkey:o.walletPubkey,secret:r,lud16:o.lud16})),clearInterval(l),window.removeEventListener(`message`,c),s&&s.close())},l=setInterval(()=>{s&&s.closed&&(clearInterval(l),window.removeEventListener(`message`,c),n(Error(`Popup closed`)))},500);window.addEventListener(`message`,c)})}async getWalletServiceInfo(){var e;await this._checkConnected();let t=await new Promise((e,t)=>{let n=[],r=this.relay.subscribe([{kinds:[13194],limit:1,authors:[this.walletPubkey]}],{eoseTimeout:1e4});r.onevent=e=>{n.push(e)},r.oneose=()=>{r.close(),e(n)}});if(!t.length)throw Error(`no info event (kind 13194) returned from relay`);let n=t[0].content,r=t[0].tags.find(e=>e[0]===`notifications`),i=t[0].tags.find(e=>e[0]===`v`),a=t[0].tags.find(e=>e[0]===`encryption`),o=[`nip04`];return i&&i[1].includes(`1.0`)&&o.push(`nip44_v2`),a&&(o=a[1].split(` `)),{encryptions:o,capabilities:n.split(/[ |,]/g),notifications:(r==null||(e=r[1])==null?void 0:e.split(` `))||[]}}async getInfo(){try{return await this.executeNip47Request(`get_info`,{},e=>!!e.methods,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_info`,e),e}}async getBudget(){try{return await this.executeNip47Request(`get_budget`,{},e=>e!==void 0,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_budget`,e),e}}async getBalance(){try{return await this.executeNip47Request(`get_balance`,{},e=>e.balance!==void 0,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_balance`,e),e}}async payInvoice(e){try{return await this.executeNip47Request(`pay_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request pay_invoice`,e),e}}async payKeysend(e){try{return await this.executeNip47Request(`pay_keysend`,e,e=>!!e.preimage)}catch(e){throw console.error(`Failed to request pay_keysend`,e),e}}async signMessage(e){try{return await this.executeNip47Request(`sign_message`,e,t=>t.message===e.message&&!!t.signature)}catch(e){throw console.error(`Failed to request sign_message`,e),e}}async createConnection(e){try{return await this.executeNip47Request(`create_connection`,e,e=>!!e.wallet_pubkey)}catch(e){throw console.error(`Failed to request create_connection`,e),e}}async multiPayInvoice(e){try{return{invoices:await this.executeMultiNip47Request(`multi_pay_invoice`,e,e.invoices.length,e=>!!e.preimage),errors:[]}}catch(e){throw console.error(`Failed to request multi_pay_invoice`,e),e}}async multiPayKeysend(e){try{return{keysends:await this.executeMultiNip47Request(`multi_pay_keysend`,e,e.keysends.length,e=>!!e.preimage),errors:[]}}catch(e){throw console.error(`Failed to request multi_pay_keysend`,e),e}}async makeInvoice(e){try{if(!e.amount)throw Error(`No amount specified`);return await this.executeNip47Request(`make_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request make_invoice`,e),e}}async makeHoldInvoice(e){try{if(!e.amount)throw Error(`No amount specified`);if(!e.payment_hash)throw Error(`No payment hash specified`);return await this.executeNip47Request(`make_hold_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request make_hold_invoice`,e),e}}async settleHoldInvoice(e){try{return await this.executeNip47Request(`settle_hold_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request settle_hold_invoice`,e),e}}async cancelHoldInvoice(e){try{return await this.executeNip47Request(`cancel_hold_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request cancel_hold_invoice`,e),e}}async lookupInvoice(e){try{return await this.executeNip47Request(`lookup_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request lookup_invoice`,e),e}}async listTransactions(e){try{return await this.executeNip47Request(`list_transactions`,e,e=>!!e.transactions,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request list_transactions`,e),e}}async subscribeNotifications(e,t){var n=this;let r,i,a,o=!0;return async function(){for(;o;){try{await n._checkConnected(),await n._selectEncryptionType(),a=n.relay.subscribe([{kinds:[...n.encryptionType===`nip04`?[23196]:[23197]],authors:[n.walletPubkey],"#p":[n.publicKey]}],{}),console.info(`subscribed to relay`),a.onevent=async function(r){let i=await n.decrypt(n.walletPubkey,r.content),a;try{a=JSON.parse(i)}catch(e){console.error(`Failed to parse decrypted event content`,e);return}a.notification?(!t||t.indexOf(a.notification_type)>-1)&&e(a):console.error(`No notification in response`,a)},await new Promise(e=>{r=()=>{e()},i=()=>{console.info(`relay disconnected`),r?.()},n.relay.onclose=i}),i!==void 0&&(n.relay.onclose=null)}catch(e){console.error(`error subscribing to notifications`,e||`unknown relay error`)}o&&await new Promise(e=>setTimeout(e,1e3))}}(),()=>{var e;o=!1,r?.(),(e=a)==null||e.close()}}async executeNip47Request(e,t,n,r){var i=this;return await this._checkConnected(),await this._selectEncryptionType(),new Promise((a,o)=>{(async function(){let s={method:e,params:t},c=await i.encrypt(i.walletPubkey,JSON.stringify(s)),l={kind:23194,created_at:Math.floor(Date.now()/1e3),tags:[[`p`,i.walletPubkey],[`v`,i.encryptionType===`nip44_v2`?`1.0`:`0.0`],[`encryption`,i.encryptionType]],content:c},u=await i.signEvent(l),d=i.relay.subscribe([{kinds:[23195],authors:[i.walletPubkey],"#e":[u.id]}],{}),f=setTimeout(function(){d.close(),o(new Qc(`reply timeout: event ${u.id}`,`INTERNAL`))},r?.replyTimeout||6e4);d.onevent=async function(e){clearTimeout(f),d.close();let t=await i.decrypt(i.walletPubkey,e.content),r;try{r=JSON.parse(t)}catch{clearTimeout(f),d.close(),o(new el(`failed to deserialize response`,`INTERNAL`));return}r.result?n(r.result)?a(r.result):(clearTimeout(f),d.close(),o(new tl(`response from NWC failed validation: `+JSON.stringify(r.result),`INTERNAL`))):(clearTimeout(f),d.close(),o(new Yc(r.error?.message||`unknown Error`,r.error?.code||`INTERNAL`)))};let p=setTimeout(function(){d.close(),o(new Zc(`publish timeout: ${u.id}`,`INTERNAL`))},r?.publishTimeout||5e3);try{await i.relay.publish(u),clearTimeout(p)}catch(e){clearTimeout(p),o(new $c(`failed to publish: ${e}`,`INTERNAL`))}})()})}async executeMultiNip47Request(e,t,n,r,i){var a=this;await this._checkConnected(),await this._selectEncryptionType();let o=[];return new Promise((s,c)=>{(async function(){let l={method:e,params:t},u=await a.encrypt(a.walletPubkey,JSON.stringify(l)),d={kind:23194,created_at:Math.floor(Date.now()/1e3),tags:[[`p`,a.walletPubkey],[`v`,a.encryptionType===`nip44_v2`?`1.0`:`0.0`],[`encryption`,a.encryptionType]],content:u},f=await a.signEvent(d),p=a.relay.subscribe([{kinds:[23195],authors:[a.walletPubkey],"#e":[f.id]}],{}),m=setTimeout(function(){p.close(),c(new Qc(`reply timeout: event ${f.id}`,`INTERNAL`))},i?.replyTimeout||6e4);p.onevent=async function(e){let t=await a.decrypt(a.walletPubkey,e.content),i;try{i=JSON.parse(t)}catch{clearTimeout(m),p.close(),c(new el(`failed to deserialize response`,`INTERNAL`))}if(i.result){if(!r(i.result))return clearTimeout(m),p.close(),void c(new tl(`Response from NWC failed validation: `+JSON.stringify(i.result),`INTERNAL`));let t=e.tags.find(e=>e[0]===`d`)?.[1];if(t===void 0)return clearTimeout(m),p.close(),void c(new tl(`No d tag found in response event`,`INTERNAL`));o.push(Uc({},i.result,{dTag:t})),o.length===n&&(clearTimeout(m),p.close(),s(o))}else clearTimeout(m),p.close(),c(new nl(i.error?.message,i.error?.code))};let h=setTimeout(function(){p.close(),c(new Zc(`Publish timeout: ${f.id}`,`INTERNAL`))},i?.publishTimeout||5e3);try{await a.relay.publish(f),clearTimeout(h)}catch(e){clearTimeout(h),c(new $c(`Failed to publish: ${e}`,`INTERNAL`))}})()})}async _checkConnected(){if(!this.secret)throw Error(`Missing secret key`);if(!this.relayUrl)throw Error(`Missing relay url`);try{this.relay.connected||await this.relay.connect()}catch{throw console.error(`failed to connect to relay`,this.relayUrl),new Jc(`Failed to connect to `+this.relayUrl,`OTHER`)}}async _selectEncryptionType(){if(!this._encryptionType){let e=await this.getWalletServiceInfo(),t=this._findPreferredEncryptionType(e.encryptions);if(!t)throw new rl(`no compatible encryption or version found between wallet and client`,`UNSUPPORTED_ENCRYPTION`);t===`nip04`&&console.warn(`NIP-04 encryption is about to be deprecated. Please upgrade your wallet service to use NIP-44 instead.`),this._encryptionType=t}}_findPreferredEncryptionType(e){return e.includes(`nip44_v2`)?`nip44_v2`:e.includes(`nip04`)?`nip04`:null}},al=class{constructor(e,t){this.transaction=void 0,this.invoice=void 0,this._nwcClient=void 0,this._unsubscribeFunc=void 0,this._timeoutFunc=void 0,this._timeoutId=void 0,this.transaction=t,this.invoice=new Oc({pr:t.invoice}),this._nwcClient=e}onPaid(e){var t=this;return async function(){let n;try{n=(await t._nwcClient.getInfo()).notifications?.includes(`payment_received`)}catch{console.error(`failed to fetch info, falling back to polling`)}let r=n=>{t._unsubscribeFunc==null||t._unsubscribeFunc(),e(n)},i=e=>()=>{t._timeoutFunc=void 0,clearTimeout(t._timeoutId),e()};n?t._unsubscribeFunc=i(await t._nwcClient.subscribeNotifications(e=>{e.notification.payment_hash===t.transaction.payment_hash&&r(e.notification)},[`payment_received`])):(console.warn(`current connection does not support notifications, falling back to polling`),t._unsubscribeFunc=i(t._onPaidPollingFallback(r)))}(),this}onTimeout(e,t){return this._timeoutFunc=()=>{var e;(e=this._unsubscribeFunc)==null||e.call(this),t()},this._timeoutId=setTimeout(()=>{var e;(e=this._timeoutFunc)==null||e.call(this)},1e3*e),this}unsubscribe(){var e;(e=this._unsubscribeFunc)==null||e.call(this)}_onPaidPollingFallback(e){var t=this;let n=!0;return async function(){for(;n;){let r=await t._nwcClient.lookupInvoice({payment_hash:t.transaction.payment_hash});if(r.settled_at&&r.preimage){e(r),n=!1;break}await new Promise(e=>setTimeout(e,3e3))}}(),()=>{n=!1}}};async function ol(e){if(typeof e==`number`)return{satoshi:e,millisat:1e3*e};let t=await Promise.resolve(e.satoshi);return{satoshi:t,millisat:1e3*t}}var sl=class{constructor(e){this.nwcClient=void 0,this.nwcClient=typeof e==`string`?new il({nostrWalletConnectUrl:e}):e instanceof il?e:new il(e)}async pay(e,t,n){let r=e,i=t?await ol(t):void 0;if(r.indexOf(`@`)>-1){var a,o;if(!i)throw Error(`Amount must be provided when paying to a lightning address`);let t=new Hc(e);await t.fetch(),r=(await t.requestInvoice({satoshi:i.satoshi,comment:n==null||(a=n.metadata)==null?void 0:a.comment,payerdata:n==null||(o=n.metadata)==null?void 0:o.payer_data})).paymentRequest}let s=await this.nwcClient.payInvoice(Uc({},n||{},{invoice:r,amount:i?.millisat}));return Uc({},s,{invoice:new Oc({pr:r})})}async requestPayment(e,t){let n=await ol(e),r=await this.nwcClient.makeInvoice(Uc({},t||{},{amount:n.millisat}));return new al(this.nwcClient,r)}close(){this.nwcClient.close()}},cl=100000000000n,ll={m:1000n,u:1000000n,n:1000000000n,p:1000000000000n},ul=/^ln(bcrt|bc|tbs|tb|sb)(?:(\d+)([munp])?)?$/,dl=1,fl=13,pl=19,ml=23,hl=6,gl=104,_l=7,vl=3600;function yl(e){let t=new Uint8Array(Math.floor(e.length*5/8)),n=0,r=0,i=0;for(let a of e)for(n=n<<5|a,r+=5;r>=8;)r-=8,t[i++]=n>>r&255;return t}function bl(e){let t=0;for(let n of e)t=t*32+n;return t}function xl(e,t){if(!e)return null;let n=BigInt(e),r=t?ll[t]:1n,i=n*cl;if(i%r!==0n)throw Error(`Invalid BOLT11 invoice: amount is not a whole number of millisatoshis`);let a=i/r;if(a>BigInt(2**53-1))throw Error(`Invalid BOLT11 invoice: amount is implausibly large`);return Number(a)}function Sl(e){let t=e.trim().replace(/^lightning:/i,``).toLowerCase();if(!t.startsWith(`ln`))throw Error(`Invalid BOLT11 invoice: missing "ln" prefix`);let{prefix:n,words:r}=nt.decode(t,!1),i=ul.exec(n);if(!i)throw Error(`Invalid BOLT11 invoice: unrecognized prefix`);let[,a,o,s]=i,c=xl(o,s);if(r.length<111)throw Error(`Invalid BOLT11 invoice: truncated`);let l=bl(r.slice(0,_l)),u=r.slice(_l,r.length-gl),d={amountMsat:c,network:a,timestamp:l,expiry:vl};for(let e=0;e+3<=u.length;){let t=u[e],n=u[e+1]*32+u[e+2],r=e+3,i=r+n;if(i>u.length)throw Error(`Invalid BOLT11 invoice: tagged field overruns the invoice`);let a=u.slice(r,i);switch(e=i,t){case dl:n===52&&(d.paymentHash=rt(yl(a)));break;case ml:n===52&&(d.descriptionHash=rt(yl(a)));break;case pl:n===53&&(d.payee=rt(yl(a)));break;case fl:d.description=new TextDecoder().decode(yl(a));break;case hl:d.expiry=bl(a);break}}return d}function Cl(e,t){let n;try{n=Sl(e)}catch(e){throw Error(`Lightning service returned an unreadable invoice: ${e instanceof Error?e.message:`unknown error`}`)}if(n.amountMsat===null)throw Error(`Lightning service returned an invoice with no amount, which would let it charge any sum. Payment cancelled.`);if(n.amountMsat!==t)throw Error(`Lightning service returned an invoice for ${Math.round(n.amountMsat/1e3)} sats, but ${Math.round(t/1e3)} sats was requested. Payment cancelled.`);return{...n,amountMsat:n.amountMsat}}function wl(e,t){if(!e.descriptionHash)return!0;let n=new TextEncoder;return t.some(t=>rt(it(n.encode(t)))===e.descriptionHash)}function Tl(e){let{toast:t}=Mn(),n=e?`nwc-connections:${e}`:`nwc-connections`,r=e?`nwc-active-connection:${e}`:`nwc-active-connection`,[i,a]=Ws(n,[]),[o,s]=Ws(r,null),[c,l]=(0,G.useState)({});return{connections:i,activeConnection:o,connectionInfo:c,addConnection:async(e,n)=>{let r=(e=>{try{return!e.startsWith(`nostr+walletconnect://`)&&!e.startsWith(`nostrwalletconnect://`)?(console.error(`Invalid NWC URI protocol:`,{protocol:e.split(`://`)[0]}),null):{connectionString:e}}catch(e){return console.error(`Failed to parse NWC URI:`,e),null}})(e);if(!r)return t({title:`Invalid NWC URI`,description:`Please check the connection string and try again.`,variant:`destructive`}),!1;if(i.find(e=>e.connectionString===r.connectionString))return t({title:`Connection already exists`,description:`This wallet is already connected.`,variant:`destructive`}),!1;try{let e,c=new Promise((e,t)=>{try{e(new sl(r.connectionString))}catch(e){t(e)}}),u=new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Connection test timeout`)),1e4)});try{await Promise.race([c,u]),e&&clearTimeout(e)}catch(t){throw e&&clearTimeout(e),t}let d={connectionString:r.connectionString,alias:n||`NWC Wallet`,isConnected:!0};l(e=>({...e,[r.connectionString]:{alias:d.alias,methods:[`pay_invoice`]}}));let f=[...i,d];return a(f),(i.length===0||!o)&&s(r.connectionString),t({title:`Wallet connected`,description:`Successfully connected to ${d.alias}.`}),!0}catch(e){console.error(`NWC connection failed:`,e);let n=e instanceof Error?e.message:`Unknown error occurred`;return t({title:`Connection failed`,description:`Could not connect to the wallet: ${n}`,variant:`destructive`}),!1}},removeConnection:e=>{let n=i.filter(t=>t.connectionString!==e);if(a(n),o===e){let e=n.length>0?n[0].connectionString:null;s(e)}l(t=>{let n={...t};return delete n[e],n}),t({title:`Wallet disconnected`,description:`The wallet connection has been removed.`})},setActiveConnection:s,getActiveConnection:(0,G.useCallback)(()=>!o&&i.length>0?(s(i[0].connectionString),i[0]):o&&i.find(e=>e.connectionString===o)||null,[o,i,s]),sendPayment:(0,G.useCallback)(async(e,t,n)=>{if(!e.connectionString)throw Error(`Invalid connection: missing connection string`);Cl(t,n);let r;try{r=new sl(e.connectionString)}catch(e){throw console.error(`Failed to create NWC client:`,e),Error(`Failed to create NWC client: ${e instanceof Error?e.message:`Unknown error`}`)}try{let e,n=new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Payment timeout after 15 seconds`)),15e3)}),i=r.pay(t);try{let t=await Promise.race([i,n]);return e&&clearTimeout(e),t}catch(t){throw e&&clearTimeout(e),t}}catch(e){throw console.error(`NWC payment failed:`,e),e instanceof Error?e.message.includes(`timeout`)?Error(`Payment timed out. Please try again.`):e.message.includes(`insufficient`)?Error(`Insufficient balance in connected wallet.`):e.message.includes(`invalid`)?Error(`Invalid invoice or connection. Please check your wallet.`):Error(`Payment failed: ${e.message}`):Error(`Payment failed with unknown error`)}},[])}}var El=(0,G.createContext)(null);function Dl(){let e=(0,G.useContext)(El);if(!e)throw Error(`useNWC must be used within a NWCProvider`);return e}function Ol({children:e}){let{user:t}=V(),n=Tl(t?.pubkey);return(0,K.jsx)(El.Provider,{value:n,children:e})}function kl(){return!1}var Al=(0,G.createContext)(null);function jl(){let e=(0,G.useContext)(Al);return!kl()||!e?{devEmotion:null,setDevEmotion:()=>{},clearDevEmotion:()=>{},isDevEmotionActive:!1}:e}function Ml(e){let{devEmotion:t,isDevEmotionActive:n}=jl();return kl()&&n&&t?t:e??`neutral`}function Nl({children:e}){let[t,n]=(0,G.useState)(null),r={devEmotion:t,setDevEmotion:(0,G.useCallback)(e=>{kl()&&n(e)},[]),clearDevEmotion:(0,G.useCallback)(()=>{n(null)},[]),isDevEmotionActive:t!==null};return(0,K.jsx)(Al.Provider,{value:r,children:e})}function Pl(){let{currentTrack:e,minimized:t,minimize:n}=di(),r=lr(),i=(0,G.useRef)(r.pathname);return(0,G.useEffect)(()=>{r.pathname!==i.current&&(e&&!t&&n(),i.current=r.pathname)},[r.pathname,e,t,n]),null}function Fl(){return(0,G.useEffect)(()=>{if(_n.getPlatform()!==`android`)return;let e;async function t(){let{App:t}=await z(async()=>{let{App:e}=await import(`./esm-CGtja3l7.js`);return{App:e}},__vite__mapDeps([61,41,1])),n=await t.addListener(`backButton`,({canGoBack:e})=>{e?window.history.back():t.minimizeApp()});e=()=>n.remove()}return t(),()=>{e?.()}},[]),null}var Il=[`npub1`,`nprofile1`,`note1`,`nevent1`,`naddr1`];function J(e){let t=e.startsWith(`@`)?e.slice(1):e;if(t.includes(`@`)){let e=t.indexOf(`@`);return e>0&&e0&&nt.startsWith(e))}function Ll(e){let t=e.trim();if(!/^https?:\/\//i.test(t))return!1;try{return new URL(t),!0}catch{return!1}}function Y(e){let t=e.trim();if(!t)return null;let n=t.startsWith(`nostr:`)?t.slice(6):t;if(Il.some(e=>n.startsWith(e)))try{return{decoded:tt.decode(n),raw:n}}catch{}return null}function X(e){return Bn(e.trim())}function Z(e){let t=e.trim();if(!t||Ll(t))return null;let n=t.startsWith(`nostr:`)?t.slice(6):t,r=Y(n);if(r){let{decoded:e,raw:t}=r;switch(e.type){case`npub`:return{type:`npub`,pubkey:e.data,raw:t};case`nprofile`:return{type:`nprofile`,pubkey:e.data.pubkey,raw:t};case`note`:return{type:`note`,eventId:e.data,raw:t};case`nevent`:return{type:`nevent`,eventId:e.data.id,relays:e.data.relays,authorHint:e.data.author,raw:t};case`naddr`:return{type:`naddr`,addr:{kind:e.data.kind,pubkey:e.data.pubkey,identifier:e.data.identifier},relays:e.data.relays,raw:t}}}return X(n)?{type:`hex`,hex:n}:J(n)?{type:`nip05`,identifier:n.startsWith(`@`)?n.slice(1):n}:null}function Rl(e){let t=e.trim();if(!t)return null;let n=t.startsWith(`nostr:`)?t.slice(6):t;if(Il.some(e=>n.startsWith(e)))try{return tt.decode(n),`/${n}`}catch{}return Bn(n)?`/${n}`:J(n)?`/${n.startsWith(`@`)?n.slice(1):n}`:null}function zl(){let e=rr();return(0,G.useEffect)(()=>{if(!_n.isNativePlatform())return;let t;async function n(){let{App:n}=await z(async()=>{let{App:e}=await import(`./esm-CGtja3l7.js`);return{App:e}},__vite__mapDeps([61,41,1])),r=await n.addListener(`appUrlOpen`,t=>{let n=t.url?.trim();if(!n)return;if(/^bitcoin:/i.test(n)){e(`/wallet`,{state:{bip21Uri:n}});return}let r=/^nostr:/i.exec(n);if(r){let t=Rl(`nostr:${n.slice(r[0].length)}`);t&&e(t);return}try{let t=new URL(n);if(t.protocol!==`https:`||t.pathname.startsWith(`//`))return;let r=t.pathname+t.search+t.hash;r&&e(r)}catch{}});t=()=>r.remove()}return n(),()=>{t?.()}},[e]),null}var Bl=hn(`DittoNotification`);function Vl(e){return/^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@%/?#[\]]*$/.test(e)}function Hl(){let e=rr();return(0,G.useEffect)(()=>{if(!_n.isNativePlatform())return;let t=[],n=!1;async function r(){let r=await Bl.addListener(`share`,({mode:t,text:n})=>{n&&e(`/share`,{state:{mode:t===`view`?`view`:`post`,text:n}})}),i=await Bl.addListener(`notificationTap`,({path:t})=>{!t||!Vl(t)||e(t)});if(n){r.remove(),i.remove();return}t.push(r,i)}return r(),()=>{n=!0;for(let e of t)e.remove()}},[e]),null}var Ul=t(Te(),1),Wl=5e3,Gl=8e3,Kl=350;function ql(){let[e,t]=(0,G.useState)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||e.rangeCount===0){t(null);return}let n=Yl(e.toString());if(!n||n.length>Wl){t(null);return}let r=e.getRangeAt(0),i=Dt(r.startContainer),a=Dt(r.endContainer);if(!i||!a||i.id!==a.id){t(null);return}if((r.startContainer instanceof Element?r.startContainer:r.startContainer.parentElement)?.closest(`input, textarea, [contenteditable="true"]`)){t(null);return}let o=Zl(r,Jl(r.startContainer),n),s=r.getBoundingClientRect();if(s.width===0&&s.height===0){t(null);return}t({text:n,context:o,source:i,rect:s})},[]),a=(0,G.useCallback)(()=>{n.current!==null&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{n.current=null,i()})},[i]),o=(0,G.useCallback)(()=>{r.current!==null&&clearTimeout(r.current);let e=window.getSelection();if(!e||e.isCollapsed||e.rangeCount===0||!e.toString().trim()){n.current!==null&&cancelAnimationFrame(n.current),t(null);return}r.current=setTimeout(a,Kl)},[a]);return(0,G.useEffect)(()=>(document.addEventListener(`selectionchange`,o),window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`selectionchange`,o),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a),n.current!==null&&cancelAnimationFrame(n.current),r.current!==null&&clearTimeout(r.current)}),[a,o]),{selection:e,clear:(0,G.useCallback)(()=>{r.current!==null&&clearTimeout(r.current),window.getSelection()?.removeAllRanges(),t(null)},[])}}function Jl(e){let t=e instanceof Element?e:e?.parentElement??null;for(;t;){if(t.hasAttribute(`data-highlight-id`))return t;t=t.parentElement}return null}function Yl(e){return e.replace(/\r\n?/g,` `).replace(/[ \t]+\n/g,` `).trim()}var Xl=new Set([`P`,`LI`,`BLOCKQUOTE`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`PRE`,`TD`,`FIGCAPTION`]);function Zl(e,t,n){if(!t)return;let r=e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement;for(;r&&r!==t&&!Xl.has(r.tagName);)r=r.parentElement;if(r&&r!==t&&Xl.has(r.tagName)){let e=Yl(r.textContent??``);if(Ql(e,n))return e}let i=Yl(t.textContent??``);if(i.includes(n)){let e=i.split(/\n{2,}/).find(e=>e.includes(n))?.trim();if(e&&Ql(e,n))return e;if(Ql(i,n))return i}}function Ql(e,t){return!!e&&e.length<=Gl&&e!==t&&e.includes(t)}function $l(){let{mutateAsync:e}=zn(),t=ht();return Ct({mutationFn:async({text:t,context:n,source:r,comment:i})=>{let a=Ot(r,n),o=i?.trim();return o&&a.push([`comment`,o]),e({kind:9802,content:t,tags:a})},onSuccess:(e,{source:n})=>{t.invalidateQueries({queryKey:[`nostr`,`highlights`,n.id]})}})}var eu=8,tu=92,nu=32,ru=768,iu=()=>typeof window<`u`&&(`ontouchstart`in window||(navigator.maxTouchPoints??0)>0);function au(){let{user:e}=V(),{selection:t,clear:n}=ql(),{toast:r}=Mn(),{mutateAsync:i,isPending:a}=$l(),{pathname:o}=lr(),[s]=(0,G.useState)(iu),[c]=(0,G.useState)(()=>_n.isNativePlatform()),[l,u]=(0,G.useState)(()=>typeof window>`u`?0:window.innerWidth);(0,G.useEffect)(()=>{let e=()=>u(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let d=c||s&&l{f||h(``)},[f]),(0,G.useEffect)(()=>{window.getSelection()?.removeAllRanges(),p(null)},[o]);let _=()=>{t&&p(t)},v=()=>{p(null),n()},y=async()=>{if(f)try{let e=await i({text:f.text,context:f.context,source:f.source,comment:m}),t=Ur({id:e.id,author:e.pubkey,kind:e.kind});r({title:`Highlight published`,action:t?(0,K.jsx)(ji,{altText:`View highlight`,asChild:!0,children:(0,K.jsx)(or,{to:`/${t}`,children:`View`})}):void 0}),v()}catch(e){r({title:`Failed to publish highlight`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}},b=(0,G.useMemo)(()=>{if(!f||!e)return null;let t=Ot(f.source,f.context),n=m.trim();return n&&t.push([`comment`,n]),{id:``,sig:``,kind:9802,pubkey:e.pubkey,created_at:Math.floor(Date.now()/1e3),content:f.text,tags:t}},[f,e,m]);return(0,K.jsxs)(K.Fragment,{children:[g&&(0,Ul.createPortal)(d?(0,K.jsx)(ou,{onActivate:_}):(0,K.jsx)(su,{rect:t.rect,onActivate:_}),document.body),(0,K.jsx)(Ci,{open:!!f,onOpenChange:e=>{e||v()},children:(0,K.jsxs)(Si,{className:`max-w-[480px]`,children:[(0,K.jsx)(yi,{children:(0,K.jsx)(bi,{children:`Create highlight`})}),b&&(0,K.jsx)(`div`,{className:`max-h-[40dvh] overflow-y-auto`,children:(0,K.jsx)(xa,{event:b,expanded:!0,className:`mt-0`})}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`highlight-comment`,className:`text-sm font-medium`,children:[`Add a comment `,(0,K.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,K.jsx)(wi,{id:`highlight-comment`,value:m,onChange:e=>h(e.target.value),placeholder:`Why is this worth highlighting?`,rows:3})]}),(0,K.jsxs)(xi,{children:[(0,K.jsx)(Rn,{variant:`outline`,onClick:v,disabled:a,children:`Cancel`}),(0,K.jsx)(Rn,{onClick:y,disabled:a,children:a?`Publishing...`:`Highlight`})]})]})})]})}function ou({onActivate:e}){return(0,K.jsx)(`div`,{style:{position:`fixed`,left:0,right:0,bottom:`calc(1.5rem + var(--bottom-nav-height, 0px) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))`,zIndex:45},className:`flex justify-center px-4 pointer-events-none`,children:(0,K.jsx)(`button`,{type:`button`,onPointerUp:t=>{t.stopPropagation(),e()},className:`pointer-events-auto inline-flex items-center justify-center rounded-full bg-primary/90 px-6 py-2.5 text-sm font-semibold text-primary-foreground opacity-95 shadow-xl ring-1 ring-black/10 backdrop-blur-md transition-all hover:bg-primary hover:opacity-100 active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-safe:duration-200`,children:`Highlight`})})}function su({rect:e,onActivate:t}){let n=e.bottom<=0,r=e.top>=window.innerHeight;if(n||r)return null;let i=Math.max(eu,e.top-nu-eu),a=e.left+e.width/2-tu/2;return(0,K.jsx)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),t()},style:{position:`fixed`,top:i,left:Math.min(Math.max(eu,a),window.innerWidth-tu-eu),zIndex:60},className:H(`inline-flex items-center justify-center rounded-full bg-primary/90 px-4 py-1.5 text-sm font-medium text-primary-foreground opacity-95 shadow-lg ring-1 ring-black/10 backdrop-blur-md transition-all hover:scale-105 hover:bg-primary hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-95 motion-safe:duration-200`),children:`Highlight`})}var cu=`audio-minibar-position`,lu=4;function uu(){try{let e=localStorage.getItem(cu);if(e)return JSON.parse(e)}catch{}return null}function du(){return window.matchMedia(`(min-width: 900px)`).matches?0:56}function fu(e,t,n,r){let i=window.innerWidth-n,a=window.innerHeight-r-du();return{x:Math.max(0,Math.min(e,i)),y:Math.max(0,Math.min(t,a))}}function pu(){let e=di(),{currentTrack:t,minimized:n,isPlaying:i,currentTime:a,duration:o,playlist:s,currentIndex:c,loadState:l,artworkSrc:u}=e,d=rr(),p=(0,G.useRef)(null),[m,g]=(0,G.useState)(()=>{let e=uu(),t={x:16,y:window.innerHeight-80-du()};return e?fu(e.x,e.y,300,64):t}),_=(0,G.useRef)(!1),v=(0,G.useRef)(!1),y=(0,G.useRef)({x:0,y:0}),b=(0,G.useRef)({x:0,y:0});(0,G.useEffect)(()=>{let e=()=>{g(e=>{let t=p.current,n=t?.offsetWidth??300,r=t?.offsetHeight??64;return fu(e.x,e.y,n,r)})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{try{localStorage.setItem(cu,JSON.stringify(m))}catch{}},[m]);let x=(0,G.useCallback)(e=>{e.target.closest(`[data-drag-handle]`)&&(e.preventDefault(),e.target.setPointerCapture(e.pointerId),_.current=!0,v.current=!1,y.current={x:e.clientX,y:e.clientY},b.current={...m})},[m]),S=(0,G.useCallback)(e=>{if(!_.current)return;let t=e.clientX-y.current.x,n=e.clientY-y.current.y;if(!v.current&&Math.abs(t)+Math.abs(n){_.current&&=(e.target.releasePointerCapture(e.pointerId),!1)},[]);if(!t||!n)return null;let T=o>0?a/o*100:0,E=s.length>1,D=E&&(c>0||a>3),O=E&&ce.prevTrack(),disabled:!D,className:`p-1.5 rounded-full hover:bg-secondary transition-colors disabled:opacity-30`,"aria-label":`Previous`,children:(0,K.jsx)(r,{className:`size-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>i?e.pause():e.resume(),disabled:l.status===`decrypting`,className:`p-1.5 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:cursor-progress`,"aria-label":i?`Pause`:`Play`,children:l.status===`decrypting`?(0,K.jsx)(F,{className:`size-3.5 animate-spin`}):i?(0,K.jsx)(f,{className:`size-3.5`,fill:`currentColor`}):(0,K.jsx)(ce,{className:`size-3.5 ml-0.5`,fill:`currentColor`})}),E&&(0,K.jsx)(`button`,{onClick:()=>e.nextTrack(),disabled:!O,className:`p-1.5 rounded-full hover:bg-secondary transition-colors disabled:opacity-30`,"aria-label":`Next`,children:(0,K.jsx)(C,{className:`size-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>{e.expand(),t.path&&d(t.path)},className:`p-1.5 rounded-full hover:bg-secondary transition-colors`,"aria-label":`Expand`,children:(0,K.jsx)(fe,{className:`size-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>e.stop(),className:`p-1.5 rounded-full hover:bg-secondary transition-colors`,"aria-label":`Close`,children:(0,K.jsx)(M,{className:`size-3.5`})})]})]}),(0,K.jsx)(`div`,{className:`mx-3 h-0.5 rounded-full bg-border overflow-hidden -mt-0.5`,children:(0,K.jsx)(`div`,{className:H(`h-full bg-primary transition-[width] duration-200`),style:{width:`${T}%`}})})]})}var mu=`audio-player-volume`,hu={status:`ready`};function gu(){try{let e=localStorage.getItem(mu);if(e!==null){let t=parseFloat(e);if(isFinite(t)&&t>=0&&t<=1)return t}}catch{}return .8}function _u({children:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(0),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(0),[m,h]=(0,G.useState)(0),[g,_]=(0,G.useState)(gu),[v,y]=(0,G.useState)(hu),[b,x]=(0,G.useState)(),{config:S}=Nt(),C=(0,G.useRef)([]);C.current=Mr(S.blossomServerMetadata,S.useAppBlossomServers);let w=(0,G.useRef)(void 0),T=(0,G.useRef)(0),E=(0,G.useRef)(void 0),D=(0,G.useRef)(void 0),O=(0,G.useCallback)(()=>{w.current&&=(URL.revokeObjectURL(w.current),void 0)},[]),k=(0,G.useCallback)((e,n={})=>{let r=t.current;if(!r)return;let i=++T.current;if(E.current?.abort(),E.current=void 0,O(),D.current=e,!e.encryption){y(hu),r.src=e.url,r.play().catch(()=>{});return}if(r.pause(),r.removeAttribute(`src`),r.load(),!yn(e.encryption)){y({status:`unsupported`});return}y({status:`decrypting`});let a=new AbortController;E.current=a,bn(e.url,e.encryption,{signal:a.signal,fallbackUrls:da(e.url,C.current),...n.allowOversize?{maxBytes:1/0}:{}}).then(({objectUrl:e})=>{if(i!==T.current){URL.revokeObjectURL(e);return}w.current=e,y(hu),r.src=e,r.play().catch(()=>{})}).catch(e=>{i===T.current&&(e instanceof xn?y({status:`too-large`,byteSize:e.byteSize}):a.signal.aborted||y({status:`failed`}))})},[O]),ee=(0,G.useCallback)(()=>{let e=D.current;e&&k(e,{allowOversize:!0})},[k]),A=(0,G.useCallback)(e=>{let t=i[e];t&&(s(e),r(t),p(0),h(t.duration??0),k(t))},[i,k]);(0,G.useEffect)(()=>{let e=n?.artwork,t=n?.artworkEncryption;if(!e){x(void 0);return}if(!t){x(e);return}if(x(void 0),!yn(t))return;let r,i=!1,a=new AbortController;return bn(e,t,{signal:a.signal,fallbackUrls:da(e,C.current)}).then(e=>{if(i){URL.revokeObjectURL(e.objectUrl);return}r=e.objectUrl,x(e.objectUrl)}).catch(()=>{}),()=>{i=!0,a.abort(),r&&URL.revokeObjectURL(r)}},[n?.artwork,n?.artworkEncryption]),(0,G.useEffect)(()=>()=>{E.current?.abort(),O()},[O]),(0,G.useEffect)(()=>{t.current&&(t.current.volume=g)},[g]),(0,G.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>d(!0),r=()=>d(!1),a=()=>{d(!1),i.length>0&&op(e.currentTime),c=()=>{e.duration&&isFinite(e.duration)&&h(e.duration)};return e.addEventListener(`play`,n),e.addEventListener(`pause`,r),e.addEventListener(`ended`,a),e.addEventListener(`timeupdate`,s),e.addEventListener(`durationchange`,c),e.addEventListener(`loadedmetadata`,c),()=>{e.removeEventListener(`play`,n),e.removeEventListener(`pause`,r),e.removeEventListener(`ended`,a),e.removeEventListener(`timeupdate`,s),e.removeEventListener(`durationchange`,c),e.removeEventListener(`loadedmetadata`,c)}},[i,o,A]),(0,G.useEffect)(()=>{if(!(`mediaSession`in navigator))return;if(!n){navigator.mediaSession.metadata=null;return}let e=b?[{src:b,sizes:`512x512`}]:[];navigator.mediaSession.metadata=new MediaMetadata({title:n.title,artist:n.artist,artwork:e})},[n,b]),(0,G.useEffect)(()=>{`mediaSession`in navigator&&(navigator.mediaSession.playbackState=u?`playing`:`paused`)},[u]),(0,G.useEffect)(()=>{if(`mediaSession`in navigator&&!(!n||m<=0))try{navigator.mediaSession.setPositionState({duration:m,playbackRate:t.current?.playbackRate??1,position:Math.min(f,m)})}catch{}},[f,m,n]),(0,G.useEffect)(()=>{if(!(`mediaSession`in navigator))return;let e=t.current;return navigator.mediaSession.setActionHandler(`play`,()=>e?.play().catch(()=>{})),navigator.mediaSession.setActionHandler(`pause`,()=>e?.pause()),navigator.mediaSession.setActionHandler(`previoustrack`,()=>{if(e&&e.currentTime>3){e.currentTime=0;return}i.length!==0&&A(o-1)}),navigator.mediaSession.setActionHandler(`nexttrack`,()=>{A(o+1)}),navigator.mediaSession.setActionHandler(`seekto`,t=>{e&&t.seekTime!=null&&(e.currentTime=t.seekTime)}),()=>{navigator.mediaSession.setActionHandler(`play`,null),navigator.mediaSession.setActionHandler(`pause`,null),navigator.mediaSession.setActionHandler(`previoustrack`,null),navigator.mediaSession.setActionHandler(`nexttrack`,null),navigator.mediaSession.setActionHandler(`seekto`,null)}},[o,i,A]),(0,G.useEffect)(()=>{if(!n)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[n]);let j=(0,G.useCallback)(e=>{r(e),a([]),s(0),l(!1),p(0),h(e.duration??0),k(e)},[k]),M=(0,G.useCallback)((e,t=0)=>{if(e.length===0)return;let n=Math.max(0,Math.min(t,e.length-1));a(e),s(n),r(e[n]),l(!1),p(0),h(e[n].duration??0),k(e[n])},[k]),N=(0,G.useCallback)(()=>{t.current?.pause()},[]),te=(0,G.useCallback)(()=>{t.current?.play().catch(()=>{})},[]),ne=(0,G.useCallback)(e=>{let n=t.current;n&&(n.currentTime=e)},[]),re=(0,G.useCallback)(e=>{let t=Math.max(0,Math.min(1,e));_(t);try{localStorage.setItem(mu,String(t))}catch{}},[]),P=(0,G.useCallback)(()=>{i.length!==0&&A(o+1)},[i,o,A]),F=(0,G.useCallback)(()=>{let e=t.current;if(!(!e||i.length===0)){if(e.currentTime>3){e.currentTime=0;return}A(o-1)}},[i,o,A]),I=(0,G.useCallback)(()=>l(!0),[]),L=(0,G.useCallback)(()=>l(!1),[]),R=(0,G.useCallback)(()=>{let e=t.current;e&&(e.pause(),e.src=``),T.current++,E.current?.abort(),E.current=void 0,D.current=void 0,O(),y(hu),r(null),a([]),s(0),l(!1),d(!1),p(0),h(0)},[O]);return(0,K.jsxs)(ui.Provider,{value:{currentTrack:n,playlist:i,currentIndex:o,minimized:c,isPlaying:u,currentTime:f,duration:m,volume:g,loadState:v,artworkSrc:b,playTrack:j,playPlaylist:M,pause:N,resume:te,seek:ne,setVolume:re,nextTrack:P,prevTrack:F,minimize:I,expand:L,stop:R,decryptAnyway:ee},children:[(0,K.jsx)(`audio`,{ref:t,preload:`metadata`,className:`hidden`}),e]})}var vu=(0,G.createContext)(null);function yu({children:e}){let t=(0,G.useRef)(null),n=(0,G.useRef)(!1),r=(0,G.useRef)(!1),i=(0,G.useRef)(new Set),a=(0,G.useCallback)(e=>(i.current.add(e),()=>{i.current.delete(e)}),[]),o=(0,G.useCallback)(()=>{i.current.forEach(e=>e())},[]),s=(0,G.useMemo)(()=>({registerRef:t,canUseItemsRegisteredRef:n,isUsingItemRegisteredRef:r,notifyUpdate:o,subscribe:a}),[o,a]);return(0,K.jsx)(vu.Provider,{value:s,children:e})}var bu=768;function xu(){let{toasts:e}=Mn(),[t,n]=(0,G.useState)(window.innerWidth>=bu);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${bu}px)`),t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,K.jsxs)(Ni,{swipeDirection:t?`right`:`up`,swipeThreshold:30,children:[e.map(function({id:e,title:t,description:n,action:r,...i}){return(0,K.jsxs)(W,{...i,children:[(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[t&&(0,K.jsx)(Oi,{children:t}),n&&(0,K.jsx)(Ti,{children:n})]}),r,(0,K.jsx)(Fi,{})]},e)}),(0,K.jsx)(Mi,{})]})}async function Su(e,t,n){let r=new URLSearchParams({action:`query`,generator:`search`,gsrsearch:e,gsrnamespace:`0`,gsrlimit:`10`,prop:`pageimages|description`,piprop:`thumbnail`,pithumbsize:`80`,pilicense:`any`,format:`json`,origin:`*`}),i=await fetch(`https://${t}.wikipedia.org/w/api.php?${r}`,{signal:n,headers:{Accept:`application/json`}});if(!i.ok)return[];let a=(await i.json())?.query?.pages??{};return Object.values(a).sort((e,t)=>e.index-t.index).map(e=>({title:e.title,description:e.description??``,url:`https://${t}.wikipedia.org/wiki/${encodeURIComponent(e.title.replace(/ /g,`_`))}`,thumbnail:e.thumbnail?.source}))}function Cu(e){let{locale:t}=pn();return yt({queryKey:[`wikipedia-search`,t,e],queryFn:({signal:n})=>Su(e,t,n),enabled:e.trim().length>=2,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,placeholderData:e=>e})}var wu=[`software`,`movies`,`audio`,`etree`,`texts`];async function Tu(e,t){let n=`title:(${e}) mediatype:(${wu.join(` OR `)})`,r=`https://archive.org/advancedsearch.php?q=${encodeURIComponent(n)}&fl[]=identifier&fl[]=title&fl[]=mediatype&fl[]=downloads&sort[]=-downloads&rows=12&output=json`,i=await fetch(r,{signal:t,headers:{Accept:`application/json`}});return i.ok?(await i.json()).response.docs.map(e=>({identifier:e.identifier,title:e.title,mediatype:e.mediatype,downloads:e.downloads})):[]}function Eu(e){return yt({queryKey:[`archive-search`,e],queryFn:({signal:t})=>Tu(e,t),enabled:e.trim().length>=2,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,placeholderData:e=>e})}var Du=30023,Ou=3e4,ku=30030,Au=39089,ju=31990,Mu=[Du,Ou,ku,Au],Nu=[qr,Gr,ju];function Pu(e){return e===Du?`article`:e===Ou?`list`:e===ku?`emoji-pack`:e===Au?`follow-pack`:e===15128||e===35128?`nsite`:e===ju?`app`:null}function Fu(e,t){return e.tags.find(([e])=>e===t)?.[1]}var Iu={article:`Untitled`,list:`Untitled list`,"follow-pack":`Untitled Pack`,"emoji-pack":`Untitled pack`,nsite:`Untitled site`,app:`Untitled app`},Lu=new Set([`list`,`emoji-pack`,`nsite`,`app`]);function Ru(e){return e>=3e4&&e<4e4}function zu(e){if(!e)return{};try{let t=JSON.parse(e);if(typeof t==`object`&&t&&!Array.isArray(t))return t}catch{}return{}}function Bu(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function Vu(e){let t=Pu(e.kind);if(!t)return null;let n=Fu(e,`d`);if(Ru(e.kind)&&!n)return null;let r=t===`app`?zu(e.content):{},i=Lu.has(t)&&n||Iu[t];return{type:t,title:Fu(e,`title`)||Fu(e,`name`)||Bu(r,`name`)||Bu(r,`display_name`)||i,description:Fu(e,`summary`)||Fu(e,`description`)||Bu(r,`about`),image:Fu(e,`image`)||Fu(e,`thumb`)||Fu(e,`banner`)||Bu(r,`picture`),path:`/${Bi(e)}`,event:e}}function Hu(e){let t=new Map;for(let n of e){let e=t.get(n.type);e?e.push(n):t.set(n.type,[n])}let n=[...t.values()],r=Math.max(0,...n.map(e=>e.length)),i=[];for(let e=0;e{let r=n.trim();if(!r)return[];let i=`${r} autocomplete:true sort:top`,a=await t.query([{kinds:Mu,search:i,limit:12},{kinds:Nu,search:i,limit:8}],{signal:AbortSignal.any([e,AbortSignal.timeout(5e3)])}),o=new Map;for(let e of a){let t=Vu(e);if(!t)continue;let n=Fu(e,`d`)??``,r=`${e.kind}:${e.pubkey}:${n}`,i=o.get(r);(!i||e.created_at>i.event.created_at)&&o.set(r,t)}return Hu(Array.from(o.values()))},enabled:n.trim().length>=1,staleTime:30*1e3,placeholderData:e=>e})}function Q(e){return e.followed}function Wu(e){return!e.followed}function Gu(e,{excludePubkey:t,eventLimit:n=5}={}){let{data:r,isFetching:i,followedPubkeys:a}=Da(e),{data:o,isFetching:s}=Uu(e),c=(0,G.useMemo)(()=>{let e=[];for(let n of r??[])n.pubkey!==t&&e.push({type:`profile`,key:`profile:${n.pubkey}`,followed:a.has(n.pubkey),profile:n});return e},[r,t,a]),l=(0,G.useMemo)(()=>{let e=[];for(let t of o??[])e.push({type:`event`,key:`event:${t.path}`,followed:a.has(t.event.pubkey),event:t});return[...e.filter(Q),...e.filter(Wu)].slice(0,n)},[o,a,n]);return{results:(0,G.useMemo)(()=>[...c.filter(Q),...l.filter(Q),...c.filter(Wu),...l.filter(Wu)],[c,l]),profileCount:c.length,isFetching:i||s,followedPubkeys:a}}var Ku={article:{icon:m,label:sn({id:`search.eventType.article`,defaultMessage:`Article`})},list:{icon:le,label:sn({id:`search.eventType.list`,defaultMessage:`List`})},"follow-pack":{icon:te,label:sn({id:`search.eventType.followPack`,defaultMessage:`Follow pack`})},"emoji-pack":{icon:A,label:sn({id:`search.eventType.emojiPack`,defaultMessage:`Emoji pack`})},nsite:{icon:v,label:sn({id:`search.eventType.nsite`,defaultMessage:`Site`})},app:{icon:s,label:sn({id:`search.eventType.app`,defaultMessage:`App`})}};function qu({result:e,isSelected:t,isFollowed:n,onClick:r}){let i=ln(),{icon:a,label:o}=Ku[e.type],s=Dn(e.event.pubkey),c=s.data?.event;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>r(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsx)(Ju,{result:e,Icon:a}),n&&(0,K.jsx)(`span`,{className:`absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-primary flex items-center justify-center ring-2 ring-popover`,title:i.formatMessage({id:`search.following`,defaultMessage:`Following`}),children:(0,K.jsx)(T,{className:`size-2.5 text-primary-foreground`,strokeWidth:3})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:e.title}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:c?(0,K.jsx)(B,{id:`search.eventResult.byline`,defaultMessage:`{type} · by {author}`,values:{type:i.formatMessage(o),author:(0,K.jsx)(dr,{tags:c.tags,children:Ii(s.data?.metadata)})}}):(0,K.jsx)(B,{...o})})]})]})}function Ju({result:e,Icon:t}){return e.type===`nsite`?(0,K.jsx)(Yu,{result:e,Icon:t}):(0,K.jsx)(Xu,{image:an(e.image),fallback:(0,K.jsx)(t,{className:`size-4 text-primary`})})}function Yu({result:e,Icon:t}){let n=`https://${Kr(e.event)}.nsite.lol`,{data:r}=Ui(n);return(0,K.jsx)(Xu,{image:an(e.image)??an(r?.thumbnail_url),fallback:(0,K.jsx)(hr,{url:n,size:20,fallback:(0,K.jsx)(t,{className:`size-4 text-primary`})})})}function Xu({image:e,fallback:t}){return(0,K.jsxs)(`div`,{className:`size-10 rounded-lg overflow-hidden bg-primary/10 flex items-center justify-center`,children:[e?(0,K.jsx)(`img`,{src:e,alt:``,className:`size-10 object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}):null,(0,K.jsx)(`div`,{className:H(`items-center justify-center size-10`,e?`hidden`:`flex`),children:t})]})}function Zu({placeholder:e=`Search people...`,className:t,inputClassName:n,autoFocus:r,onSelect:i,enableTextSearch:a,hideCountry:o=!1}){let s=rr(),c=ht(),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(-1),h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(null),{data:v}=Cu(l),{data:y}=Eu(l),b=v?.[0]??null,x=y?.[0]??null,S=(0,G.useMemo)(()=>Wi(l),[l]),C=o?null:S,w=(0,G.useMemo)(()=>ra(l),[l]),T=(0,G.useMemo)(()=>Ll(l),[l]),E=(0,G.useMemo)(()=>Z(l),[l]),{data:D}=Oe(E?.type===`nip05`?E.identifier:void 0),{results:O,profileCount:k,isFetching:ee}=Gu(l,{excludePubkey:(0,G.useMemo)(()=>{if(E){if(E.type===`npub`||E.type===`nprofile`)return E.pubkey;if(E.type===`nip05`&&D)return D}},[E,D])}),A=O.length,j=!!C&&(C.exact||k===0);(0,G.useEffect)(()=>{l.trim().length>0&&(a||A>0||C||w.length>0||b||x)&&f(!0)},[A,l,a,C,w,b,x]),(0,G.useEffect)(()=>{m(-1)},[O]),(0,G.useEffect)(()=>{function e(e){h.current&&!h.current.contains(e.target)&&f(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let M=(0,G.useCallback)((e,t)=>{f(!1),u(``),i?i(e):s(t)},[s,i]),N=(0,G.useCallback)(()=>{l.trim()&&(f(!1),u(``),g.current?.blur(),a&&s(`/search?q=${encodeURIComponent(l.trim())}`))},[a,l,s]),te=!!C,ne=T&&a,re=!!E,P=!!b,F=!!x,I=w.length,L=I+A+ +!!te+ +!!ne+ +!!re+ +!!P+ +!!F,R=0,ie=R;R+=I;let ae=re?R++:-1,oe=ne?R++:-1,se=te&&j?R++:-1,ce=R;R+=A;let le=te&&!j?R++:-1,ue=j?se:le,fe=P?R++:-1,pe=F?R++:-1,me=(0,G.useCallback)(()=>{T&&(f(!1),u(``),g.current?.blur(),s(`/i/${encodeURIComponent(l.trim())}`))},[T,l,s]),he=(0,G.useCallback)(e=>{f(!1),u(``),s(`/i/iso3166:${e.code}`)},[s]),ge=(0,G.useCallback)(e=>{f(!1),u(``),g.current?.blur(),s(`/i/${encodeURIComponent(e.url)}`)},[s]),_e=(0,G.useCallback)(e=>{f(!1),u(``),g.current?.blur(),s(`/i/${encodeURIComponent(`https://archive.org/details/${e.identifier}`)}`)},[s]),ve=(0,G.useCallback)(e=>{f(!1),u(``),g.current?.blur(),s(e.path)},[s]),ye=(0,G.useCallback)(e=>{f(!1),u(``),g.current?.blur(),s(e)},[s]),be=(0,G.useCallback)(e=>{f(!1),u(``),g.current?.blur(),s(e.path)},[s]);return(0,G.useEffect)(()=>{p>=0&&_.current&&_.current.querySelectorAll(`[data-search-item]`)[p]?.scrollIntoView({block:`nearest`})},[p]),(0,K.jsxs)(`div`,{ref:h,className:H(`relative`,t),children:[(0,K.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,K.jsx)(de,{className:`absolute left-3 size-4 text-muted-foreground pointer-events-none`}),ee&&(0,K.jsxs)(`svg`,{className:`absolute right-3 size-4 text-muted-foreground`,style:{animation:`spin 1s linear infinite`},xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),(0,K.jsx)(yr,{ref:g,value:l,onChange:e=>{u(e.target.value),e.target.value.trim().length===0&&f(!1)},onFocus:()=>{l.trim().length>0&&(a||A>0)&&f(!0)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),f(!1),g.current?.blur();return}if(e.key===`Enter`){if(e.preventDefault(),d&&p>=0&&p0&&p>=ie&&p0&&p>=ce&&pee>0?e-1:L-1);break}},placeholder:e,autoFocus:r,className:H(`pl-10 pr-10 rounded-full bg-secondary border-0 focus-visible:ring-0 focus-visible:ring-offset-0`,n),autoComplete:`off`,role:`combobox`,"aria-expanded":d,"aria-haspopup":`listbox`,"aria-autocomplete":`list`})]}),!a&&d&&(I>0||re||te||P||F||A>0)&&(0,K.jsx)(`div`,{ref:_,role:`listbox`,className:`absolute top-full left-0 right-0 mt-1.5 z-50 rounded-xl border border-border bg-popover shadow-lg overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-150`,children:(0,K.jsxs)(`div`,{className:`max-h-[320px] overflow-y-auto py-1`,children:[w.map((e,t)=>(0,K.jsx)(Qu,{item:e,isSelected:t+ie===p,onClick:be},e.id)),re&&(0,K.jsx)($u,{match:E,isSelected:p===ae,onNavigate:ye}),te&&j&&(0,K.jsx)(ad,{country:C.country,isSelected:p===ue,onClick:he}),O.map((e,t)=>e.type===`profile`?(0,K.jsx)(sd,{profile:e.profile,isSelected:t+ce===p,isFollowed:e.followed,onClick:M},e.key):(0,K.jsx)(qu,{result:e.event,isSelected:t+ce===p,isFollowed:e.followed,onClick:ve},e.key)),te&&!j&&(0,K.jsx)(ad,{country:C.country,isSelected:p===ue,onClick:he}),P&&(0,K.jsx)(cd,{result:b,isSelected:p===fe,onClick:ge}),F&&(0,K.jsx)(ld,{result:x,isSelected:p===pe,onClick:_e})]})}),a&&d&&l.trim().length>0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1.5 z-50 rounded-xl border border-border bg-popover shadow-lg overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-150`,children:(0,K.jsxs)(`div`,{ref:_,className:`max-h-[320px] overflow-y-auto py-1`,children:[(0,K.jsxs)(`button`,{className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,L===0||p===-1?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:N,onMouseDown:e=>e.preventDefault(),children:[(()=>{let e=L===0||p===-1;return(0,K.jsx)(`div`,{className:H(`size-10 shrink-0 rounded-full flex items-center justify-center`,e?`bg-accent-foreground/10`:`bg-primary/10`),children:(0,K.jsx)(de,{className:H(`size-4`,e?`text-accent-foreground`:`text-primary`)})})})(),(0,K.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[`Search for "`,l.trim(),`"`]})]}),w.map((e,t)=>(0,K.jsx)(Qu,{item:e,isSelected:t+ie===p,onClick:be},e.id)),re&&(0,K.jsx)($u,{match:E,isSelected:p===ae,onNavigate:ye}),ne&&(0,K.jsx)(od,{url:l.trim(),isSelected:p===oe,onClick:me}),te&&j&&(0,K.jsx)(ad,{country:C.country,isSelected:p===ue,onClick:he}),O.map((e,t)=>e.type===`profile`?(0,K.jsx)(sd,{profile:e.profile,isSelected:t+ce===p,isFollowed:e.followed,onClick:M},e.key):(0,K.jsx)(qu,{result:e.event,isSelected:t+ce===p,isFollowed:e.followed,onClick:ve},e.key)),te&&!j&&(0,K.jsx)(ad,{country:C.country,isSelected:p===ue,onClick:he}),P&&(0,K.jsx)(cd,{result:b,isSelected:p===fe,onClick:ge}),F&&(0,K.jsx)(ld,{result:x,isSelected:p===pe,onClick:_e})]})}),!a&&d&&l.trim().length>0&&!ee&&!re&&!te&&!P&&!F&&A===0&&I===0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1.5 z-50 rounded-xl border border-border bg-popover shadow-lg overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-150`,children:(0,K.jsx)(`div`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`No results found`})})]})}function Qu({item:e,isSelected:t,onClick:n}){let r=ln().formatMessage({id:`nav.${e.id}`,defaultMessage:e.label}),i=e.icon;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:H(`size-10 shrink-0 rounded-full flex items-center justify-center`,t?`bg-accent-foreground/10`:`bg-primary/10`),children:(0,K.jsx)(i,{className:H(`size-4`,t?`text-accent-foreground`:`text-primary`)})}),(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:r})]})}function $u({match:e,isSelected:t,onNavigate:n}){switch(e.type){case`nip05`:return(0,K.jsx)(ed,{identifier:e.identifier,isSelected:t,onNavigate:n});case`npub`:case`nprofile`:return(0,K.jsx)(td,{pubkey:e.pubkey,raw:e.raw,isSelected:t,onNavigate:n});case`note`:return(0,K.jsx)(nd,{eventId:e.eventId,raw:e.raw,isSelected:t,onNavigate:n});case`nevent`:return(0,K.jsx)(nd,{eventId:e.eventId,relays:e.relays,authorHint:e.authorHint,raw:e.raw,isSelected:t,onNavigate:n});case`naddr`:return(0,K.jsx)(rd,{addr:e.addr,relays:e.relays,raw:e.raw,isSelected:t,onNavigate:n});case`hex`:return(0,K.jsx)(id,{hex:e.hex,isSelected:t,onNavigate:n})}}function ed({identifier:e,isSelected:t,onNavigate:n}){let{data:r,isLoading:i}=Oe(e),a=Dn(r??void 0),o=a.data?.metadata,s=o?.name||o?.display_name||(r?`Anonymous`:e),c=a.data?.event?.tags??[];return i?(0,K.jsxs)(`div`,{"data-search-item":!0,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors`,t?`bg-accent text-accent-foreground`:``),children:[(0,K.jsx)(`div`,{className:`size-10 shrink-0 rounded-full bg-secondary animate-pulse`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,K.jsx)(`div`,{className:`h-4 w-24 bg-secondary animate-pulse rounded`}),(0,K.jsx)(`div`,{className:`h-3 w-32 bg-secondary animate-pulse rounded`})]})]}):r?(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(`/${e}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(nr,{shape:$n(o),className:`size-10 shrink-0`,children:[(0,K.jsx)(er,{src:o?.picture,alt:s}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:s[0]?.toUpperCase()||`?`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:(0,K.jsx)(dr,{tags:c,children:s})}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:e})]})]}):null}function td({pubkey:e,raw:t,isSelected:n,onNavigate:r}){let i=Dn(e),a=i.data?.metadata,o=a?.name||a?.display_name||`Anonymous`,s=i.data?.event?.tags??[];return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":n,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,n?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>r(`/${t}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(nr,{shape:$n(a),className:`size-10 shrink-0`,children:[(0,K.jsx)(er,{src:a?.picture,alt:o}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:o[0]?.toUpperCase()||`?`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:i.isLoading?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading profile...`}):(0,K.jsx)(dr,{tags:s,children:o})}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[t.slice(0,8),`...`,t.slice(-4)]})]})]})}function nd({eventId:e,relays:t,authorHint:n,raw:r,isSelected:i,onNavigate:a}){let{data:o,isLoading:s}=Hi(e,t,n),c=Dn(o?.pubkey).data?.metadata,l=c?.name||c?.display_name||(o?`Anonymous`:void 0);return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":i,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,i?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>a(`/${r}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-10 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(_e,{className:`size-4 text-primary`})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:s?(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading event...`}):o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm truncate block`,children:o.content.slice(0,80)||`Kind ${o.kind} event`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:l?`by ${l}`:r.slice(0,8)+`...`+r.slice(-4)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:`Go to event`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[r.slice(0,8),`...`,r.slice(-4)]})]})})]})}function rd({addr:e,relays:t,raw:n,isSelected:r,onNavigate:i}){let{data:a,isLoading:o}=Vi(e,t),s=Dn(a?.pubkey??e.pubkey).data?.metadata,c=s?.name||s?.display_name||`Anonymous`,l=a?.tags.find(([e])=>e===`title`)?.[1];return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":r,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,r?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>i(`/${n}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-10 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(_e,{className:`size-4 text-primary`})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading...`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm truncate block`,children:l||a?.content.slice(0,80)||`Kind ${e.kind} event`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:[`by `,c]})]})})]})}function id({hex:e,isSelected:t,onNavigate:n}){return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(`/${e}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-10 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(b,{className:`size-4 text-primary`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:`Go to identifier`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[e.slice(0,8),`...`,e.slice(-4)]})]})]})}function ad({country:e,isSelected:t,onClick:n}){return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-10 shrink-0 rounded-full bg-secondary flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`text-lg leading-none`,role:`img`,"aria-label":`Flag of ${e.name}`,children:e.flag})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:e.name}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.code})]})]})}function od({url:e,isSelected:t,onClick:n}){let{data:r}=Ui(e),i=r?.thumbnail_url;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:n,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-10 shrink-0 rounded-lg overflow-hidden bg-primary/10 flex items-center justify-center`,children:[i?(0,K.jsx)(`img`,{src:i,alt:``,className:`size-10 object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}):null,(0,K.jsx)(`div`,{className:H(`items-center justify-center size-10`,i?`hidden`:`flex`),children:(0,K.jsx)(hr,{url:e,size:18,fallback:(0,K.jsx)(w,{className:`size-4 text-primary`})})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:r?.title??`Comment on this link`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:(()=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}})()})]})]})}function sd({profile:e,isSelected:t,isFollowed:n,onClick:r}){let{metadata:i,pubkey:a}=e,o=i.name||i.display_name||`Anonymous`,s=i.nip05,{data:c}=pr(s,a),l=mr(a,i),u=c&&s?s.startsWith(`_@`)?s.slice(2):s:void 0,d=u||tt.npubEncode(a);return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>r(e,l),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsxs)(nr,{shape:$n(i),className:`size-10`,children:[(0,K.jsx)(er,{src:i.picture,alt:o}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:o[0]?.toUpperCase()||`?`})]}),n&&(0,K.jsx)(`span`,{className:`absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-primary flex items-center justify-center ring-2 ring-popover`,title:`Following`,children:(0,K.jsx)(T,{className:`size-2.5 text-primary-foreground`,strokeWidth:3})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:(0,K.jsx)(dr,{tags:e.event.tags,children:o})}),i.bot&&(0,K.jsx)(`span`,{className:`text-xs text-primary`,title:`Bot account`,children:`🤖`})]}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:u?(0,K.jsx)(`span`,{className:`truncate`,children:d}):(0,K.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:d})})]})]})}function cd({result:e,isSelected:t,onClick:n}){return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-10 shrink-0 rounded-full bg-secondary flex items-center justify-center`,children:[e.thumbnail?(0,K.jsx)(`img`,{src:e.thumbnail,alt:``,className:`size-10 rounded-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}):null,(0,K.jsx)(`div`,{className:H(`items-center justify-center size-10`,e.thumbnail?`hidden`:`flex`),children:(0,K.jsx)(ai,{className:`size-4 text-muted-foreground`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:e.title}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:`Wikipedia`})]})]})}function ld({result:e,isSelected:t,onClick:n}){let r=`https://archive.org/services/img/${e.identifier}`;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors cursor-pointer`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-10 shrink-0 rounded-full bg-secondary flex items-center justify-center overflow-hidden`,children:[(0,K.jsx)(`img`,{src:r,alt:``,className:`size-10 rounded-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}),(0,K.jsx)(`div`,{className:`hidden items-center justify-center size-10`,children:(0,K.jsx)(l,{className:`size-4 text-muted-foreground`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:e.title}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:`Internet Archive`})]})]})}var ud=`vertical`,dd=`horizontal`,fd=`closestCenter`,pd={Transform:{toString(e){if(e)return`translate3d(${e.x}px, ${e.y}px, 0)`}}};function md(e,t,n){let r=e.slice(),[i]=r.splice(t,1);return r.splice(n,0,i),r}var hd=`pointer`,gd=`keyboard`;function _d(e,t){return(0,G.useMemo)(()=>({kind:e,options:t}),[e,t])}function vd(...e){return(0,G.useMemo)(()=>e,e)}var $=(0,G.createContext)(null);function yd({sensors:e,onDragEnd:t,children:n}){let[r,i]=(0,G.useState)(0),a=(0,G.useRef)(void 0);a.current||={nodes:new Map,items:[],axis:`y`,activationDistance:0,onDragEnd:void 0,activeId:null,overId:null,delta:0,rects:new Map,shift:0,notify:()=>i(e=>e+1)};let o=a.current;o.onDragEnd=t,o.activationDistance=e?.find(e=>e.kind===`pointer`)?.options?.activationConstraint?.distance??0;let s=(0,G.useMemo)(()=>({engine:o,version:r}),[o,r]);return(0,K.jsx)($.Provider,{value:s,children:n})}function bd({items:e,strategy:t,children:n}){let r=(0,G.useContext)($);return r&&(r.engine.items=e,r.engine.axis=t===`horizontal`?`x`:`y`),(0,K.jsx)(K.Fragment,{children:n})}function xd(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>{window.removeEventListener(`click`,e,{capture:!0})},0)}function Sd({id:e,disabled:t}){let n=(0,G.useContext)($),r=(0,G.useRef)(e);r.current=e;let i=(0,G.useCallback)(e=>{n&&(e?n.engine.nodes.set(r.current,e):n.engine.nodes.delete(r.current))},[n]),a=(0,G.useCallback)(e=>{if(!n||t||e.button!==0)return;let{engine:i}=n,a=i.axis,o=a===`y`?e.clientY:e.clientX,s=r.current,c=!1,l=e=>{e.cancelable&&e.preventDefault()},u=()=>{c=!0,i.rects.clear();for(let e of i.items){let t=i.nodes.get(e);if(!t)continue;let n=t.getBoundingClientRect(),r=a===`y`?n.top:n.left,o=a===`y`?n.height:n.width;i.rects.set(e,{start:r,size:o,center:r+o/2})}let e=i.rects.get(s),t=0,n=i.items.indexOf(s),r=i.rects.get(i.items[n+1]??i.items[n-1]??``);e&&r&&(t=Math.abs(r.start>e.start?r.start-(e.start+e.size):e.start-(r.start+r.size))),i.shift=(e?.size??0)+t,i.activeId=s,i.overId=s,i.delta=0,document.body.style.userSelect=`none`,i.notify()},d=e=>{let t=(a===`y`?e.clientY:e.clientX)-o;if(!c){if(Math.abs(t){window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`touchstart`,l),window.removeEventListener(`touchmove`,l),document.body.style.userSelect=``},p=()=>{let{overId:e}=i;i.activeId=null,i.overId=null,i.delta=0,i.notify(),e&&e!==s&&i.onDragEnd?.({active:{id:s},over:{id:e}})},m=()=>{f(),c&&(xd(),p())},h=()=>{f(),c&&(i.activeId=null,i.overId=null,i.delta=0,i.notify())};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,h),window.addEventListener(`touchstart`,l,{passive:!1}),window.addEventListener(`touchmove`,l,{passive:!1})},[n,t]),o=(0,G.useCallback)(e=>{if(!n||t)return;let{engine:i}=n,a=i.axis,o=a===`y`?`ArrowUp`:`ArrowLeft`,s=a===`y`?`ArrowDown`:`ArrowRight`;if(e.key!==o&&e.key!==s)return;let c=i.items.indexOf(r.current),l=e.key===o?c-1:c+1;c===-1||l<0||l>=i.items.length||(e.preventDefault(),e.stopPropagation(),i.onDragEnd?.({active:{id:r.current},over:{id:i.items[l]}}))},[n,t]),s=null,c,l=!1;if(n){let{engine:t}=n;if(t.activeId!==null){let n=t.axis;if(t.activeId===e)l=!0,s={x:n===`x`?t.delta:0,y:n===`y`?t.delta:0,scaleX:1,scaleY:1};else{c=`transform 200ms ease`;let r=t.items,i=r.indexOf(t.activeId),a=r.indexOf(t.overId??t.activeId),o=r.indexOf(e),l=0;i!==-1&&o!==-1&&(ii&&o<=a?l=-t.shift:i>a&&o>=a&&o{let i;if(n)i={ids:[n],limit:1};else if(r)i=Oa(r.kind)?{kinds:[r.kind],authors:[r.pubkey],"#d":[r.identifier],limit:1}:{kinds:[r.kind],authors:[r.pubkey],limit:1};else return null;let a=await t.query([i],{signal:e});if(a.length===0)return null;let o=a[0];return{label:wd(o),kind:o.kind}},enabled:!!(n||r),staleTime:600*1e3,gcTime:1800*1e3,retry:1})}function wd(e){let t=e.tags.find(([e])=>e===`title`)?.[1];if(t)return Td(t);let n=e.tags.find(([e])=>e===`name`)?.[1];if(n)return Td(n);let r=e.tags.find(([e])=>e===`subject`)?.[1];if(r)return Td(r);let i=e.tags.find(([e])=>e===`d`)?.[1];return i?Td(i):e.content?Td(e.content):`Event`}function Td(e,t=24){let n=e.replace(/\n/g,` `).trim();return n.length<=t?n:n.slice(0,t-1)+`…`}var Ed={3e4:R};function Dd({pubkey:e,className:t}){let{data:n}=Dn(e),r=n?.metadata;return(0,K.jsxs)(nr,{shape:$n(r),className:H(`size-6 shrink-0`,t),children:[(0,K.jsx)(er,{src:r?.picture,alt:r?.name}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-[10px]`,children:(r?.name?.[0]||`?`).toUpperCase()})]})}function Od({pubkey:e}){let{data:t,isLoading:n}=Dn(e),r=t?.metadata;return n&&!r?(0,K.jsx)(kr,{className:`h-4 w-20`}):(0,K.jsx)(`span`,{className:`truncate`,children:r?.name||r?.display_name||`Anonymous`})}function kd({kind:e,className:t}){return(0,K.jsx)(qi(e)??Ed[e]??_e,{className:H(`size-6`,t)})}function Ad({decoded:e}){let{data:t,isLoading:n}=Cd(e.type===`naddr`&&e.identifier!==void 0?{addr:{kind:e.kind,pubkey:e.pubkey,identifier:e.identifier}}:{eventId:e.eventId});return n&&!t?(0,K.jsx)(kr,{className:`h-4 w-20`}):(0,K.jsx)(`span`,{className:`truncate`,children:t?.label??`Event`})}function jd({id:e,active:t,editing:n,onRemove:r,onClick:i,linkClassName:a}){let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=Sd({id:e,disabled:!n}),f={transform:pd.Transform.toString(l),transition:u},p=sa(e),m=Md(p);if(!m)return null;let g=`/${p}`,_=m.type===`npub`||m.type===`nprofile`;return(0,K.jsxs)(`div`,{ref:c,style:f,className:H(`flex items-center rounded-full transition-colors relative bg-background/85`,d&&`z-10 opacity-80 shadow-lg`),children:[n&&(0,K.jsx)(`button`,{className:`flex items-center justify-center w-8 shrink-0 cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground transition-colors`,...o,...s,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(or,{to:g,onClick:i,className:H(`flex items-center gap-4 py-3 rounded-full transition-colors hover:bg-secondary/60 flex-1 min-w-0`,n?`px-2`:`px-3`,t?`font-bold text-primary`:`font-normal text-foreground`,a??`text-lg`),children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:_?(0,K.jsx)(Dd,{pubkey:m.pubkey}):(0,K.jsx)(kd,{kind:m.kind??1})}),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:_?(0,K.jsx)(Od,{pubkey:m.pubkey}):(0,K.jsx)(Ad,{decoded:m})})]}),n&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),r(e)},className:`flex items-center justify-center size-8 shrink-0 rounded-full transition-all text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove`,children:(0,K.jsx)(M,{className:`size-4`})})]})}function Md(e){try{let t=tt.decode(e);switch(t.type){case`npub`:return{type:`npub`,pubkey:t.data};case`nprofile`:{let e=t.data;return{type:`nprofile`,pubkey:e.pubkey,relays:e.relays}}case`note`:return{type:`note`,pubkey:``,eventId:t.data,kind:1};case`nevent`:{let e=t.data;return{type:`nevent`,pubkey:e.author??``,eventId:e.id,kind:e.kind,relays:e.relays}}case`naddr`:{let e=t.data;return{type:`naddr`,pubkey:e.pubkey,kind:e.kind,identifier:e.identifier,relays:e.relays}}default:return null}}catch{return null}}function Nd({subdomain:e,parsed:t}){let{data:n}=Ui(`https://${e}.nsite.lol`),{data:r,isLoading:i}=Cd(t.kind===5128?{eventId:t.id}:{addr:{kind:t.kind,pubkey:t.pubkey,identifier:t.identifier}});return i&&!r&&!n?(0,K.jsx)(kr,{className:`h-4 w-20`}):(0,K.jsx)(`span`,{className:`truncate`,children:n?.title||r?.label||`Nsite`})}function Pd({id:e,editing:t,onRemove:n,onClick:r,linkClassName:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=Sd({id:e,disabled:!t}),d={transform:pd.Transform.toString(c),transition:l},f=rr(),p=aa(e),m=(0,G.useMemo)(()=>Yr(p),[p]),{activeSubdomain:g}=wa(),_=g===p,v=(0,G.useMemo)(()=>m?m.kind===5128?`/${tt.neventEncode({id:m.id})}`:`/${tt.naddrEncode({kind:m.kind,pubkey:m.pubkey,identifier:m.identifier})}`:null,[m]),y=(0,G.useCallback)(e=>{r?.(e),!(e.defaultPrevented||!v)&&(e.preventDefault(),f(v,{state:{nsiteAutoPlay:!0,nsiteAutoPlayTs:Date.now()}}))},[v,f,r]);return!m||!v?null:(0,K.jsxs)(`div`,{ref:s,style:d,className:H(`flex items-center rounded-full transition-colors relative bg-background/85`,u&&`z-10 opacity-80 shadow-lg`),children:[t&&(0,K.jsx)(`button`,{className:`flex items-center justify-center w-8 shrink-0 cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground transition-colors`,...a,...o,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(`a`,{href:v,onClick:y,className:H(`flex items-center gap-4 py-3 rounded-full transition-colors hover:bg-secondary/60 flex-1 min-w-0`,t?`px-2`:`px-3`,_?`font-bold text-primary`:`font-normal text-foreground`,i??`text-lg`),children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(hr,{url:`https://${p}.nsite.lol`,size:20,fallback:(0,K.jsx)(re,{className:`size-5`}),className:`size-6 flex items-center justify-center`})}),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:(0,K.jsx)(Nd,{subdomain:p,parsed:m})})]}),t&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),n(e)},className:`flex items-center justify-center size-8 shrink-0 rounded-full transition-all text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove`,children:(0,K.jsx)(M,{className:`size-4`})})]})}function Fd({id:e}){let t=(0,G.useMemo)(()=>Di(e),[e]);if(t.type===`iso3166`){let e=Gi(t.code);if(e?.flag)return(0,K.jsx)(`span`,{className:`text-lg leading-none shrink-0`,children:e.flag})}return t.type===`url`?(0,K.jsx)(hr,{url:t.value,size:20,fallback:(0,K.jsx)(v,{className:`size-5 text-muted-foreground`}),className:`size-6 shrink-0 flex items-center justify-center`}):t.type===`isbn`?(0,K.jsx)(ye,{className:`size-5 shrink-0`}):(0,K.jsx)(v,{className:`size-6 shrink-0`})}function Id({id:e}){let t=(0,G.useMemo)(()=>Di(e),[e]),{data:n}=ki(t.type===`isbn`?t.value.replace(`isbn:`,``):null);return(0,K.jsx)(`span`,{className:`truncate`,children:t.type===`isbn`&&n?.title?n.title:Ai(t)})}function Ld({id:e,active:t,editing:n,onRemove:r,onClick:i,linkClassName:a}){let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=Sd({id:e,disabled:!n}),f={transform:pd.Transform.toString(l),transition:u},p=`/i/${encodeURIComponent(e)}`;return(0,K.jsxs)(`div`,{ref:c,style:f,className:H(`flex items-center rounded-full transition-colors relative bg-background/85`,d&&`z-10 opacity-80 shadow-lg`),children:[n&&(0,K.jsx)(`button`,{className:`flex items-center justify-center w-8 shrink-0 cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground transition-colors`,...o,...s,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(or,{to:p,onClick:i,className:H(`flex items-center gap-4 py-3 rounded-full transition-colors hover:bg-secondary/60 flex-1 min-w-0`,n?`px-2`:`px-3`,t?`font-bold text-primary`:`font-normal text-foreground`,a??`text-lg`),children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(Fd,{id:e})}),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:(0,K.jsx)(Id,{id:e})})]}),n&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),r(e)},className:`flex items-center justify-center size-8 shrink-0 rounded-full transition-all text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove`,children:(0,K.jsx)(M,{className:`size-4`})})]})}function Rd({id:e,active:t,editing:n,onRemove:r,onClick:i,profilePath:a,showIndicator:o,linkClassName:s,homePage:c}){let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=Sd({id:e,disabled:!n}),g={transform:pd.Transform.toString(f),transition:p},_=na(e),v=Zi(e),y=ta(e,a,c),b=ln();return(0,K.jsxs)(`div`,{ref:d,style:g,className:H(`flex items-center rounded-full transition-colors relative bg-background/85`,m&&`z-10 opacity-80 shadow-lg`),children:[n&&(0,K.jsx)(`button`,{className:`flex items-center justify-center w-8 shrink-0 cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground transition-colors`,...l,...u,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(or,{to:y,onClick:i,className:H(`flex items-center gap-4 py-3 rounded-full transition-colors hover:bg-secondary/60 flex-1 min-w-0`,n?`px-2`:`px-3`,t?`font-bold text-primary`:`font-normal text-foreground`,s??`text-lg`),children:[(0,K.jsxs)(`span`,{className:`shrink-0 relative`,children:[_,o&&(0,K.jsx)(`span`,{className:`absolute -top-1 right-0 size-2.5 bg-primary rounded-full`})]}),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:v})]}),n&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),r(e)},className:`flex items-center justify-center size-8 shrink-0 rounded-full transition-all text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:b.formatMessage({id:`sidebar.removeItem`,defaultMessage:`Remove {label}`},{label:v}),children:(0,K.jsx)(M,{className:`size-4`})})]})}function zd({sortableId:e,editing:t,onRemove:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=Sd({id:e,disabled:!t}),l={transform:pd.Transform.toString(o),transition:s},u=ln();return(0,K.jsxs)(`div`,{ref:a,style:l,className:H(`flex items-center rounded-full transition-colors relative`,t&&`bg-background/85`,c&&`z-10 opacity-80 shadow-lg`),children:[t&&(0,K.jsx)(`button`,{className:`flex items-center justify-center w-8 shrink-0 cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground transition-colors`,...r,...i,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsx)(`div`,{className:H(`flex-1 flex items-center py-3`,t?`px-2`:`px-3`),children:(0,K.jsx)(`div`,{className:`h-px w-full bg-border`})}),t&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`flex items-center justify-center size-8 shrink-0 rounded-full transition-all text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:u.formatMessage({id:`sidebar.removeDivider`,defaultMessage:`Remove divider`}),children:(0,K.jsx)(M,{className:`size-4`})})]})}function Bd({items:e,editing:t,onRemove:n,onReorder:r,isActive:i,getOnClick:a,getProfilePath:o,getShowIndicator:s,linkClassName:c,homePage:l}){let u=vd(_d(hd,{activationConstraint:{distance:5}}),_d(gd)),d=e.map((e,t)=>ea(e)?`divider-${t}`:e);return(0,K.jsx)(yd,{sensors:u,collisionDetection:fd,onDragEnd:(0,G.useCallback)(t=>{let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=d.indexOf(n.id),o=d.indexOf(i.id);a===-1||o===-1||r(md(e,a,o))},[d,e,r]),children:(0,K.jsx)(bd,{items:d,strategy:ud,children:e.map((e,r)=>{let u=d[r];return ea(e)?(0,K.jsx)(zd,{sortableId:u,editing:t,onRemove:()=>n(e,r)},u):ia(e)?(0,K.jsx)(jd,{id:e,active:i(e),editing:t,onRemove:e=>n(e,r),onClick:a?.(e),linkClassName:c},e):la(e)?(0,K.jsx)(Pd,{id:e,active:i(e),editing:t,onRemove:e=>n(e,r),onClick:a?.(e),linkClassName:c},e):ca(e)?(0,K.jsx)(Ld,{id:e,active:i(e),editing:t,onRemove:e=>n(e,r),onClick:a?.(e),linkClassName:c},e):(0,K.jsx)(Rd,{id:e,active:i(e),editing:t,onRemove:e=>n(e,r),onClick:a?.(e),profilePath:o?.(e),showIndicator:s?.(e),linkClassName:c,homePage:l},e)})})})}function Vd(e=!1){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useCallback)(()=>{let e=t.current;e&&(a(e.scrollTop>0),s(e.scrollTop+e.clientHeight{if(r.current?.disconnect(),r.current=null,t.current=n,!n)return;e&&(n.scrollTop=(n.scrollHeight-n.clientHeight)/2);let i=new ResizeObserver(c);i.observe(n),r.current=i,c()},[e,c]),u=(0,G.useCallback)(()=>{n.current&&=(clearInterval(n.current),null)},[]),d=(0,G.useCallback)(e=>{u(),n.current=setInterval(()=>{let n=t.current;if(!n)return u();n.scrollBy({top:e===`up`?-8:8}),c(),(e===`up`?n.scrollTop<=0:n.scrollTop+n.clientHeight>=n.scrollHeight-1)&&u()},16)},[c,u]);return(0,G.useEffect)(()=>u,[u]),{scrollRef:t,refCallback:l,canScrollUp:i,canScrollDown:o,onScroll:c,startScroll:d,stopScroll:u}}function Hd({direction:e,onMouseEnter:t,onMouseLeave:n}){return(0,K.jsx)(`button`,{className:`flex cursor-default items-center justify-center py-1 w-full shrink-0`,onMouseEnter:t,onMouseLeave:n,children:e===`up`?(0,K.jsx)(E,{className:`h-4 w-4`}):(0,K.jsx)(_,{className:`h-4 w-4`})})}var Ud=on({yours:{id:`sidebar.section.yours`,defaultMessage:`Yours`},app:{id:`sidebar.section.app`,defaultMessage:`App`},social:{id:`sidebar.section.social`,defaultMessage:`Social`},media:{id:`sidebar.section.media`,defaultMessage:`Media`},reading:{id:`sidebar.section.reading`,defaultMessage:`Reading`},fun:{id:`sidebar.section.fun`,defaultMessage:`Fun`},personalize:{id:`sidebar.section.personalize`,defaultMessage:`Personalize`},tools:{id:`sidebar.section.tools`,defaultMessage:`Tools`}});function Wd(e){let t=new Map;for(let n of e){let e=t.get(n.section);e?e.push(n):t.set(n.section,[n])}return Qi.flatMap(e=>{let n=t.get(e);return n?[[e,n]]:[]})}function Gd({section:e,first:t}){return(0,K.jsx)(`div`,{className:H(`px-2 pb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground/70`,t?`pt-1`:`pt-3`),children:(0,K.jsx)(B,{...Ud[e]})})}function Kd({item:e,onAdd:t,onClose:n}){let r=ln(),i=r.formatMessage({id:`nav.${e.id}`,defaultMessage:e.label});return(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsxs)(`button`,{onClick:()=>{t(e.id),n()},className:`flex items-center gap-3 flex-1 min-w-0 px-2 py-2 rounded-sm text-sm hover:bg-secondary/60 transition-colors cursor-pointer`,children:[na(e.id,`size-5 shrink-0`),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:i})]}),(0,K.jsx)(`button`,{onClick:()=>{t(e.id),n()},className:`size-8 flex items-center justify-center shrink-0 rounded-sm text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:r.formatMessage({id:`sidebar.addToSidebar`,defaultMessage:`Add {label} to sidebar`},{label:i}),children:(0,K.jsx)(S,{className:`size-4`,strokeWidth:4})})]})}function qd({editing:e,hiddenItems:t,onDoneEditing:n,onStartEditing:r,onAdd:i,onAddDivider:a,onNavigate:o,open:s,onOpenChange:c,homePage:l}){let u=ln(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``),[v,y]=(0,G.useState)(!1),[b,C]=(0,G.useState)(``),[w,T]=(0,G.useState)(``),D=(0,G.useCallback)(e=>u.formatMessage({id:`nav.${e.id}`,defaultMessage:e.label}),[u]),O=t.filter(e=>D(e).toLowerCase().includes(d.toLowerCase())),k=t.filter(e=>D(e).toLowerCase().includes(h.toLowerCase())),ee=()=>{let e=b.trim();if(!e)return;if(e.startsWith(`https://`)||e.startsWith(`http://`)){i(e),y(!1),C(``),T(``);return}if(e.startsWith(`iso3166:`)){let t=e.slice(8);if(!/^[A-Za-z]{2}(-[A-Za-z0-9]+)?$/.test(t)){T(u.formatMessage({id:`sidebar.invalidCountryCode`,defaultMessage:`Invalid country/region code`}));return}i(e),y(!1),C(``),T(``);return}if(e.startsWith(`isbn:`)){i(e),y(!1),C(``),T(``);return}if(e.startsWith(`nsite://`)){if(!Yr(e.slice(8))){T(u.formatMessage({id:`sidebar.invalidNsiteId`,defaultMessage:`Invalid nsite identifier`}));return}i(e),y(!1),C(``),T(``);return}let t=e.startsWith(`nostr:`)?e.slice(6):e;try{let e=tt.decode(t);if(![`npub`,`nprofile`,`note`,`nevent`,`naddr`].includes(e.type)){T(u.formatMessage({id:`sidebar.unsupportedIdentifier`,defaultMessage:`Unsupported identifier type`}));return}}catch{T(u.formatMessage({id:`sidebar.invalidIdentifier`,defaultMessage:`Invalid identifier`}));return}i(`nostr:${t}`),y(!1),C(``),T(``)},A=Vd(!0),j=Vd();return e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(wr,{open:p,onOpenChange:e=>{m(e),e||g(``)},children:[(0,K.jsx)(br,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-4 px-4 py-2.5 rounded-full transition-colors text-sm text-muted-foreground hover:text-foreground hover:bg-secondary/60 bg-background/85`,children:[(0,K.jsx)(S,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`common.add`,defaultMessage:`Add`})})]})}),(0,K.jsxs)(Sr,{side:`top`,align:`start`,collisionPadding:8,className:`w-[240px] p-1 flex flex-col max-h-[calc(var(--radix-dropdown-menu-content-available-height)-12px-var(--safe-area-inset-top,env(safe-area-inset-top,0px)))]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-2 py-2 shrink-0`,children:[(0,K.jsx)(de,{className:`size-5 shrink-0`}),(0,K.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:u.formatMessage({id:`common.searchPlaceholder`,defaultMessage:`Search...`}),className:`flex-1 min-w-0 bg-transparent text-base md:text-sm outline-none placeholder:text-muted-foreground/60`,autoFocus:!0})]}),(0,K.jsx)(`div`,{className:`h-px bg-border mb-1 shrink-0`}),j.canScrollUp&&(0,K.jsx)(Hd,{direction:`up`,onMouseEnter:()=>j.startScroll(`up`),onMouseLeave:j.stopScroll}),(0,K.jsxs)(`div`,{ref:j.refCallback,className:`overflow-y-auto flex-1 min-h-0`,onScroll:j.onScroll,children:[Wd(k).map(([e,t],n)=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Gd,{section:e,first:n===0}),t.map(e=>(0,K.jsx)(Kd,{item:e,onAdd:i,onClose:()=>m(!1)},e.id))]},e)),k.length===0&&(0,K.jsx)(`p`,{className:`px-2 py-3 text-sm text-muted-foreground text-center`,children:(0,K.jsx)(B,{id:`common.noResults`,defaultMessage:`No results`})})]}),j.canScrollDown&&(0,K.jsx)(Hd,{direction:`down`,onMouseEnter:()=>j.startScroll(`down`),onMouseLeave:j.stopScroll})]})]}),(0,K.jsxs)(`button`,{onClick:a,className:`flex items-center gap-4 px-4 py-2.5 rounded-full transition-colors text-sm text-muted-foreground hover:text-foreground hover:bg-secondary/60 bg-background/85`,children:[(0,K.jsx)(L,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.addDivider`,defaultMessage:`Add divider`})})]}),v?(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-2 bg-background/85 rounded-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(me,{className:`size-4 text-muted-foreground shrink-0`}),(0,K.jsx)(`input`,{value:b,onChange:e=>{C(e.target.value),T(``)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ee()):e.key===`Escape`&&(y(!1),C(``),T(``))},placeholder:u.formatMessage({id:`sidebar.linkInputPlaceholder`,defaultMessage:`URL, npub1..., nsite://..., ...`}),className:`flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60`,autoFocus:!0})]}),w&&(0,K.jsx)(`p`,{className:`text-xs text-destructive pl-6`,children:w}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 pl-6`,children:[(0,K.jsx)(`button`,{onClick:ee,className:`text-xs font-medium text-primary hover:underline`,children:(0,K.jsx)(B,{id:`common.add`,defaultMessage:`Add`})}),(0,K.jsx)(`button`,{onClick:()=>{y(!1),C(``),T(``)},className:`text-xs text-muted-foreground hover:underline`,children:(0,K.jsx)(B,{id:`common.cancel`,defaultMessage:`Cancel`})})]})]}):(0,K.jsxs)(`button`,{onClick:()=>y(!0),className:`flex items-center gap-4 px-4 py-2.5 rounded-full transition-colors text-sm text-muted-foreground hover:text-foreground hover:bg-secondary/60 bg-background/85`,children:[(0,K.jsx)(me,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.addLink`,defaultMessage:`Add link`})})]}),(0,K.jsxs)(`button`,{onClick:n,className:`flex items-center gap-4 px-4 py-2.5 rounded-full transition-colors text-sm text-primary font-medium hover:bg-primary/10 bg-background/85`,children:[(0,K.jsx)(he,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.doneEditing`,defaultMessage:`Done editing`})})]})]}):(0,K.jsxs)(wr,{open:s,onOpenChange:e=>{c(e),e||f(``)},children:[(0,K.jsx)(br,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-4 px-4 py-2.5 rounded-full transition-colors text-sm text-muted-foreground/60 hover:text-muted-foreground hover:bg-secondary/40 bg-background/85`,children:[s?(0,K.jsx)(E,{className:`size-4`}):(0,K.jsx)(_,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.more`,defaultMessage:`More...`})})]})}),(0,K.jsxs)(Sr,{side:`top`,align:`start`,collisionPadding:8,className:`w-[240px] p-1 flex flex-col max-h-[calc(var(--radix-dropdown-menu-content-available-height)-12px-var(--safe-area-inset-top,env(safe-area-inset-top,0px)))]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-2 py-2 shrink-0`,children:[(0,K.jsx)(de,{className:`size-5 shrink-0`}),(0,K.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:u.formatMessage({id:`common.searchPlaceholder`,defaultMessage:`Search...`}),className:`flex-1 min-w-0 bg-transparent text-base md:text-sm outline-none placeholder:text-muted-foreground/60`,autoFocus:!0})]}),(0,K.jsx)(`div`,{className:`h-px bg-border mb-1 shrink-0`}),A.canScrollUp&&(0,K.jsx)(Hd,{direction:`up`,onMouseEnter:()=>A.startScroll(`up`),onMouseLeave:A.stopScroll}),(0,K.jsxs)(`div`,{ref:A.refCallback,className:`overflow-y-auto flex-1 min-h-0`,onScroll:A.onScroll,children:[Wd(O).map(([e,t],n)=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Gd,{section:e,first:n===0}),t.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsxs)(or,{to:ta(e.id,void 0,l),onClick:()=>{c(!1),o?.()},className:`flex items-center gap-3 flex-1 min-w-0 px-2 py-2 rounded-sm text-sm hover:bg-secondary/60 transition-colors`,children:[na(e.id,`size-5 shrink-0`),(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:`var(--title-font-family, inherit)`},children:D(e)})]}),(0,K.jsx)(`button`,{onClick:()=>{i(e.id),c(!1)},className:`size-8 flex items-center justify-center shrink-0 rounded-sm text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:u.formatMessage({id:`sidebar.addToSidebar`,defaultMessage:`Add {label} to sidebar`},{label:D(e)}),children:(0,K.jsx)(S,{className:`size-4`,strokeWidth:4})})]},e.id))]},e)),O.length===0&&(0,K.jsx)(`p`,{className:`px-2 py-3 text-sm text-muted-foreground text-center`,children:(0,K.jsx)(B,{id:`common.noResults`,defaultMessage:`No results`})})]}),A.canScrollDown&&(0,K.jsx)(Hd,{direction:`down`,onMouseEnter:()=>A.startScroll(`down`),onMouseLeave:A.stopScroll}),(0,K.jsx)(`div`,{className:`h-px bg-border my-1 shrink-0`}),(0,K.jsxs)(`button`,{onClick:()=>{r(),c(!1)},className:`flex items-center gap-3 w-full px-2 py-2 rounded-sm text-sm hover:bg-secondary/60 transition-colors cursor-pointer shrink-0`,children:[(0,K.jsx)(x,{className:`size-5`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.editSidebar`,defaultMessage:`Edit sidebar`})})]})]})]})}var Jd=t(ua(),1);function Yd({open:e,onOpenChange:t}){let{user:n}=V(),r=Dn(n?.pubkey??``),i=ka(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(!1),l=r.data?.metadata,u=n?l?.name||l?.display_name||`Anonymous`:``,d=n?tt.npubEncode(n.pubkey):``,f=d?`${i}/${d}`:``;return(0,G.useEffect)(()=>{if(!f||!e)return;let{dark:t,light:n}=Et();Jd.toDataURL(f,{width:400,margin:2,color:{dark:t,light:n},errorCorrectionLevel:`M`}).then(o).catch(console.error)},[f,e]),n?(0,K.jsx)(Ci,{open:e,onOpenChange:t,children:(0,K.jsxs)(Si,{className:`max-w-sm p-6 flex flex-col items-center gap-5 rounded-2xl`,children:[(0,K.jsx)(bi,{className:`sr-only`,children:`Share follow link`}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,K.jsxs)(nr,{shape:$n(l),className:`size-16 ring-2 ring-secondary`,children:[(0,K.jsx)(er,{src:l?.picture,alt:u}),(0,K.jsx)(Qn,{className:`text-xl font-semibold`,children:u.charAt(0).toUpperCase()})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center`,children:[`Scan to follow `,(0,K.jsx)(`span`,{className:`text-foreground font-medium`,children:u})]})]}),a?(0,K.jsx)(`img`,{src:a,alt:`Follow QR code`,className:`w-full rounded-xl border border-border`,style:{imageRendering:`pixelated`},decoding:`async`}):(0,K.jsx)(`div`,{className:`w-full aspect-square rounded-xl border border-border bg-muted animate-pulse`}),(0,K.jsxs)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(f),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[s?(0,K.jsx)(he,{className:`size-3.5 text-primary flex-shrink-0`}):(0,K.jsx)(ne,{className:`size-3.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate max-w-64`,children:f})]})]})}):null}function Xd(){let{nostr:e}=Ge(),{logins:t,setLogin:n,removeLogin:r}=We(),{data:i=[],isLoading:a}=yt({queryKey:[`nostr`,`logins`,t.map(e=>e.id).join(`;`)],queryFn:async({signal:n})=>{let r=await e.query([{kinds:[0],authors:t.map(e=>e.pubkey)}],{signal:AbortSignal.any([n,AbortSignal.timeout(1500)])});return t.map(({id:e,pubkey:t})=>{let n=r.find(e=>e.pubkey===t);try{return{id:e,pubkey:t,metadata:qe.json().pipe(qe.metadata()).parse(n?.content),event:n}}catch{return{id:e,pubkey:t,metadata:{},event:n}}})},retry:3});return{authors:i,currentUser:(()=>{let e=t[0];if(e)return{metadata:{},...i.find(t=>t.id===e.id),id:e.id,pubkey:e.pubkey}})(),otherUsers:(i||[]).slice(1),isLoading:a,setLogin:n,removeLogin:r}}function Zd(){let{nostr:e}=Ge(),{user:t}=V(),{settings:n}=en(),r=n==null?null:n.notificationsCursor??0,{data:i}=Hn(),a=n?.notificationPreferences,o=(0,G.useMemo)(()=>ho(a),[a]),s=[...o].sort().join(`,`),c=(0,G.useMemo)(()=>i?.pubkeys??[],[i?.pubkeys]),l=a?.onlyFollowing===!0&&c.length>0?c:void 0,u=l?l.slice().sort().join(`,`):`all`,{data:d=!1}=yt({queryKey:[`notifications-unread`,t?.pubkey??``,s,u],queryFn:async({signal:n})=>{if(!t||r===null)return!1;let i={kinds:o,"#p":[t.pubkey],since:r+1,limit:1,...l?{authors:l}:{}};return(await e.query([i],{signal:AbortSignal.any([n,AbortSignal.timeout(5e3)])})).some(e=>e.pubkey!==t.pubkey)},enabled:!!t&&r!==null,placeholderData:e=>e});return d}function Qd(){let e=ht(),{nostr:t}=Ge(),{mutateAsync:n}=zn(),{user:r}=V();return Ct({mutationFn:async({status:e,url:i})=>{if(!r?.pubkey)return;let a=await Cn(t,{kinds:[30315],authors:[r.pubkey],"#d":[`general`]}),o=[[`d`,`general`]];i&&o.push([`r`,i]),await n({kind:30315,content:e,tags:o,prev:a??void 0})},onMutate:({status:t,url:n})=>{if(!r?.pubkey)return;let i=[`user-status`,r.pubkey],a=e.getQueryData(i),o=t.trim();return e.setQueryData(i,{status:o||null,url:o?an(n)??null:null,tags:a?.tags??[]}),{snapshot:a,key:i}},onError:(t,n,r)=>{r&&Ri(e,r.key,r.snapshot)},onSuccess:()=>{r&&e.invalidateQueries({queryKey:[`user-status`,r.pubkey]})}})}function $d(){let e=ln(),t=lr(),n=rr(),{user:r,metadata:i,event:a,isLoading:o}=V(),s=$n(i),{currentUser:l,otherUsers:u,setLogin:f}=Xd(),{logout:p}=Rr(),{orderedItems:m,hiddenItems:h,updateSidebarOrder:g,addToSidebar:_,addDividerToSidebar:v,removeFromSidebar:y}=Aa(),{config:b}=Nt(),x=m,S=h,C=Zd(),w=mr(r?.pubkey??``,i),[T,E]=(0,G.useState)(!1),{startSignup:D}=Br(),[O,k]=(0,G.useState)(!1),[ee,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1),[te,ne]=(0,G.useState)(!1),re=gr(r?.pubkey),P=Qd(),{toast:I}=Mn(),[L,R]=(0,G.useState)(!1),[ie,ae]=(0,G.useState)(``),oe=b.homePage,se=(0,G.useCallback)(e=>n=>{t.pathname===e&&(n.preventDefault(),window.scrollTo({top:0,behavior:`smooth`}))},[t.pathname]),ce=t=>t.metadata.name||t.metadata.display_name||e.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`});return(0,K.jsxs)(`aside`,{className:`hidden sidebar:flex flex-col h-screen sticky top-0 py-3 px-4 w-[300px] lg:w-1/4 lg:max-w-[300px] shrink-0`,children:[(0,K.jsx)(`div`,{className:`flex items-center px-3 mb-1`,children:(0,K.jsx)(or,{to:`/`,onClick:se(`/`),children:(0,K.jsx)(`div`,{className:`bg-background/85 rounded-full`,children:(0,K.jsx)(Fn,{size:48})})})}),(0,K.jsx)(`div`,{className:`px-2 py-4`,children:(0,K.jsx)(Zu,{placeholder:e.formatMessage({id:`common.searchPlaceholder`,defaultMessage:`Search...`}),inputClassName:`py-3.5`,enableTextSearch:!0})}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-0.5 flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,children:[(0,K.jsx)(Bd,{items:x,editing:j,onRemove:y,onReorder:g,isActive:e=>$i(e,t.pathname,t.search,w,oe),getOnClick:e=>e===oe?se(`/`):void 0,getProfilePath:e=>e===`profile`?w:void 0,getShowIndicator:e=>e===`notifications`?C:void 0,homePage:oe}),(0,K.jsx)(qd,{editing:j,hiddenItems:S,onDoneEditing:()=>M(!1),onStartEditing:()=>M(!0),onAdd:_,onAddDivider:v,open:te,onOpenChange:ne,homePage:oe})]}),!r&&t.pathname!==`/`&&(0,K.jsx)(`div`,{className:`pt-2 pb-1`,children:(0,K.jsx)(`button`,{onClick:()=>E(!0),className:`flex items-center justify-center w-full h-10 rounded-full bg-primary text-primary-foreground font-semibold text-sm hover:bg-primary/90 transition-colors cursor-pointer`,children:(0,K.jsx)(B,{id:`sidebar.join`,defaultMessage:`Join`})})}),r&&l&&(0,K.jsx)(`div`,{className:`pt-2`,children:(0,K.jsxs)(Or,{open:O,onOpenChange:k,children:[(0,K.jsx)(Er,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-3 p-3 rounded-full hover:bg-secondary/60 transition-colors cursor-pointer w-full text-left bg-background/85`,children:[o?(0,K.jsx)(kr,{className:`size-10 shrink-0 rounded-full`}):(0,K.jsxs)(nr,{shape:s,className:`size-10 shrink-0`,children:[(0,K.jsx)(er,{src:i?.picture,alt:i?.name}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:(i?.name||i?.display_name||e.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`}))[0]?.toUpperCase()??`?`})]}),(0,K.jsx)(`div`,{className:`flex flex-col min-w-0 flex-1 gap-1`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kr,{className:`h-3.5 w-24`}),(0,K.jsx)(kr,{className:`h-3 w-16`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:a&&(i?.name||i?.display_name)?(0,K.jsx)(dr,{tags:a.tags,children:i.name||i.display_name||``}):i?.name||i?.display_name||(0,K.jsx)(B,{id:`common.anonymous`,defaultMessage:`Anonymous`})}),i?.nip05&&(0,K.jsx)(Ta,{nip05:i.nip05,pubkey:r.pubkey,className:`text-xs text-muted-foreground truncate`})]})})]})}),(0,K.jsxs)(Dr,{side:`top`,align:`start`,sideOffset:8,className:`w-[260px] p-0 rounded-2xl shadow-xl border border-border overflow-hidden`,children:[(0,K.jsx)(or,{to:w,onClick:()=>k(!1),className:`block p-4 border-b border-border hover:bg-secondary/60 transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(nr,{shape:s,className:`size-11 shrink-0`,children:[(0,K.jsx)(er,{src:l.metadata.picture,alt:ce(l)}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:ce(l).charAt(0).toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-bold text-sm truncate`,children:l.event?(0,K.jsx)(dr,{tags:l.event.tags,children:ce(l)}):ce(l)}),l.metadata.nip05&&(0,K.jsx)(Ta,{nip05:l.metadata.nip05,pubkey:l.pubkey,className:`text-xs text-muted-foreground truncate`})]})]})}),(0,K.jsx)(`div`,{className:`border-b border-border`,children:L?(0,K.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,K.jsx)(yr,{value:ie,onChange:e=>ae(e.target.value.slice(0,80)),placeholder:e.formatMessage({id:`sidebar.statusPlaceholder`,defaultMessage:`What are you up to?`}),className:`h-8 text-base md:text-sm`,maxLength:80,autoFocus:!0,onKeyDown:t=>{if(t.key===`Enter`){t.preventDefault();let n=ie.trim();P.mutateAsync({status:n}).then(()=>{R(!1),ae(``),I({title:n?e.formatMessage({id:`sidebar.statusUpdated`,defaultMessage:`Status updated`}):e.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})}else t.key===`Escape`&&(R(!1),ae(``))}}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{onClick:()=>{let t=ie.trim();P.mutateAsync({status:t}).then(()=>{R(!1),ae(``),I({title:t?e.formatMessage({id:`sidebar.statusUpdated`,defaultMessage:`Status updated`}):e.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})},disabled:P.isPending,className:`text-xs font-medium text-primary hover:underline disabled:opacity-50`,children:P.isPending?(0,K.jsx)(F,{className:`size-3 animate-spin`}):(0,K.jsx)(B,{id:`common.save`,defaultMessage:`Save`})}),re.status&&(0,K.jsx)(`button`,{onClick:()=>{P.mutateAsync({status:``}).then(()=>{R(!1),ae(``),I({title:e.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})},disabled:P.isPending,className:`text-xs font-medium text-destructive hover:underline disabled:opacity-50`,children:(0,K.jsx)(B,{id:`common.clear`,defaultMessage:`Clear`})}),(0,K.jsx)(`button`,{onClick:()=>{R(!1),ae(``)},className:`text-xs text-muted-foreground hover:underline ml-auto`,children:(0,K.jsx)(B,{id:`common.cancel`,defaultMessage:`Cancel`})})]})]}):(0,K.jsx)(`button`,{onClick:()=>{R(!0),ae(re.status??``)},className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm hover:bg-secondary/60 transition-colors`,children:re.status?(0,K.jsx)(`span`,{className:`truncate text-muted-foreground italic text-xs pr-1`,children:(0,K.jsx)(dr,{tags:re.tags,children:re.status})}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:(0,K.jsx)(B,{id:`sidebar.setStatus`,defaultMessage:`Set a status`})})})}),u.length>0&&(0,K.jsx)(`div`,{className:`border-b border-border`,children:u.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{f(e.id),k(!1)},className:`flex items-center gap-3 w-full px-4 py-3 hover:bg-secondary/60 transition-colors`,children:[(0,K.jsxs)(nr,{shape:$n(e.metadata),className:`size-9 shrink-0`,children:[(0,K.jsx)(er,{src:e.metadata.picture,alt:ce(e)}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-xs`,children:ce(e).charAt(0).toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.event?(0,K.jsx)(dr,{tags:e.event.tags,children:ce(e)}):ce(e)}),e.metadata.nip05&&(0,K.jsx)(Ta,{nip05:e.metadata.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]})]},e.id))}),(0,K.jsxs)(`div`,{className:`py-1`,children:[(0,K.jsxs)(`button`,{onClick:()=>{k(!1),A(!0)},className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm font-medium hover:bg-secondary/60 transition-colors`,children:[(0,K.jsx)(d,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.shareProfile`,defaultMessage:`Share profile`})})]}),(0,K.jsxs)(`button`,{onClick:()=>{k(!1),E(!0)},className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm font-medium hover:bg-secondary/60 transition-colors`,children:[(0,K.jsx)(c,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.addAccount`,defaultMessage:`Add another account`})})]}),(0,K.jsxs)(`button`,{onClick:async()=>{k(!1),await p(),n(`/`)},className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,K.jsx)(N,{className:`size-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.logOutAs`,defaultMessage:`Log out @{name}`,values:{name:i?.name||i?.display_name||e.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`})}})})]})]})]})]})}),(0,K.jsx)(Vr,{isOpen:T,onClose:()=>E(!1),onLogin:()=>E(!1),onSignupClick:D}),(0,K.jsx)(Yd,{open:ee,onOpenChange:A})]})}var ef=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(`svg`,{ref:n,xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 640 640`,fill:`currentColor`,className:e,...t,children:(0,K.jsx)(`path`,{d:`M64 160C64 142.3 78.3 128 96 128L480 128C497.7 128 512 142.3 512 160C512 177.7 497.7 192 480 192L96 192C78.3 192 64 177.7 64 160zM128 320C128 302.3 142.3 288 160 288L544 288C561.7 288 576 302.3 576 320C576 337.7 561.7 352 544 352L160 352C142.3 352 128 337.7 128 320zM512 480C512 497.7 497.7 512 480 512L96 512C78.3 512 64 497.7 64 480C64 462.3 78.3 448 96 448L480 448C497.7 448 512 462.3 512 480z`})}));ef.displayName=`BarsStaggeredIcon`;function tf({onAvatarClick:e,hasSubHeader:t}){let n=lr(),r=ha(),i=(0,G.useCallback)(e=>{n.pathname===`/`&&(e.preventDefault(),window.scrollTo({top:0,behavior:`smooth`}))},[n.pathname]);return(0,K.jsxs)(`header`,{className:`sticky top-0 z-20 sidebar:hidden safe-area-top transition-transform duration-300 ease-in-out`,style:r?{transform:`translateY(calc(-100% - 20px - var(--safe-area-inset-top, env(safe-area-inset-top, 0px))))`}:void 0,children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 right-0 bg-background/85`,style:{height:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`}}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(ja,{variant:t?`rect`:`down`}),(0,K.jsxs)(`div`,{className:`relative flex items-center px-3 h-10`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center w-7 shrink-0`,children:(0,K.jsx)(`button`,{onClick:e,className:`rounded-full focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1 focus:ring-offset-background text-muted-foreground hover:text-foreground transition-colors`,children:(0,K.jsx)(ef,{className:`size-5`})})}),(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsx)(or,{to:`/`,onClick:i,children:(0,K.jsx)(Fn,{size:28})})}),(0,K.jsx)(`div`,{className:`w-7 shrink-0`})]})]})]})}var nf=_i,rf=hi,af=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(fi,{className:H(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));af.displayName=fi.displayName;var of=Ln(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full w-3/4 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`}},defaultVariants:{side:`right`}}),sf=G.forwardRef(({side:e=`right`,className:t,children:n,...r},i)=>(0,K.jsxs)(rf,{children:[(0,K.jsx)(af,{}),(0,K.jsxs)(mi,{ref:i,className:H(of({side:e}),t),...r,children:[n,(0,K.jsxs)(vi,{className:H(`absolute opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none`,e===`left`?`left-full ml-3 top-4`:`right-4 top-4 rounded-sm ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 data-[state=open]:bg-secondary`),style:{top:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 0.85rem)`},children:[(0,K.jsx)(M,{className:e===`left`?`h-5 w-5 text-white`:`h-4 w-4`,strokeWidth:e===`left`?2.5:2}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));sf.displayName=mi.displayName;var cf=({className:e,...t})=>(0,K.jsx)(`div`,{className:H(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});cf.displayName=`SheetHeader`;var lf=({className:e,...t})=>(0,K.jsx)(`div`,{className:H(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});lf.displayName=`SheetFooter`;var uf=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(pi,{ref:n,className:H(`text-lg font-semibold text-foreground`,e),...t}));uf.displayName=pi.displayName;var df=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(gi,{ref:n,className:H(`text-sm text-muted-foreground`,e),...t}));df.displayName=gi.displayName;function ff({onAddAccountClick:e}){let{currentUser:t,otherUsers:n,isLoading:r,setLogin:i,removeLogin:a}=Xd(),[o,s]=(0,G.useState)(!1),l=ln();if(!t)return null;let u=()=>{s(!1),setTimeout(()=>{a(t.id)},0)},d=e=>e.metadata.name||e.metadata.display_name||l.formatMessage({id:`accountSwitcher.anonymous`,defaultMessage:`Anonymous`});return(0,K.jsxs)(wr,{modal:!1,open:o,onOpenChange:s,children:[(0,K.jsx)(br,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-3 p-3 rounded-full hover:bg-accent transition-all w-full text-foreground`,children:[r?(0,K.jsx)(kr,{className:`w-10 h-10 rounded-full shrink-0`}):(0,K.jsxs)(nr,{shape:$n(t.metadata),className:`w-10 h-10`,children:[(0,K.jsx)(er,{src:t.metadata.picture,alt:d(t)}),(0,K.jsx)(Qn,{children:d(t).charAt(0)})]}),(0,K.jsx)(`div`,{className:`flex-1 text-left hidden md:block truncate`,children:r?(0,K.jsx)(kr,{className:`h-4 w-24`}):(0,K.jsx)(`p`,{className:`font-medium text-sm truncate`,children:d(t)})}),(0,K.jsx)(_,{className:`w-4 h-4 text-muted-foreground`})]})}),(0,K.jsxs)(Sr,{className:`w-56 p-2 animate-scale-in`,children:[(0,K.jsx)(`div`,{className:`font-medium text-sm px-2 py-1.5`,children:(0,K.jsx)(B,{id:`accountSwitcher.switchAccount`,defaultMessage:`Switch Account`})}),n.map(e=>(0,K.jsxs)(Cr,{onClick:()=>i(e.id),className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:[(0,K.jsxs)(nr,{shape:$n(e.metadata),className:`w-8 h-8`,children:[(0,K.jsx)(er,{src:e.metadata.picture,alt:d(e)}),(0,K.jsx)(Qn,{children:d(e)?.charAt(0)||(0,K.jsx)(Se,{})})]}),(0,K.jsx)(`div`,{className:`flex-1 truncate`,children:(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:d(e)})}),e.id===t.id&&(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-primary`})]},e.id)),(0,K.jsx)(xr,{}),(0,K.jsxs)(Cr,{onClick:e,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:[(0,K.jsx)(c,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`accountSwitcher.addAccount`,defaultMessage:`Add another account`})})]}),(0,K.jsxs)(Cr,{onClick:u,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md text-red-500`,children:[(0,K.jsx)(N,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`accountSwitcher.logOut`,defaultMessage:`Log out`})})]})]})]})}function pf({className:e}){let{currentUser:t}=Xd(),[n,r]=(0,G.useState)(!1),{startSignup:i}=Br();return(0,K.jsxs)(`div`,{className:H(`inline-flex items-center justify-center`,e),children:[t?(0,K.jsx)(ff,{onAddAccountClick:()=>r(!0)}):(0,K.jsxs)(`div`,{className:`flex gap-3 justify-center`,children:[(0,K.jsx)(Rn,{onClick:()=>r(!0),className:`flex items-center gap-2 px-4 py-2 rounded-full bg-primary text-primary-foreground w-full font-medium transition-all hover:bg-primary/90 animate-scale-in`,children:(0,K.jsx)(`span`,{className:`truncate`,children:(0,K.jsx)(B,{id:`loginArea.logIn`,defaultMessage:`Log in`})})}),(0,K.jsx)(Rn,{onClick:i,variant:`outline`,className:`flex items-center gap-2 px-4 py-2 rounded-full font-medium transition-all`,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`loginArea.signUp`,defaultMessage:`Sign up`})})})]}),(0,K.jsx)(Vr,{isOpen:n,onClose:()=>r(!1),onLogin:()=>{r(!1)},onSignupClick:i})]})}var mf=`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,hf=`size-3 shrink-0`;function gf({onNavigate:e}){return(0,K.jsx)(`footer`,{className:`mt-auto pt-3 pb-3 -mx-1 sidebar:bg-background/85 sidebar:rounded-xl sidebar:p-3`,children:(0,K.jsxs)(`nav`,{className:`flex items-center justify-center gap-0.5 flex-wrap`,"aria-label":`Footer links`,children:[(0,K.jsxs)(`a`,{href:`https://about.ditto.pub`,className:mf,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(we,{className:hf}),`About`]}),(0,K.jsxs)(`a`,{href:`https://about.ditto.pub/docs/`,className:mf,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(ye,{className:hf}),`Docs`]}),(0,K.jsxs)(or,{to:`/privacy`,className:mf,onClick:e,children:[(0,K.jsx)(ve,{className:hf}),`Privacy`]}),(0,K.jsxs)(`a`,{href:`https://gitlab.com/soapbox-pub/ditto`,className:mf,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(a,{className:hf}),`Source`]}),(0,K.jsxs)(or,{to:`/changelog`,className:mf,onClick:e,children:[(0,K.jsx)(ae,{className:hf}),`Changelog`]}),(0,K.jsxs)(`a`,{href:`https://shakespeare.diy/clone?url=https%3A%2F%2Fgitlab.com%2Fsoapbox-pub%2Fditto.git`,className:mf,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(`span`,{className:`text-xs leading-none`,"aria-hidden":!0,children:`🎭`}),`Edit with Shakespeare`]})]})})}var _f=336;function vf(e){return{width:_f,clipPath:`url(#${e})`}}function yf({open:e,onOpenChange:t}){let n=ln(),r=`${(0,G.useId)()}-drawer-arc-clip`,i=vf(r),a=lr(),o=rr(),{user:s,metadata:l,event:u}=V(),f=$n(l),p=mr(s?.pubkey??``,l),{logout:m}=Rr(),{otherUsers:h,setLogin:g}=Xd(),{orderedItems:v,hiddenItems:y,addToSidebar:b,addDividerToSidebar:x,removeFromSidebar:S,updateSidebarOrder:C}=Aa(),{config:w}=Nt(),T=w.homePage,D=Zd(),[O,k]=(0,G.useState)(!1),[ee,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1),[te,ne]=(0,G.useState)(!1),[re,P]=(0,G.useState)(!1),{startSignup:I}=Br(),{theme:L,customTheme:R,themes:ie}=Jt(),ae=gr(s?.pubkey),oe=Qd(),{toast:se}=Mn(),[ce,le]=(0,G.useState)(!1),[ue,de]=(0,G.useState)(``),[fe,pe]=(0,G.useState)(void 0),me=(0,G.useCallback)(e=>{pe(e??void 0)},[]),he=(0,G.useMemo)(()=>{let e=Ut(L),t=e===`custom`?R:Bt(e,ie),n=t?.background?.url;return n?(t?.background?.mode??`cover`)===`tile`?{backgroundColor:`transparent`,backgroundImage:`url("${n}")`,backgroundRepeat:`repeat`,backgroundSize:`auto`}:{backgroundColor:`transparent`,backgroundImage:`url("${n}")`,backgroundSize:`cover`,backgroundRepeat:`no-repeat`,backgroundPosition:`center`}:{}},[L,R,ie]),ge=Object.keys(he).length>0,_e=(0,G.useMemo)(()=>v.filter((e,t)=>e===`divider`?v.slice(0,t).some(e=>e!==`divider`):!0),[v]),ve=y,ye=()=>{t(!1),A(!1)},be=async()=>{await m(),ye(),o(`/`)},xe=e=>e.metadata.name||e.metadata.display_name||n.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`}),Se=l?.name||l?.display_name||n.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nf,{open:e,onOpenChange:e=>{e||A(!1),t(e)},children:(0,K.jsx)(sf,{ref:me,side:`left`,className:`w-[300px] p-0 gap-0 border-r-border flex flex-col overflow-visible`,children:(0,K.jsxs)(Tr,{value:fe,children:[(0,K.jsx)(`svg`,{className:`absolute`,width:`0`,height:`0`,"aria-hidden":`true`,children:(0,K.jsx)(`defs`,{children:(0,K.jsx)(`clipPath`,{id:r,clipPathUnits:`objectBoundingBox`,children:(0,K.jsx)(`path`,{d:`M0,0 L0.893,0 Q1,0.5 0.893,1 L0,1 Z`})})})}),(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 pointer-events-none bg-background`,style:{...he,...i}}),ge&&(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 bg-background/70 pointer-events-none`,style:i}),(0,K.jsx)(uf,{className:`sr-only`,children:`Navigation menu`}),s?(0,K.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,K.jsxs)(`button`,{onClick:()=>M(e=>!e),className:`flex items-center gap-3 px-3 hover:bg-secondary/60 transition-colors w-full text-left`,style:{minHeight:`calc(3rem + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`},children:[(0,K.jsxs)(nr,{shape:f,className:`size-7 shrink-0`,children:[(0,K.jsx)(er,{src:l?.picture,alt:Se}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-xs`,children:Se[0].toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:u&&(l?.name||l?.display_name)?(0,K.jsx)(dr,{tags:u.tags,children:l.name||l.display_name||``}):Se}),l?.nip05&&(0,K.jsx)(Ta,{nip05:l.nip05,pubkey:s.pubkey,className:`text-xs text-muted-foreground truncate`})]}),j?(0,K.jsx)(E,{className:`size-4 text-muted-foreground shrink-0 mr-1`}):(0,K.jsx)(_,{className:`size-4 text-muted-foreground shrink-0 mr-1`})]}),j&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`border-b border-border`,children:ce?(0,K.jsxs)(`div`,{className:`px-3 py-2 space-y-2`,children:[(0,K.jsx)(yr,{value:ue,onChange:e=>de(e.target.value.slice(0,80)),placeholder:n.formatMessage({id:`sidebar.statusPlaceholder`,defaultMessage:`What are you up to?`}),className:`h-8 text-base md:text-sm`,maxLength:80,autoFocus:!0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=ue.trim();oe.mutateAsync({status:t}).then(()=>{le(!1),de(``),se({title:t?n.formatMessage({id:`sidebar.statusUpdated`,defaultMessage:`Status updated`}):n.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})}else e.key===`Escape`&&(le(!1),de(``))}}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{onClick:()=>{let e=ue.trim();oe.mutateAsync({status:e}).then(()=>{le(!1),de(``),se({title:e?n.formatMessage({id:`sidebar.statusUpdated`,defaultMessage:`Status updated`}):n.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})},disabled:oe.isPending,className:`text-xs font-medium text-primary hover:underline disabled:opacity-50`,children:oe.isPending?(0,K.jsx)(F,{className:`size-3 animate-spin`}):(0,K.jsx)(B,{id:`common.save`,defaultMessage:`Save`})}),ae.status&&(0,K.jsx)(`button`,{onClick:()=>{oe.mutateAsync({status:``}).then(()=>{le(!1),de(``),se({title:n.formatMessage({id:`sidebar.statusCleared`,defaultMessage:`Status cleared`})})})},disabled:oe.isPending,className:`text-xs font-medium text-destructive hover:underline disabled:opacity-50`,children:(0,K.jsx)(B,{id:`common.clear`,defaultMessage:`Clear`})}),(0,K.jsx)(`button`,{onClick:()=>{le(!1),de(``)},className:`text-xs text-muted-foreground hover:underline ml-auto`,children:(0,K.jsx)(B,{id:`common.cancel`,defaultMessage:`Cancel`})})]})]}):(0,K.jsx)(`button`,{onClick:()=>{le(!0),de(ae.status??``)},className:`flex items-center gap-3 w-full px-3 py-2.5 text-sm hover:bg-secondary/60 transition-colors`,children:ae.status?(0,K.jsx)(`span`,{className:`truncate text-muted-foreground italic text-xs pr-1`,children:(0,K.jsx)(dr,{tags:ae.tags,children:ae.status})}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:(0,K.jsx)(B,{id:`sidebar.setStatus`,defaultMessage:`Set a status`})})})}),h.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{g(e.id),ye()},className:`flex items-center gap-3 w-full px-3 py-2 hover:bg-secondary/60 transition-colors`,children:[(0,K.jsxs)(nr,{shape:$n(e.metadata),className:`size-7 shrink-0`,children:[(0,K.jsx)(er,{src:e.metadata.picture,alt:xe(e)}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-xs`,children:xe(e).charAt(0).toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.event?(0,K.jsx)(dr,{tags:e.event.tags,children:xe(e)}):xe(e)}),e.metadata.nip05&&(0,K.jsx)(Ta,{nip05:e.metadata.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]})]},e.id)),(0,K.jsxs)(`button`,{onClick:()=>{ye(),P(!0)},className:`flex items-center gap-4 w-full px-4 py-2.5 text-sm font-normal text-muted-foreground hover:bg-secondary/60 transition-colors`,children:[(0,K.jsx)(d,{className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.shareProfile`,defaultMessage:`Share profile`})})]}),(0,K.jsxs)(`button`,{onClick:()=>{ye(),ne(!0)},className:`flex items-center gap-4 w-full px-4 py-2.5 text-sm font-normal text-muted-foreground hover:bg-secondary/60 transition-colors`,children:[(0,K.jsx)(c,{className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.addAccount`,defaultMessage:`Add another account`})})]}),(0,K.jsxs)(`button`,{onClick:be,className:`flex items-center gap-4 w-full px-4 py-2.5 text-sm font-normal text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,K.jsx)(N,{className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(B,{id:`sidebar.logOutAs`,defaultMessage:`Log out @{name}`,values:{name:l?.name||l?.display_name||n.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`})}})})]})]}),(0,K.jsx)(`nav`,{className:`flex flex-col gap-0.5 flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-1`,children:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(Bd,{items:_e,editing:O,onRemove:S,onReorder:C,isActive:e=>$i(e,a.pathname,a.search,p,T),getOnClick:()=>ye,getProfilePath:e=>e===`profile`?p:void 0,getShowIndicator:e=>e===`notifications`?D:void 0,linkClassName:`text-base`,homePage:T}),(0,K.jsx)(qd,{editing:O,hiddenItems:ve,onDoneEditing:()=>k(!1),onStartEditing:()=>k(!0),onAdd:b,onAddDivider:x,onNavigate:ye,open:ee,onOpenChange:A,homePage:T})]})}),(0,K.jsx)(`div`,{className:`px-2 safe-area-bottom`,children:(0,K.jsx)(gf,{onNavigate:ye})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-3 px-4 border-b border-border`,style:{minHeight:`calc(3rem + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`},children:(0,K.jsx)(pf,{className:`w-full flex`})}),(0,K.jsx)(`nav`,{className:`flex flex-col gap-0.5 flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-1`,children:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(Bd,{items:_e,editing:!1,onRemove:S,onReorder:C,isActive:e=>$i(e,a.pathname,a.search,p,T),getOnClick:()=>ye,getProfilePath:e=>e===`profile`?p:void 0,getShowIndicator:e=>e===`notifications`?D:void 0,linkClassName:`text-base`,homePage:T}),(0,K.jsx)(qd,{editing:!1,hiddenItems:ve,onDoneEditing:()=>k(!1),onStartEditing:()=>k(!0),onAdd:b,onAddDivider:x,onNavigate:ye,open:ee,onOpenChange:A,homePage:T})]})}),(0,K.jsx)(`div`,{className:`px-2 safe-area-bottom`,children:(0,K.jsx)(gf,{onNavigate:ye})})]})]})})}),(0,K.jsx)(Vr,{isOpen:te,onClose:()=>ne(!1),onLogin:()=>ne(!1),onSignupClick:I}),(0,K.jsx)(Yd,{open:re,onOpenChange:P})]})}function bf(e){let[t,n]=(0,G.useState)(!1),r=(0,G.useRef)(0),i=(0,G.useRef)(0);return(0,G.useEffect)(()=>{let t=e??window;r.current=0,i.current=0,n(!1);let a=()=>{let t=e?e.scrollTop:window.scrollY;if(t<=60){i.current=0,n(!1),r.current=t;return}let a=t-r.current;r.current=t,Math.sign(a)===Math.sign(i.current)?i.current+=a:i.current=a,i.current>8?(n(!0),i.current=0):i.current<-8&&(n(!1),i.current=0)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>t.removeEventListener(`scroll`,a)},[e]),{hidden:t}}function xf({open:e,onClose:t}){let n=rr(),r=ht(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(-1),c=(0,G.useRef)(null),{data:l}=Cu(i),{data:u}=Eu(i),d=l?.[0]??null,f=u?.[0]??null,p=(0,G.useMemo)(()=>Wi(i),[i]),m=(0,G.useMemo)(()=>ra(i),[i]),h=(0,G.useMemo)(()=>Ll(i),[i]),g=h,_=(0,G.useMemo)(()=>Z(i),[i]),{data:v}=Oe(_?.type===`nip05`?_.identifier:void 0),{results:y,profileCount:b,isFetching:x}=Gu(i,{excludePubkey:(0,G.useMemo)(()=>{if(_){if(_.type===`npub`||_.type===`nprofile`)return _.pubkey;if(_.type===`nip05`&&v)return v}},[_,v])}),S=y.length,C=!!p,w=C&&(p.exact||b===0),T=!!_,E=!!d,D=!!f,O=m.length,k=O+S+ +!!C+ +!!g+ +!!T+ +!!E+ +!!D,ee=0,A=ee;ee+=O;let j=T?ee++:-1,N=g?ee++:-1,te=C&&w?ee++:-1,ne=ee;ee+=S;let re=C&&!w?ee++:-1,P=w?te:re,F=E?ee++:-1,I=D?ee++:-1;(0,G.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;document.body.style.overflow=`hidden`;let n=e=>{e.target.closest?.(`[data-mobile-search-results]`)||e.preventDefault()};return document.addEventListener(`touchmove`,n,{passive:!1}),()=>{document.body.style.overflow=t,document.removeEventListener(`touchmove`,n)}},[e]),(0,G.useEffect)(()=>{if(e){let e=setTimeout(()=>c.current?.focus(),80);return()=>clearTimeout(e)}else a(``),s(-1)},[e]),(0,G.useEffect)(()=>{s(-1)},[y]);let L=(0,G.useCallback)(()=>{a(``),t()},[t]),R=(0,G.useCallback)(()=>{h&&(L(),n(`/i/${encodeURIComponent(i.trim())}`))},[h,i,n,L]),ie=(0,G.useCallback)(e=>{L(),n(`/i/iso3166:${e.code}`)},[n,L]),ae=(0,G.useCallback)(e=>{L(),n(e)},[n,L]),oe=(0,G.useCallback)(e=>{L(),n(e.path)},[n,L]),se=(0,G.useCallback)(e=>{L(),n(`/i/${encodeURIComponent(e.url)}`)},[n,L]),ce=(0,G.useCallback)(e=>{L(),n(`/i/${encodeURIComponent(`https://archive.org/details/${e.identifier}`)}`)},[n,L]),le=(0,G.useCallback)(e=>{L(),n(e.path)},[n,L]),ue=(0,G.useCallback)(e=>{let t=e.metadata.nip05,i=!!t&&r.getQueryData([`nip05-verify`,t,e.pubkey])===!0,a=fr(e.pubkey,e.metadata,i);L(),n(a)},[n,L,r]),fe=(0,G.useCallback)(()=>{i.trim()&&(L(),n(`/search?q=${encodeURIComponent(i.trim())}`))},[i,n,L]),pe=e=>{if(e.key===`Escape`){e.preventDefault(),L();return}if(e.key===`Enter`){if(e.preventDefault(),o>=0&&o0&&o>=A&&o0&&o>=ne&&oe>0?e-1:k-1)):e.key===`ArrowDown`&&(e.preventDefault(),s(e=>e0&&(O>0||T||g||C||E||D||S>0);return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 sidebar:hidden animate-in fade-in-0 duration-150`,onClick:L}),(0,K.jsxs)(`div`,{className:`fixed left-0 right-0 bottom-0 z-[49] sidebar:hidden animate-in slide-in-from-bottom-4 duration-200 pb-6`,children:[me&&(0,K.jsxs)(`div`,{"data-mobile-search-results":!0,className:`flex flex-col-reverse bg-popover/95 rounded-2xl mx-6 mb-0.5 overflow-hidden max-h-[55vh] overflow-y-auto shadow-lg`,children:[m.map((e,t)=>(0,K.jsx)(Sf,{item:e,isSelected:t+A===o,onClick:oe},e.id)),T&&(0,K.jsx)(Cf,{match:_,isSelected:o===j,onNavigate:ae}),g&&(0,K.jsx)(Af,{url:i.trim(),isSelected:o===N,onClick:R}),C&&w&&(0,K.jsx)(kf,{country:p.country,isSelected:o===P,onClick:ie}),y.map((e,t)=>e.type===`profile`?(0,K.jsx)(jf,{profile:e.profile,isSelected:t+ne===o,isFollowed:e.followed,onClick:ue},e.key):(0,K.jsx)(qu,{result:e.event,isSelected:t+ne===o,isFollowed:e.followed,onClick:le},e.key)),C&&!w&&(0,K.jsx)(kf,{country:p.country,isSelected:o===P,onClick:ie}),E&&(0,K.jsx)(Mf,{result:d,isSelected:o===F,onClick:se}),D&&(0,K.jsx)(Nf,{result:f,isSelected:o===I,onClick:ce})]}),(0,K.jsx)(`div`,{className:`flex items-center px-6 py-3 safe-area-bottom`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 bg-secondary rounded-full px-4 py-2.5`,children:[x?(0,K.jsxs)(`svg`,{className:`size-4 shrink-0 text-muted-foreground`,style:{animation:`spin 1s linear infinite`},xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}):(0,K.jsx)(de,{strokeWidth:4,className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onKeyDown:pe,placeholder:`Search people or topics...`,className:`flex-1 bg-transparent text-base outline-none placeholder:text-muted-foreground`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1}),(0,K.jsx)(`button`,{onClick:L,className:`size-5 shrink-0 flex items-center justify-center rounded-full bg-muted text-muted-foreground hover:bg-muted/80 transition-colors`,children:(0,K.jsx)(M,{strokeWidth:4,className:`size-3`})})]})})]})]}):null}function Sf({item:e,isSelected:t,onClick:n}){let r=e.icon;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-full bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(r,{className:`size-3.5 text-primary`})}),(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:e.label})]})}function Cf({match:e,isSelected:t,onNavigate:n}){switch(e.type){case`nip05`:return(0,K.jsx)(wf,{identifier:e.identifier,isSelected:t,onNavigate:n});case`npub`:case`nprofile`:return(0,K.jsx)(Tf,{pubkey:e.pubkey,raw:e.raw,isSelected:t,onNavigate:n});case`note`:return(0,K.jsx)(Ef,{eventId:e.eventId,raw:e.raw,isSelected:t,onNavigate:n});case`nevent`:return(0,K.jsx)(Ef,{eventId:e.eventId,relays:e.relays,authorHint:e.authorHint,raw:e.raw,isSelected:t,onNavigate:n});case`naddr`:return(0,K.jsx)(Df,{addr:e.addr,relays:e.relays,raw:e.raw,isSelected:t,onNavigate:n});case`hex`:return(0,K.jsx)(Of,{hex:e.hex,isSelected:t,onNavigate:n})}}function wf({identifier:e,isSelected:t,onNavigate:n}){let{data:r,isLoading:i}=Oe(e),a=Dn(r??void 0),o=a.data?.metadata,s=o?.name||o?.display_name||(r?`Anonymous`:e),c=a.data?.event?.tags??[];return i?(0,K.jsxs)(`div`,{"data-search-item":!0,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:``),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-full bg-secondary animate-pulse`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,K.jsx)(`div`,{className:`h-4 w-24 bg-secondary animate-pulse rounded`}),(0,K.jsx)(`div`,{className:`h-3 w-32 bg-secondary animate-pulse rounded`})]})]}):r?(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(`/${e}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(nr,{shape:$n(o),className:`size-9 shrink-0`,children:[(0,K.jsx)(er,{src:o?.picture,alt:s}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:s[0]?.toUpperCase()||`?`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:(0,K.jsx)(dr,{tags:c,children:s})}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:e})]})]}):null}function Tf({pubkey:e,raw:t,isSelected:n,onNavigate:r}){let i=Dn(e),a=i.data?.metadata,o=a?.name||a?.display_name||`Anonymous`,s=i.data?.event?.tags??[];return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":n,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>r(`/${t}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(nr,{shape:$n(a),className:`size-9 shrink-0`,children:[(0,K.jsx)(er,{src:a?.picture,alt:o}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:o[0]?.toUpperCase()||`?`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:i.isLoading?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading profile...`}):(0,K.jsx)(dr,{tags:s,children:o})}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[t.slice(0,8),`...`,t.slice(-4)]})]})]})}function Ef({eventId:e,relays:t,authorHint:n,raw:r,isSelected:i,onNavigate:a}){let{data:o,isLoading:s}=Hi(e,t,n),c=Dn(o?.pubkey).data?.metadata,l=c?.name||c?.display_name||(o?`Anonymous`:void 0);return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":i,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,i?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>a(`/${r}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(_e,{className:`size-3.5 text-primary`})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:s?(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading event...`}):o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm truncate block`,children:o.content.slice(0,80)||`Kind ${o.kind} event`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:l?`by ${l}`:r.slice(0,8)+`...`+r.slice(-4)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:`Go to event`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[r.slice(0,8),`...`,r.slice(-4)]})]})})]})}function Df({addr:e,relays:t,raw:n,isSelected:r,onNavigate:i}){let{data:a,isLoading:o}=Vi(e,t),s=Dn(a?.pubkey??e.pubkey).data?.metadata,c=s?.name||s?.display_name||`Anonymous`,l=a?.tags.find(([e])=>e===`title`)?.[1];return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":r,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>i(`/${n}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(_e,{className:`size-3.5 text-primary`})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading...`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm truncate block`,children:l||a?.content.slice(0,80)||`Kind ${e.kind} event`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:[`by `,c]})]})})]})}function Of({hex:e,isSelected:t,onNavigate:n}){return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(`/${e}`),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(b,{className:`size-3.5 text-primary`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:`Go to identifier`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate block font-mono`,children:[e.slice(0,8),`...`,e.slice(-4)]})]})]})}function kf({country:e,isSelected:t,onClick:n}){return(0,K.jsxs)(`button`,{role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{className:`size-9 shrink-0 rounded-full bg-secondary flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`text-lg leading-none`,role:`img`,"aria-label":`Flag of ${e.name}`,children:e.flag})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:e.name}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.code})]})]})}function Af({url:e,isSelected:t,onClick:n}){let{data:r}=Ui(e),i=r?.thumbnail_url;return(0,K.jsxs)(`button`,{role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:n,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-9 shrink-0 rounded-lg overflow-hidden bg-primary/10 flex items-center justify-center`,children:[i?(0,K.jsx)(`img`,{src:i,alt:``,className:`size-9 object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}):null,(0,K.jsx)(`div`,{className:H(`items-center justify-center size-9`,i?`hidden`:`flex`),children:(0,K.jsx)(hr,{url:e,size:16,fallback:(0,K.jsx)(w,{className:`size-3.5 text-primary`})})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate block`,children:r?.title??`Comment on this link`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground truncate block`,children:(()=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}})()})]})]})}function jf({profile:e,isSelected:t,isFollowed:n,onClick:r}){let{metadata:i,pubkey:a}=e,o=i.name||i.display_name||`Anonymous`,s=i.nip05,{data:c}=pr(s,a),l=c&&s?s.startsWith(`_@`)?s.slice(2):s:void 0,u=l||tt.npubEncode(a);return(0,K.jsxs)(`button`,{role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>r(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsxs)(nr,{shape:$n(i),className:`size-9`,children:[(0,K.jsx)(er,{src:i.picture,alt:o}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-sm`,children:o[0]?.toUpperCase()||`?`})]}),n&&(0,K.jsx)(`span`,{className:`absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-primary flex items-center justify-center ring-2 ring-popover`,children:(0,K.jsx)(T,{className:`size-2.5 text-primary-foreground`,strokeWidth:3})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate`,children:(0,K.jsx)(dr,{tags:e.event.tags,children:o})}),i.bot&&(0,K.jsx)(`span`,{className:`text-xs text-primary`,children:`🤖`})]}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:l?(0,K.jsx)(`span`,{children:u}):(0,K.jsx)(`span`,{className:`font-mono text-[11px]`,children:u})})]})]})}function Mf({result:e,isSelected:t,onClick:n}){return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-9 shrink-0 rounded-full bg-secondary flex items-center justify-center`,children:[e.thumbnail?(0,K.jsx)(`img`,{src:e.thumbnail,alt:``,className:`size-9 rounded-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}):null,(0,K.jsx)(`div`,{className:H(`items-center justify-center size-9`,e.thumbnail?`hidden`:`flex`),children:(0,K.jsx)(ai,{className:`size-3.5 text-muted-foreground`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:e.title}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:`Wikipedia`})]})]})}function Nf({result:e,isSelected:t,onClick:n}){let r=`https://archive.org/services/img/${e.identifier}`;return(0,K.jsxs)(`button`,{"data-search-item":!0,role:`option`,"aria-selected":t,className:H(`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`hover:bg-secondary/60`),onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`size-9 shrink-0 rounded-full bg-secondary flex items-center justify-center overflow-hidden`,children:[(0,K.jsx)(`img`,{src:r,alt:``,className:`size-9 rounded-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.nextElementSibling.style.display=`flex`},decoding:`async`}),(0,K.jsx)(`div`,{className:`hidden items-center justify-center size-9`,children:(0,K.jsx)(l,{className:`size-3.5 text-muted-foreground`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate block`,children:e.title}),(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:`Internet Archive`})]})]})}var Pf={transform:`translateY(calc(100% + 28px))`};function Ff(){let e=lr(),t=ht(),{user:n,metadata:r}=V(),i=Zd(),{scrollContainer:a,noArcs:o}=pa(),{hidden:s}=bf(a),c=mr(n?.pubkey??``,r),{config:l}=Nt(),u=ln(),d=oa(l.homePage),f=d?.icon??xe,p=d?u.formatMessage({id:`nav.${d.id}`,defaultMessage:d.label}):u.formatMessage({id:`nav.feed`,defaultMessage:`Feed`}),m=d?.path,[h,g]=(0,G.useState)(!1),_=(0,G.useCallback)(e=>{e.preventDefault(),_r(),g(e=>!e)},[]),v=s||h,y=r?.name||r?.display_name,b=n&&e.pathname===c;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xf,{open:h,onClose:()=>g(!1)}),(0,K.jsxs)(`nav`,{className:H(`fixed bottom-0 left-0 right-0 z-40 sidebar:hidden will-change-transform`,`transition-transform duration-300 ease-in-out`),style:v?Pf:void 0,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(ja,{variant:o?`rect`:`up`}),(0,K.jsxs)(`div`,{className:`h-11 flex items-center relative`,children:[(0,K.jsxs)(or,{to:`/`,onClick:()=>{_r(),g(!1),(e.pathname===`/`||e.pathname===m)&&(window.scrollTo({top:0,behavior:`smooth`}),t.invalidateQueries({queryKey:[`feed`]}),t.invalidateQueries({queryKey:[`ditto-curated-feed`]}))},className:H(`flex flex-col items-center justify-center gap-0.5 flex-1 py-2 transition-colors`,e.pathname===`/`||e.pathname===m?`text-primary`:`text-muted-foreground`),children:[(0,K.jsx)(f,{className:`size-5`}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium`,children:p})]}),(0,K.jsxs)(`button`,{onClick:_,className:H(`flex flex-col items-center justify-center gap-0.5 flex-1 py-2 transition-colors`,h?`text-primary`:`text-muted-foreground`),children:[(0,K.jsx)(de,{className:`size-5`}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium`,children:(0,K.jsx)(B,{id:`nav.search`,defaultMessage:`Search`})})]}),n&&(0,K.jsxs)(or,{to:`/notifications`,onClick:()=>{_r(),g(!1)},className:H(`flex flex-col items-center justify-center gap-0.5 flex-1 py-2 transition-colors`,e.pathname===`/notifications`?`text-primary`:`text-muted-foreground`),children:[(0,K.jsxs)(`span`,{className:`relative`,children:[(0,K.jsx)(pe,{className:`size-5`}),i&&(0,K.jsx)(`span`,{className:`absolute -top-1 right-0 size-2 bg-primary rounded-full`})]}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium`,children:(0,K.jsx)(B,{id:`nav.notifications`,defaultMessage:`Notifications`})})]}),n?(0,K.jsxs)(or,{to:c,onClick:()=>{_r(),g(!1)},className:H(`flex flex-col items-center justify-center gap-0.5 flex-1 py-2 transition-colors`,b?`text-primary`:`text-muted-foreground`),children:[(0,K.jsxs)(nr,{shape:$n(r),className:`size-5`,children:[(0,K.jsx)(er,{src:r?.picture,alt:y}),(0,K.jsx)(Qn,{className:`bg-primary/20 text-primary text-[8px]`,children:y?.[0]?.toUpperCase()||(0,K.jsx)(Se,{className:`size-3`})})]}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium`,children:(0,K.jsx)(B,{id:`nav.profile`,defaultMessage:`Profile`})})]}):(0,K.jsxs)(or,{to:`/profile`,className:`flex flex-col items-center justify-center gap-0.5 flex-1 py-2 transition-colors text-muted-foreground`,children:[(0,K.jsx)(Se,{className:`size-5`}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium`,children:(0,K.jsx)(B,{id:`nav.profile`,defaultMessage:`Profile`})})]})]})]}),(0,K.jsx)(`div`,{className:`safe-area-bottom bg-background/85`})]})]})}function If({onClick:e,icon:t,disabled:n,className:r=``,title:i}){let{metadata:a}=V(),o=$n(a),s=(0,G.useMemo)(()=>{if(!o)return;let e=tr(o);if(e)return{WebkitMaskImage:`url(${e})`,maskImage:`url(${e})`,WebkitMaskSize:`contain`,maskSize:`contain`,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,WebkitMaskPosition:`center`,maskPosition:`center`}},[o]);return(0,K.jsxs)(`button`,{onClick:e,disabled:n,title:i,className:`relative size-16 transition-transform hover:scale-105 active:scale-95 disabled:opacity-40 disabled:pointer-events-none ${r}`,style:{filter:`drop-shadow(0 2px 8px hsl(var(--primary) / 0.25))`},children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-primary ${s?``:`rounded-full`}`,style:s}),(0,K.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-primary-foreground`,children:t})]})}var Lf=(0,G.lazy)(()=>z(()=>import(`./EmbeddedPost-DITW2flc.js`).then(e=>e.f).then(e=>({default:e.ReplyComposeModal})),__vite__mapDeps([62,3,4,15,5,41,31,32,33,34,38,63,64,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,45,48,54,56,57,121,27,122,123,124,125,126,59,127,128])));function Rf({kind:e=1,href:t,onFabClick:n,icon:r}){let{user:i,isLoading:a}=V(),o=rr(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1);return!i||a?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(If,{onClick:()=>{n?n():t?o(t):e===1?c(!0):u(!0)},icon:r??(0,K.jsx)(S,{strokeWidth:4,size:16})}),e===1&&s&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Lf,{open:s,onOpenChange:c})}),e!==1&&(0,K.jsx)(Ci,{open:l,onOpenChange:u,children:(0,K.jsx)(Si,{className:`max-w-[360px] rounded-2xl text-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:[(0,K.jsx)(`div`,{className:`size-16 rounded-full bg-muted flex items-center justify-center`,children:(0,K.jsx)(Ce,{className:`size-8 text-muted-foreground`})}),(0,K.jsx)(bi,{className:`text-lg font-semibold`,children:`Coming soon`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed max-w-[260px]`,children:`Creating this type of content isn't available yet. Stay tuned!`}),(0,K.jsx)(Rn,{variant:`outline`,className:`rounded-full mt-2`,onClick:()=>u(!1),children:`Got it`})]})})})]})}function zf(e){let t=e.trim().split(/\s+/);return{h:parseFloat(t[0]??`30`),s:parseFloat(t[1]??`100`),l:parseFloat(t[2]??`55`)}}function Bf(){let e=(0,G.useRef)(null),t=(0,G.useRef)([]),n=(0,G.useRef)([]),r=(0,G.useRef)(null),i=(0,G.useRef)(!1),a=(0,G.useRef)(0),o=(0,G.useRef)(0),s=(0,G.useRef)(0);return(0,G.useEffect)(()=>{let c=e.current;if(!c)return;let l=c.getContext(`2d`);if(!l)return;function u(){c&&(c.width=window.innerWidth,c.height=window.innerHeight)}u(),window.addEventListener(`resize`,u);function d(e){r.current={x:e.clientX,y:e.clientY},i.current=!0}function f(e){let t=e.touches[0];t&&(r.current={x:t.clientX,y:t.clientY},i.current=!0)}function p(){i.current=!1}function m(e){v(e.clientX,e.clientY)}function h(e){let t=e.touches[0];t&&v(t.clientX,t.clientY)}window.addEventListener(`mousemove`,d),window.addEventListener(`touchmove`,f,{passive:!0}),window.addEventListener(`mouseleave`,p),window.addEventListener(`touchend`,p),window.addEventListener(`click`,m),window.addEventListener(`touchstart`,h,{passive:!0});function g(){let e=getComputedStyle(document.documentElement).getPropertyValue(`--primary`).trim();return e?zf(e):{h:270,s:80,l:60}}function _(e,n){let r=Math.floor(Math.random()*2)+2;for(let i=0;i{cancelAnimationFrame(a.current),window.removeEventListener(`resize`,u),window.removeEventListener(`mousemove`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`mouseleave`,p),window.removeEventListener(`touchend`,p),window.removeEventListener(`click`,m),window.removeEventListener(`touchstart`,h)}},[]),(0,K.jsx)(`canvas`,{ref:e,className:`pointer-events-none fixed inset-0 z-[9999]`,"aria-hidden":`true`})}function Vf(e){let[t,n]=(0,G.useState)(()=>window.matchMedia(e).matches);return(0,G.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),n(t.matches),()=>t.removeEventListener(`change`,r)},[e]),t}var Hf=(0,G.lazy)(()=>z(()=>import(`./WidgetSidebar-CCOWgym0.js`).then(e=>({default:e.WidgetSidebar})),__vite__mapDeps([129,3,4,5,64,41,36,37,31,32,33,34,38,39,40,1,6,8,70,82,130,10,16,18,20,21,15,9,22,26,29])));function Uf(){return(0,K.jsx)(`main`,{className:`flex-1 min-w-0 min-h-screen sidebar:border-l sidebar:border-r border-border bg-background/85 sidebar:max-w-[600px] flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`relative w-10 h-10`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-[2.5px] border-primary/20`}),(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-[2.5px] border-transparent border-t-primary animate-spin`})]})})}function Wf(){let{rightSidebar:e,showFAB:t=!1,fabKind:n=1,fabHref:r,onFabClick:i,fabIcon:a,wrapperClassName:o,noOverscroll:s,noMaxWidth:c,scrollContainer:l,hasSubHeader:u,hideTopBar:d,hideBottomNav:f}=pa(),[p,m]=(0,G.useState)(!1),h=(0,G.useCallback)(()=>m(!0),[]),g=(0,G.useRef)(null),[_,v]=(0,G.useState)(null),{config:y}=Nt(),{hidden:b}=bf(l),x=lr(),S=Vf(`(min-width: 1024px)`);return(0,K.jsx)(ya.Provider,{value:_,children:(0,K.jsx)(ga.Provider,{value:h,children:(0,K.jsxs)(fa.Provider,{value:b,children:[y.magicMouse&&(0,K.jsx)(Bf,{}),!d&&(0,K.jsx)(tf,{onAvatarClick:()=>m(!0),hasSubHeader:u}),(0,K.jsx)(yf,{open:p,onOpenChange:m}),(0,K.jsxs)(`div`,{className:H(`flex justify-center mx-auto max-w-[1200px]`,o),children:[(0,K.jsx)($d,{}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Uf,{}),children:(0,K.jsxs)(`div`,{ref:e=>{g.current=e,v(e)},className:H(`relative z-0 flex-1 min-w-0 sidebar:border-l sidebar:border-r border-border bg-background/85`,!d&&`-mt-mobile-bar`,!c&&`sidebar:max-w-[600px]`,!s&&`pb-overscroll`),children:[(0,K.jsx)(Ne,{sentryTags:{errorBoundary:`center-column`,path:x.pathname},resetKeys:[x.pathname],children:(0,K.jsx)(ir,{})}),t&&(0,K.jsx)(`div`,{className:`hidden sidebar:block sticky bottom-6 z-30 pointer-events-none`,children:(0,K.jsx)(`div`,{className:`flex justify-end pr-4`,children:(0,K.jsx)(`div`,{className:`pointer-events-auto`,children:(0,K.jsx)(Rf,{kind:n,href:r,onFabClick:i,icon:a})})})})]})}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{className:`w-1/4 max-w-[300px] shrink-0 hidden lg:block`}),children:e??(S&&(0,K.jsx)(Hf,{}))})]}),!f&&(0,K.jsx)(Ff,{}),t&&(0,K.jsx)(`div`,{className:`fixed bottom-fab right-6 z-30 pointer-events-none transition-transform duration-300 ease-in-out sidebar:hidden`,style:b?{transform:`translateY(calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))))`}:void 0,children:(0,K.jsx)(`div`,{className:`pointer-events-auto`,children:(0,K.jsx)(Rf,{kind:n,href:r,onFabClick:i,icon:a})})})]})})})}function Gf(){let e=(0,G.useMemo)(()=>new _a,[]),[t,n]=(0,G.useState)(null),r=(0,G.useMemo)(()=>({activeSubdomain:t,setActiveSubdomain:n}),[t]);return(0,K.jsx)(ma.Provider,{value:e,children:(0,K.jsx)(Sa.Provider,{value:r,children:(0,K.jsx)(Wf,{})})})}var Kf=`ditto:historychange`,qf=!1;function Jf(){if(!(qf||typeof window>`u`||!window.history)){qf=!0;for(let e of[`pushState`,`replaceState`]){let t=window.history[e];window.history[e]=function(...e){t.apply(this,e),window.dispatchEvent(new Event(Kf))}}}}function Yf(e){return Jf(),window.addEventListener(Kf,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(Kf,e),window.removeEventListener(`popstate`,e)}}var Xf=120,Zf=200,Qf=220,$f=90;function ep(){let e=lr(),[t,n]=(0,G.useState)(0),r=(0,G.useRef)(!1),i=(0,G.useRef)(void 0),a=(0,G.useRef)(void 0),o=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>Yf(()=>{clearTimeout(o.current),!r.current&&(clearTimeout(i.current),i.current=setTimeout(()=>{r.current=!0,n(8),a.current=setInterval(()=>{n(e=>e<$f?e+($f-e)*.1:e)},Zf)},Xf))}),[]),(0,G.useEffect)(()=>{clearTimeout(i.current),clearInterval(a.current),r.current&&(n(100),o.current=setTimeout(()=>{r.current=!1,n(0)},Qf))},[e.key]),(0,G.useEffect)(()=>()=>{clearTimeout(i.current),clearInterval(a.current),clearTimeout(o.current)},[]),(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none fixed inset-x-0 top-0 z-[100]`,children:(0,K.jsx)(`div`,{className:`h-0.5 bg-primary shadow-[0_0_8px_hsl(var(--primary)/0.6)] transition-[width,opacity] duration-200 ease-out`,style:{width:`${t}%`,opacity:+(t>0)}})})}function tp(){let{pathname:e}=lr(),t=ar();return(0,G.useEffect)(()=>{t===`PUSH`&&window.scrollTo(0,0)},[e,t]),null}function np(e){return e.replace(/ -- /g,` — `).replace(/(\w)--(\w)/g,`$1–$2`).replace(/ (\S+)$/,`\xA0$1`)}function rp(e){let t=[],n=null,r=null,i=[],a=()=>{n&&i.length&&(n.summary=i.join(` `)),i=[]};for(let o of e.split(` `)){let e=o.match(/^## \[([^\]]+)\]\s*-\s*(.+)$/);if(e){a(),n={version:e[1],date:e[2].trim(),sections:[]},t.push(n),r=null;continue}let s=o.match(/^### (.+)$/);if(s&&n){a(),r=s[1].trim(),n.sections.push({category:r,items:[]});continue}let c=o.match(/^- (.+)$/);if(c&&n){let e=n.sections[n.sections.length-1];e?e.items.push(np(c[1])):(a(),n.sections.push({category:`Changed`,items:[np(c[1])]}));continue}let l=o.trim();if(l&&n&&!l.startsWith(`#`)){let e=n.sections[n.sections.length-1];e?e.items.push(np(l)):i.push(l)}}return a(),t}var ip=60;function ap(e,t){if(e.length<=t)return e;let n=e.slice(0,t).trimEnd(),r=n.lastIndexOf(` `);return(r>t*.6?n.slice(0,r).trimEnd():n)+`…`}async function op(e){try{let t=await fetch(`/CHANGELOG.md`);if(!t.ok)return;let n=rp(await t.text()),r=n.find(t=>t.version===e)??n[0];if(!r)return;if(r.summary)return ap(r.summary,ip);let i=r.sections[0]?.items[0];return i?ap(i,ip):void 0}catch{return}}function sp(){let{config:e}=Nt();return(0,G.useEffect)(()=>{let t=`2.36.0`,n=Pr(e.appId,`app-version`),r=localStorage.getItem(n);if(localStorage.setItem(n,t),r&&r!==t){let{update:e,id:n}=An({title:`What's new in v${t}`,action:(0,K.jsx)(ji,{altText:`View changelog`,asChild:!0,children:(0,K.jsx)(or,{to:`/changelog`,children:`See all`})})});op(t).then(r=>{r&&e({id:n,title:`What's new in v${t}`,description:r,action:(0,K.jsx)(ji,{altText:`View changelog`,asChild:!0,children:(0,K.jsx)(or,{to:`/changelog`,children:`See all`})})})})}},[e.appId]),null}var cp=[],lp,up=[`meta[property="og:title"]`,`meta[name="twitter:title"]`],dp=[`meta[name="description"]`,`meta[property="og:description"]`,`meta[name="twitter:description"]`];function fp(){if(!lp){let e=new Map;for(let t of[...up,...dp])e.set(t,document.head.querySelector(t)?.getAttribute(`content`)??null);lp={title:document.title,tags:e}}return lp}function pp(e,t){let n=document.head.querySelector(e);n&&(t===null?n.removeAttribute(`content`):n.setAttribute(`content`,t))}function mp(){let e=fp(),t=cp[cp.length-1]?.meta;document.title=t?.title??e.title;for(let n of up)pp(n,t?.title??e.tags.get(n)??null);for(let n of dp)pp(n,t?.description??e.tags.get(n)??null)}function hp(e){let{title:t,description:n}=e,r=(0,G.useRef)(void 0);(0,G.useLayoutEffect)(()=>{let e=r.current??{meta:{}};return r.current=e,cp.push(e),()=>{let t=cp.indexOf(e);t!==-1&&cp.splice(t,1),mp()}},[]),(0,G.useLayoutEffect)(()=>{let e=r.current;e&&(e.meta={title:t,description:n},cp[cp.length-1]===e&&mp())},[t,n])}function gp(e){return`hsl(${e})`}function _p({colors:e,label:t,emoji:n,backgroundUrl:r,isActive:i,onClick:a}){let o=(0,G.useMemo)(()=>Kt(e),[e]);return(0,K.jsxs)(`button`,{onClick:a,className:H(`group flex-shrink-0 rounded-xl border-2 p-1 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i?`border-primary shadow-md scale-[1.02]`:`border-border/50 hover:border-primary/40 hover:shadow-sm`),children:[(0,K.jsxs)(`div`,{className:`w-[88px] aspect-[4/3] rounded-lg overflow-hidden relative`,style:{backgroundColor:gp(o.background)},children:[r&&(0,K.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:`absolute inset-0 w-full h-full object-cover opacity-40`,decoding:`async`}),(0,K.jsxs)(`div`,{className:`p-1.5 pt-2.5 space-y-0.5 relative`,children:[(0,K.jsx)(`div`,{className:`h-0.5 w-3/4 rounded-full`,style:{backgroundColor:gp(o.foreground),opacity:.5}}),(0,K.jsx)(`div`,{className:`h-0.5 w-1/2 rounded-full`,style:{backgroundColor:gp(o.mutedForeground),opacity:.3}}),(0,K.jsx)(`div`,{className:`pt-0.5`,children:(0,K.jsx)(`div`,{className:`h-1.5 w-6 rounded-sm`,style:{backgroundColor:gp(o.primary)}})})]})]}),(0,K.jsxs)(`p`,{className:H(`mt-1 text-[10px] font-medium text-center truncate transition-colors`,i?`text-foreground`:`text-muted-foreground`),children:[n,` `,t]})]})}function vp({onLoginClick:e,onSignupClick:t}){let{config:n}=Nt(),{theme:r,customTheme:i,applyCustomTheme:a,setTheme:o}=Jt(),s=(0,G.useRef)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!0),f=(0,G.useMemo)(()=>Object.entries(zt).filter(([,e])=>e.featured).slice(0,12),[]),m=(0,G.useMemo)(()=>{if(r!==`custom`||!i)return null;let e=JSON.stringify(i.colors);for(let[t,n]of Object.entries(zt))if(JSON.stringify(n.colors)===e)return t;return null},[r,i]),h=()=>{let e=s.current;e&&(l(e.scrollLeft>4),d(e.scrollLeft{let t=s.current;if(!t)return;let n=t.clientWidth*.6;t.scrollBy({left:e===`left`?-n:n,behavior:`smooth`})};return(0,K.jsxs)(`div`,{className:`landing-hero`,children:[(0,K.jsxs)(`div`,{className:`px-4 pt-8 pb-6 text-center space-y-4`,children:[(0,K.jsx)(`div`,{className:`flex justify-center landing-hero-fade`,style:{animationDelay:`0ms`},children:(0,K.jsx)(Fn,{size:56})}),(0,K.jsxs)(`div`,{className:`space-y-2 landing-hero-fade`,style:{animationDelay:`80ms`},children:[(0,K.jsx)(`h1`,{className:`text-2xl sidebar:text-3xl font-bold tracking-tight`,children:n.appName}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm sidebar:text-base max-w-xs mx-auto leading-relaxed`,children:`Your content. Your vibe. Your\xA0rules.`})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 justify-center landing-hero-fade`,style:{animationDelay:`160ms`},children:[(0,K.jsx)(Rn,{onClick:t,className:`rounded-full px-6`,size:`sm`,children:`Sign up`}),(0,K.jsx)(Rn,{onClick:e,variant:`outline`,className:`rounded-full px-6`,size:`sm`,children:`Log in`}),(0,K.jsx)(Rn,{variant:`outline`,className:`rounded-full px-6`,size:`sm`,asChild:!0,children:(0,K.jsx)(or,{to:`/help`,children:`FAQ`})})]})]}),(0,K.jsxs)(`div`,{className:`pb-5 landing-hero-fade`,style:{animationDelay:`240ms`},children:[(0,K.jsxs)(`div`,{className:`px-4 mb-2.5 flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Make it yours`}),(0,K.jsx)(or,{to:`/themes`,className:`text-xs text-primary hover:text-primary/80 font-medium transition-colors`,children:`All themes`})]}),(0,K.jsxs)(`div`,{className:`relative group/scroll`,children:[c&&(0,K.jsx)(`button`,{onClick:()=>g(`left`),className:`absolute left-1 top-1/2 -translate-y-1/2 z-10 size-7 rounded-full bg-background/90 border border-border shadow-sm flex items-center justify-center opacity-0 group-hover/scroll:opacity-100 transition-opacity`,"aria-label":`Scroll left`,children:(0,K.jsx)(p,{className:`size-4`})}),(0,K.jsxs)(`div`,{ref:s,onScroll:h,className:`flex gap-2 px-4 overflow-x-auto scrollbar-none scroll-smooth`,children:[f.map(([e,t])=>(0,K.jsx)(_p,{colors:t.colors,label:t.label,emoji:t.emoji,backgroundUrl:t.background?.url,isActive:m===e,onClick:()=>a({colors:t.colors,font:t.font,background:t.background})},e)),(0,K.jsxs)(`button`,{onClick:()=>o(`system`),className:H(`flex-shrink-0 rounded-xl border-2 p-1 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,r===`system`?`border-primary shadow-md scale-[1.02]`:`border-border/50 hover:border-primary/40 hover:shadow-sm`),children:[(0,K.jsx)(`div`,{className:`w-[88px] aspect-[4/3] rounded-lg overflow-hidden relative bg-gradient-to-br from-background to-muted flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`text-lg`,children:`🔄`})}),(0,K.jsx)(`p`,{className:H(`mt-1 text-[10px] font-medium text-center truncate transition-colors`,r===`system`?`text-foreground`:`text-muted-foreground`),children:`Default`})]})]}),u&&(0,K.jsx)(`button`,{onClick:()=>g(`right`),className:`absolute right-1 top-1/2 -translate-y-1/2 z-10 size-7 rounded-full bg-background/90 border border-border shadow-sm flex items-center justify-center opacity-0 group-hover/scroll:opacity-100 transition-opacity`,"aria-label":`Scroll right`,children:(0,K.jsx)(D,{className:`size-4`})})]})]}),(0,K.jsx)(`div`,{className:`border-b border-border`})]})}var yp=2e3,bp=300,xp=new Map,Sp=null;function Cp(){return typeof IntersectionObserver>`u`?null:(Sp??=new IntersectionObserver(e=>{for(let t of e)xp.get(t.target)?.(t)},{rootMargin:`${yp}px 0px`}),Sp)}function wp(e,t){let n=Cp();return n?(xp.set(e,t),n.observe(e),()=>{n.unobserve(e),xp.delete(e)}):()=>{}}function Tp({children:e,initialInView:t=!1,className:n}){let r=(0,G.useRef)(null),[i,a]=(0,G.useState)(t),o=(0,G.useRef)(bp);return(0,G.useEffect)(()=>{let e=r.current;if(e)return wp(e,e=>{if(!e.isIntersecting){let t=e.boundingClientRect.height;t>0&&(o.current=t)}a(e.isIntersecting)})},[]),(0,K.jsx)(`div`,{ref:r,className:n,children:i?e:(0,K.jsx)(`div`,{style:{height:o.current},"aria-hidden":`true`})})}var Ep=80,Dp=120,Op=.45;function kp({onRefresh:e,children:t,className:n}){let[r,i]=(0,G.useState)(0),[a,o]=(0,G.useState)(!1),s=(0,G.useRef)(0),c=(0,G.useRef)(!1),l=(0,G.useRef)(!1),u=(0,G.useRef)(0),d=(0,G.useRef)(null),f=(0,G.useRef)(e);f.current=e,(0,G.useEffect)(()=>{let e=document.documentElement.style.overscrollBehaviorY;return document.documentElement.style.overscrollBehaviorY=`contain`,()=>{document.documentElement.style.overscrollBehaviorY=e}},[]),(0,G.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>window.scrollY<=0;function n(e){l.current||!t()||(s.current=e.touches[0].clientY,c.current=!1)}function r(e){if(l.current)return;let n=e.touches[0].clientY-s.current;if(n>0&&t()){e.preventDefault(),c.current=!0;let t=Math.min(n*Op,Dp);u.current=t,i(t)}else c.current&&(c.current=!1,u.current=0,i(0))}async function a(){if(l.current||!c.current){c.current=!1,u.current=0,i(0);return}if(c.current=!1,u.current>=Ep*Op){vr(),l.current=!0,u.current=40,i(40),o(!0);try{await f.current()}finally{l.current=!1,o(!1),u.current=0,i(0)}}else u.current=0,i(0)}return e.addEventListener(`touchstart`,n,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!1}),e.addEventListener(`touchend`,a,{passive:!0}),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchmove`,r),e.removeEventListener(`touchend`,a)}},[]);let p=Math.min(r/(Ep*Op),1);return(0,K.jsxs)(`div`,{ref:d,className:n,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center overflow-hidden sidebar:hidden`,style:{height:r>4||a?`${r}px`:`0px`,transition:c.current?`none`:`height 150ms ease-out`},children:(0,K.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-full bg-secondary/80 border border-border shadow-sm`,style:{opacity:p,transform:a?`scale(1)`:`scale(${.5+p*.5}) rotate(${p*360}deg)`,transition:`transform 150ms ease-out`},children:(0,K.jsx)(F,{className:H(`size-4 text-primary`,a&&`animate-spin`)})})}),t]})}function Ap({message:e,onSwitchToGlobal:t,showDiscover:n,onRetry:r,isRetrying:i,isOffline:a,className:s}){let{config:c}=Nt(),l=()=>{try{sessionStorage.setItem(Pr(c.appId,`feed-tab:packs`),`global`)}catch{}},u=a?P:te,d=n||t||r;return(0,K.jsxs)(`div`,{className:H(`py-20 px-8 flex flex-col items-center text-center`,s),children:[(0,K.jsx)(`div`,{className:`size-12 rounded-full bg-muted flex items-center justify-center mb-4`,children:(0,K.jsx)(u,{className:`size-6 text-muted-foreground`})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground max-w-xs`,children:[a&&(0,K.jsx)(`span`,{className:`block font-medium text-foreground mb-1`,children:`You appear to be offline.`}),e]}),d&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 mt-5 w-full max-w-xs`,children:[r&&(0,K.jsxs)(Rn,{className:`rounded-full`,onClick:r,disabled:i,children:[i?(0,K.jsx)(F,{className:`size-4 animate-spin`}):(0,K.jsx)(o,{className:`size-4`}),`Try again`]}),n&&(0,K.jsx)(Rn,{asChild:!0,className:`rounded-full`,children:(0,K.jsx)(or,{to:`/packs`,onClick:l,children:`Discover people to follow`})}),t&&(0,K.jsx)(Rn,{variant:`ghost`,className:`rounded-full`,onClick:t,children:`Browse the Global feed`})]})]})}var jp=15,Mp=3;function Np(e){return e.filter(e=>e.profileZapRecipient||!Pi(e.event))}function Pp(e,t){let{nostr:n}=Ge(),r=ht(),{user:i}=V(),{config:a}=Nt(),{data:o}=Hn(),s=o?.pubkeys,{lovedPubkeys:c}=kt(),{excludeMuted:l,mutedKey:u}=Ia(),{feedSettings:d}=Aa(),{store:f}=jn(),p=Ki(d),m=t?.kinds??(d.followsFeedShowReplies?p:p.filter(e=>e!==1111&&e!==1244)),h=t?.tagFilters,g=[...m].sort().join(`,`),_=h?JSON.stringify(h):``,v=e===`follows`?!!i&&s!==void 0:e===`loved`?!!i&&c!==void 0:!0,y=(()=>{if(e!==`communities`)return[];try{let e=localStorage.getItem(Pr(a.appId,`communityData`));if(!e)return[];let t=JSON.parse(e);return t.names?Object.values(t.names).filter(e=>typeof e==`string`):[]}catch{return[]}})();return Tt({queryKey:[`feed`,e,i?.pubkey??``,g,_,y.length,d.followsFeedShowReplies,u,t?.hotGlobal??!1],queryFn:async({pageParam:o})=>{let u=AbortSignal.timeout(8e3),p=Math.floor(Date.now()/1e3);function g(e){for(let{event:t}of e)r.getQueryData([`event`,t.id])||r.setQueryData([`event`,t.id],t)}if(e===`communities`&&y.length>0){let e=d.followsFeedShowReplies?jp:jp*Mp,t={kinds:m,authors:y,limit:e,...h};o&&(t.until=o);let i=await n.query([t],{signal:u}),s=``;try{let e=localStorage.getItem(Pr(a.appId,`community`));e&&(s=JSON.parse(e).domain)}catch{}let c=[...new Set(i.map(e=>e.pubkey))],l=await n.query([{kinds:[0],authors:c}],{signal:u});if(l.length>0){let e=l.filter(e=>!r.getQueryData([`author`,e.pubkey])),t=e.length>0?await f.query([{kinds:[0],authors:[...new Set(e.map(e=>e.pubkey))]}]):[],n=new Map;for(let e of t){let t=n.get(e.pubkey);(!t||e.created_at>t.created_at)&&n.set(e.pubkey,e)}for(let t of e){let e=n.get(t.pubkey),i=e&&e.created_at>t.created_at?e:t;r.setQueryData([`author`,t.pubkey],wn(i)),f.event(t)}}let _=new Map;for(let e of l)try{let t=JSON.parse(e.content);t.nip05&&_.set(e.pubkey,t.nip05.toLowerCase())}catch{}let v=(s?i.filter(e=>{let t=_.get(e.pubkey);if(!t)return!1;let n=`@${s}`;return t.endsWith(n)}):i).filter(e=>e.created_at<=p),b=ni(v),x=ei(await ri(v,n,u));return d.followsFeedShowReplies||(x=Np(x)),g(x),{items:x,oldestQueryTimestamp:b,rawCount:v.length}}else if(e===`loved`&&i&&c!==void 0){let e=l(c);if(e.length===0)return{items:[],oldestQueryTimestamp:p,rawCount:0};let t={kinds:m.filter(e=>!ti(e)&&!Qr(e)),authors:e,limit:d.followsFeedShowReplies?jp:jp*Mp,...h};o&&(t.until=o);let r=(await n.query([t],{signal:u})).filter(e=>e.created_at<=p),i=ni(r),a=ei(await ri(r,n,u));return d.followsFeedShowReplies||(a=Np(a)),g(a),{items:a,oldestQueryTimestamp:i,rawCount:r.length}}else if(e===`follows`&&i&&s!==void 0){let e=l(s),t=e.length>0?[...e,i.pubkey]:[i.pubkey],r=d.followsFeedShowReplies?jp:jp*Mp,a={kinds:m,authors:t,limit:r,...h};o&&(a.until=o);let c=(await n.query([a],{signal:u})).filter(e=>e.created_at<=p),f=ni(c),_=ei(await ri(c,n,u));return d.followsFeedShowReplies||(_=Np(_)),g(_),{items:_,oldestQueryTimestamp:f,rawCount:c.length}}else{let r={kinds:m.filter(e=>!ti(e)&&!Qr(e)&&!ii(e)),limit:jp,...h};e===`global`&&(!t?.kinds||t?.hotGlobal)&&(r.search=`sort:hot protocol:nostr`),o&&(r.until=o);let i=(await n.query([r],{signal:u})).filter(e=>e.created_at<=p),a=ni(i),s=i.sort((e,t)=>t.created_at-e.created_at).map(e=>({event:e,sortTimestamp:e.created_at}));return g(s),{items:s,oldestQueryTimestamp:a,rawCount:i.length}}},getNextPageParam:e=>{if(e.rawCount!==0)return e.oldestQueryTimestamp-1},initialPageParam:void 0,enabled:v,staleTime:60*1e3,refetchOnWindowFocus:!1,gcTime:1800*1e3,placeholderData:e=>e})}var Fp=200,Ip=10;function Lp(e){let{tab:t,authors:n,kinds:r,showReplies:i,enabled:a=!0}=e,{nostr:o}=Ge(),{config:s}=Nt(),{user:c}=V(),{feedSettings:l}=Aa(),{mutedPubkeys:u}=Ia(),{shouldFilterEvent:d}=Pn(),[f,p]=(0,G.useState)(0),m=(0,G.useRef)(new Set),h=(0,G.useRef)(!1),g=(0,G.useCallback)(()=>{m.current=new Set,p(0)},[]);(0,G.useEffect)(()=>{function e(){let e=window.scrollY>Fp;h.current=e,e||g()}return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[g]);let _=(r??Ki(l)).filter(e=>!ti(e)&&!Qr(e)&&!ii(e)),v=[..._].sort().join(`,`),y=n?[...n].sort().join(`,`):``,b=(0,G.useMemo)(()=>{let e=Jn(s.relayMetadata,s.useAppRelays,s.useUserRelays).relays.filter(e=>e.read).map(e=>e.url);return(e.length>0?e:Yn.relays.filter(e=>e.read).map(e=>e.url)).slice(0,Ip)},[s.relayMetadata,s.useAppRelays,s.useUserRelays]),x=b.join(`,`),S=(0,G.useRef)({showReplies:i,mutedPubkeys:u,shouldFilterEvent:d,userPubkey:c?.pubkey});return S.current={showReplies:i,mutedPubkeys:u,shouldFilterEvent:d,userPubkey:c?.pubkey},(0,G.useEffect)(()=>{if(!a||_.length===0||b.length===0||t!==`global`&&(!n||n.length===0))return;let e=new AbortController,r=!0;m.current=new Set,p(0);let i=Math.floor(Date.now()/1e3),s={kinds:_,since:i,limit:0};t!==`global`&&n&&n.length>0&&(s.authors=n),(async()=>{try{let t=o.group(b);for await(let n of t.req([s],{signal:e.signal})){if(!r)break;if(n[0]===`EVENT`)c(n[2]);else if(n[0]===`CLOSED`)break}}catch{}})();function c(e){if(!h.current||e.created_at>Math.floor(Date.now()/1e3)||m.current.has(e.id))return;let{showReplies:t,mutedPubkeys:n,shouldFilterEvent:r,userPubkey:i}=S.current;i&&e.pubkey===i||n.has(e.pubkey)||$r(e)||r(e)||!t&&Pi(e)||(m.current.add(e.id),p(e=>e+1))}return()=>{r=!1,e.abort()}},[o,t,y,v,x,a]),{newPostCount:f,reset:g}}function Rp(e){return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}}function zp(){return typeof navigator>`u`?!0:navigator.onLine}function Bp(){return!0}function Vp(){return(0,G.useSyncExternalStore)(Rp,zp,Bp)}function Hp(e,t,n){let{user:r}=V(),{config:i}=Nt(),a=Pr(i.appId,`feed-tab:${e}`),[o,s]=(0,G.useState)(()=>{let e=n??(r?`follows`:`ditto`);try{let e=sessionStorage.getItem(a);if(e&&(!t||t.includes(e)))return e}catch{}return t&&!t.includes(e)?t[t.length-1]:e});return[o,(0,G.useCallback)(e=>{s(e);try{sessionStorage.setItem(a,e)}catch{}},[a])]}function Up(e=`t`){let{nostr:t}=Ge(),{user:n}=V(),r=ht(),{mutateAsync:i}=zn();En({queryKey:n?[`interests`,n.pubkey]:void 0,filter:{kinds:[10015],authors:n?[n.pubkey]:[]},toData:e=>e,getEvent:e=>e??void 0});let a=yt({queryKey:[`interests`,n?.pubkey],queryFn:async({signal:e})=>{if(!n)return null;let r=await t.query([{kinds:[10015],authors:[n.pubkey],limit:1}],{signal:AbortSignal.any([e,AbortSignal.timeout(8e3)])});return r.length>0?r.reduce((e,t)=>e.created_at>t.created_at?e:t):null},enabled:!!n,staleTime:60*1e3}),o=(a.data?.tags??[]).filter(([t])=>t===e).map(([,e])=>e.toLowerCase()).filter((e,t,n)=>n.indexOf(e)===t);function s(e){return o.includes(e.toLowerCase())}let c=()=>{r.invalidateQueries({queryKey:[`interests`,n?.pubkey]})};return{hashtags:o,hasInterest:s,addInterest:Ct({mutationFn:async r=>{if(!n)throw Error(`Must be logged in`);let a=r.toLowerCase().replace(/^#/,``);if(!a)throw Error(`Empty tag`);let o=await Cn(t,{kinds:[10015],authors:[n.pubkey]}),s=o?.tags??[];if(s.some(([t,n])=>t===e&&n.toLowerCase()===a))return;let c=[...s,[e,a]];await i({kind:10015,content:o?.content??``,tags:c,prev:o??void 0})},onMutate:t=>{let i=t.toLowerCase().replace(/^#/,``),a=[`interests`,n?.pubkey];return{snapshot:zi(r,a,{kind:10015,pubkey:n?.pubkey??``,transform:t=>t.some(([t,n])=>t===e&&n.toLowerCase()===i)?t:[...t,[e,i]]}),key:a}},onError:(e,t,n)=>{n&&Li(r,n.key,n.snapshot)},onSuccess:c}),removeInterest:Ct({mutationFn:async r=>{if(!n)throw Error(`Must be logged in`);let a=r.toLowerCase().replace(/^#/,``),o=await Cn(t,{kinds:[10015],authors:[n.pubkey]});if(!o)return;let s=o.tags.filter(([t,n])=>!(t===e&&n.toLowerCase()===a));await i({kind:10015,content:o.content??``,tags:s,prev:o})},onMutate:t=>{let i=t.toLowerCase().replace(/^#/,``),a=[`interests`,n?.pubkey];return{snapshot:zi(r,a,{kind:10015,pubkey:n?.pubkey??``,transform:t=>t.filter(([t,n])=>!(t===e&&n.toLowerCase()===i))}),key:a}},onError:(e,t,n)=>{n&&Li(r,n.key,n.snapshot)},onSuccess:c}),isLoading:a.isLoading}}function Wp(e,t,n){if(t.filter(e=>e.type===`pubkey`).map(e=>e.value).includes(e.pubkey))return!0;let r=t.filter(e=>e.type===`thread`).map(e=>e.value);if(e.tags.filter(([e,,,t])=>e===`e`&&t!==`mention`||e===`E`).map(([,e])=>e).some(e=>e&&r.includes(e))||r.includes(e.id))return!0;if(n?.skipContentMutes)return!1;let i=t.filter(e=>e.type===`hashtag`).map(e=>e.value.toLowerCase());if(e.tags.filter(([e])=>e===`t`).map(([,e])=>e?.toLowerCase()).filter(e=>!!e).some(e=>i.includes(e)))return!0;let a=t.filter(e=>e.type===`word`).map(e=>e.value.toLowerCase()),o=e.content.toLowerCase();return!!a.some(e=>o.includes(e))}function Gp(){let{config:e}=Nt(),{user:t}=V(),{muteItems:n}=Ir(),{data:r}=Hn(),i=e.exemptFollowsFromFilters===!0,a=r?.pubkeys,o=(0,G.useMemo)(()=>{if(!(!i||!a?.length))return new Set(a)},[i,a]),s=t?.pubkey;return{muteItems:n,isMuted:(0,G.useCallback)(e=>{if(n.length===0)return!1;let t=e.pubkey===s||o?.has(e.pubkey)===!0;return Wp(e,n,{skipContentMutes:t})},[n,o,s])}}var Kp=15,qp=3;async function Jp(e,t,n,r,i){try{return await Tn(e,await t.fetchQuery({queryKey:[`author-write-relays`,n],queryFn:({signal:t})=>Nn(e,n,t),staleTime:600*1e3,gcTime:1800*1e3}),[r],i)}catch{return[]}}function Yp(...e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);return[...t.values()]}var Xp=new Set([34236]);function Zp(e){return Xp.has(e.event.kind)?!0:/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp|svg|mp4|webm|mov)(\?[^\s]*)?/i.test(e.event.content)}function Qp(e,t){switch(t){case`posts`:return e.filter(e=>{let t=e.event;return e.repostedBy||e.reactedBy||e.zappedBy||e.profileZapRecipient?!0:t.kind===1111?!1:(t.kind,!Pi(t))});case`replies`:return e;case`media`:return e.filter(e=>Zp(e));default:return e}}function $p(e,t){switch(t){case`posts`:return e.filter(e=>e!==1111);default:return e}}function em(e,t,n=!0){let{nostr:r}=Ge(),i=ht(),{feedSettings:a}=Aa(),o=$p(Ki(a),t),s=[...o].sort().join(`,`);return Tt({queryKey:[`profile-feed`,e??``,s,t],queryFn:async({pageParam:t,signal:n})=>{if(!e)return{items:[],oldestQueryTimestamp:Math.floor(Date.now()/1e3),rawCount:0};let a=AbortSignal.any([n,AbortSignal.timeout(8e3)]),s=Math.floor(Date.now()/1e3);function c(e){for(let{event:t}of e)i.getQueryData([`event`,t.id])||i.setQueryData([`event`,t.id],t)}let l={kinds:o,authors:[e],limit:Kp*qp};t&&(l.until=t);let[u,d]=await Promise.all([r.query([l],{signal:a}),Jp(r,i,e,l,a)]),f=Yp(u,d).filter(e=>e.created_at<=s),p=ni(f),m=ei(await ri(f.filter(e=>!$r(e)),r,a));return c(m),{items:m,oldestQueryTimestamp:p,rawCount:f.length}},getNextPageParam:e=>{if(e.rawCount!==0)return e.oldestQueryTimestamp-1},initialPageParam:void 0,enabled:!!e&&n,staleTime:30*1e3})}function tm(e,t){let{nostr:n}=Ge(),r=ht();return Tt({queryKey:[`profile-likes-infinite`,e??``],queryFn:async({pageParam:t,signal:i})=>{if(!e)return{events:[],oldestReactionTimestamp:void 0};let a=AbortSignal.any([i,AbortSignal.timeout(8e3)]),o={kinds:[7],authors:[e],limit:Kp};t&&(o.until=t);let[s,c]=await Promise.all([n.query([o],{signal:a}),Jp(n,r,e,o,a)]),l=Yp(s,c);if(l.length===0)return{events:[],oldestReactionTimestamp:void 0};let u=l.sort((e,t)=>t.created_at-e.created_at),d=u[u.length-1].created_at,f=[];for(let e of u){let t=e.tags.findLast(([e])=>e===`e`)?.[1];t&&!f.includes(t)&&f.push(t)}if(f.length===0)return{events:[],oldestReactionTimestamp:d};let p=await n.query([{ids:f,limit:f.length}],{signal:a}),m=new Map(f.map((e,t)=>[e,t]));return{events:p.sort((e,t)=>(m.get(e.id)??999)-(m.get(t.id)??999)),oldestReactionTimestamp:d}},getNextPageParam:e=>{if(!(e.events.length===0||e.oldestReactionTimestamp===void 0))return e.oldestReactionTimestamp-1},initialPageParam:void 0,enabled:!!e&&t,staleTime:30*1e3})}function nm(e,t,n=!0){let{nostr:r}=Ge(),{feedSettings:i}=Aa(),a=Ki(i),o=[...a].sort().join(`,`);return Tt({queryKey:[`tab-feed`,t,e?.kinds?[...e.kinds].sort().join(`,`):o,e?.authors?[...e.authors].sort().join(`,`):``,e?.search??``],queryFn:async({pageParam:t,signal:n})=>{if(!e)return{items:[],oldestQueryTimestamp:Math.floor(Date.now()/1e3),rawCount:0,fetchLimit:Kp};let i=AbortSignal.any([n,AbortSignal.timeout(8e3)]),o=Math.floor(Date.now()/1e3),s={kinds:e.kinds&&e.kinds.length>0?e.kinds:a,limit:Kp};e.authors&&e.authors.length>0&&(s.authors=e.authors),e.search&&(s.search=e.search),t&&(s.until=t);let c=(await r.query([s],{signal:i})).filter(e=>e.created_at<=o),l=ni(c);return{items:ei(await ri(c,r,i)),oldestQueryTimestamp:l,rawCount:c.length,fetchLimit:Kp}},getNextPageParam:e=>{if(!(e.rawCount(i.isPending?null:r?.savedFeeds)??t.savedFeeds??[],[i.isPending,r?.savedFeeds,t.savedFeeds]),s=async e=>{let r=t.savedFeeds??[];n(t=>({...t,savedFeeds:e}));try{await i.mutateAsync({savedFeeds:e})}catch(e){throw n(e=>({...e,savedFeeds:r})),e}};return{savedFeeds:o,isLoading:a,addSavedFeed:async(t,n,r)=>{if(!e)throw Error(`Must be logged in to save feeds`);let i={id:crypto.randomUUID(),label:t.trim(),filter:n,vars:r,createdAt:Date.now()};return await s([...o,i]),i},removeSavedFeed:async t=>{if(!e)throw Error(`Must be logged in to remove feeds`);await s(o.filter(e=>e.id!==t))},renameSavedFeed:async(t,n)=>{if(!e)throw Error(`Must be logged in to rename feeds`);await s(o.map(e=>e.id===t?{...e,label:n.trim()}:e))},updateSavedFeed:async(t,n)=>{if(!e)throw Error(`Must be logged in to update feeds`);await s(o.map(e=>e.id===t?{...e,...n,label:(n.label??e.label).trim(),vars:n.vars??e.vars}:e))},isPending:i.isPending}}var im=16769,am=Fe(Ie(),Pe());function om(e){if(e.kind!==16769)return{tabs:[],vars:[]};let t=[],n=[];for(let r of e.tags)if(r[0]===`tab`&&r.length>=3){let e=r[1];if(!e)continue;try{let n=JSON.parse(r[2]),i=am.safeParse(n);if(!i.success)continue;t.push({label:e,filter:i.data})}catch{}}else if(r[0]===`var`&&r.length>=4){let e=r[1],t=r[2],i=r[3];if(!e?.startsWith(`$`)||!t||!i)continue;n.push({name:e,tagName:t,pointer:i})}return{tabs:t,vars:n}}var sm=`Feed`,cm=`Posts`;function lm(e){return{kinds:[1,6],authors:[e]}}function um(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){if(!(r in t))return!1;let n=e[r],i=t[r];if(Array.isArray(n)&&Array.isArray(i)){if(n.length!==i.length)return!1;let e=n.map(e=>JSON.stringify(e)).sort(),t=i.map(e=>JSON.stringify(e)).sort();if(e.some((e,n)=>e!==t[n]))return!1}else if(JSON.stringify(n)!==JSON.stringify(i))return!1}return!0}function dm(e,t,n){return e.label===n&&um(e.filter,lm(t))}function fm(e,t){return{...e,tabs:e.tabs.map(e=>dm(e,t,`Posts`)?{...e,label:sm}:e)}}function pm(e,t){return{...e,tabs:e.tabs.map(e=>dm(e,t,`Feed`)?{...e,label:cm}:e)}}function mm(e){let t=[[`alt`,`Custom profile tabs`]];for(let n of e.vars)t.push([`var`,n.name,n.tagName,n.pointer]);for(let n of e.tabs)t.push([`tab`,n.label,JSON.stringify(n.filter)]);return t}function hm(e,t){let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(e,r);if(n.startsWith(`e:`))return{type:`e`,id:n.slice(2)};if(n.startsWith(`a:`)){let e=n.slice(2).split(`:`);if(e.length<3)return null;let t=parseInt(e[0],10);return isNaN(t)?null:{type:`a`,kind:t,pubkey:e[1],dTag:e[2]}}return null}function gm(e,t,n){let r={...t};for(let[e,t]of Object.entries(n))e in r||(r[e]=[t]);let i={};for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let e=[];for(let t of n)typeof t==`string`&&t.startsWith(`$`)&&t in r?e.push(...r[t]):e.push(t);i[t]=e}else if(typeof n==`string`&&n.startsWith(`$`)&&n in r){let e=r[n];i[t]=e.length===1?e[0]:e}else i[t]=n;return i}function _m(e,t,n){let{nostr:r}=Ge(),i=(0,G.useMemo)(()=>({$me:n}),[n]),a=At({queries:t.map(e=>{let t=hm(e.pointer,i),a=t?t.type===`e`?{ids:[t.id],limit:1}:{kinds:[t.kind],authors:[t.pubkey],"#d":[t.dTag],limit:1}:null;return{queryKey:[`tab-var`,e.name,e.pointer,n],queryFn:async({signal:t})=>{if(!a)return[];let n=await r.query([a],{signal:AbortSignal.any([t,AbortSignal.timeout(5e3)])});return n.length===0?[]:n[0].tags.filter(([t])=>t===e.tagName).map(([,e])=>e).filter(Boolean)},staleTime:300*1e3,gcTime:600*1e3,enabled:!!t}})}),o=a.some(e=>e.isLoading);return{filter:(0,G.useMemo)(()=>{if(o)return null;let n={};return t.forEach((e,t)=>{let r=a[t]?.data;r&&(n[e.name]=r)}),gm(e,n,i)},[o,t,a,e,i]),isLoading:o}}function vm(){let{nostr:e}=Ge(),{config:t}=Nt(),{store:n}=jn(),r=t.curatorPubkey;return yt({queryKey:[`curator-follow-list`,r],queryFn:async({signal:t})=>{if(!r)return[];let i=await Vn(e,n,r,{signal:t});return[...new Set([r,...Un(i)])]},enabled:!!r,staleTime:600*1e3,gcTime:3600*1e3})}var ym=[20,21,22,34236,36787,34139,36767,37381,3367,37516,7516,30030,30009,10008,30008,31124],bm={kinds:[1063],"#m":[`application/x-webxdc`]};function xm(e){let t=5381;for(let n of e)for(let e=0;e>>0).toString(36)}function Sm(e,t){let{nostr:n}=Ge();return Tt({queryKey:[`ditto-curated-feed`,e?xm(e):``],queryFn:async({pageParam:t,signal:r})=>{let i={kinds:ym,authors:e,limit:20};t&&(i.until=t);let a={...bm,authors:e,limit:20};return t&&(a.until=t),n.group(qn).query([i,a],{signal:AbortSignal.any([r,AbortSignal.timeout(1e4)])})},getNextPageParam:e=>{if(e.length!==0)return e[e.length-1].created_at-1},initialPageParam:void 0,enabled:t&&!!e&&e.length>0,staleTime:300*1e3,gcTime:1800*1e3,placeholderData:e=>e})}function Cm(e,t){let n=(0,G.useRef)([]),r=(0,G.useRef)(t);return r.current!==t&&(r.current=t,n.current=[]),e.length>0?(n.current=e,e):n.current.length>0?n.current:e}var wm={blobbi:.1};function Tm(e){return Yi(e)??`kind-${e}`}function Em(e,t,n){if(e.length===0)return e;let r=n?.minGap??4;return km(Om(e,n?.maxProportion??.2,{...wm,...n?.typeCaps}),r,t)}function Dm(e,t){let n=t?.minGap??4,r=[],i=[];for(let a of e){let e=Em(a,i,t);r.push(...e),i=r.slice(-n).map(e=>Tm(e.event.kind))}return r}function Om(e,t,n){let r=Math.max(1,Math.ceil(e.length*t));function i(t){let i=n[t];return i===void 0?r:Math.max(1,Math.ceil(e.length*i))}let a=new Map,o=[];for(let t of e){let e=Tm(t.event.kind),n=a.get(e)??0;ni)&&a.set(t,r)}function o(e){let n=a.get(e);return n===void 0?!0:r.length-n>=t}function s(e){let t=Tm(e.event.kind);a.set(t,r.length),r.push(e)}for(let n of e)Am(i,r,a,t),o(Tm(n.event.kind))?s(n):i.push(n);for(;;){let e=i.length;if(Am(i,r,a,t),i.length===e)break}return r}function Am(e,t,n,r){for(let i=0;i=r){n.set(o,t.length),t.push(a),e.splice(i,1);break}}}function jm({label:e,active:t,onClick:n,disabled:r,className:i,children:a}){let o=(0,G.useRef)(null),{onHover:s,scrollContainerRef:c}=Na(),{reportSlice:l}=Ma(t,o);return(0,G.useLayoutEffect)(()=>{if(!t)return;let e=o.current,n=c.current;if(e&&n){let t=e.offsetLeft,r=t+e.offsetWidth,i=n.scrollLeft,a=i+n.clientWidth;ta&&n.scrollTo({left:r-n.clientWidth+8,behavior:`smooth`})}},[t]),(0,K.jsx)(`button`,{ref:o,onClick:()=>{s(null),t?window.scrollTo({top:0,behavior:`smooth`}):(window.scrollTo({top:0}),n())},onMouseEnter:()=>{let e=l();e&&s(e)},onMouseLeave:()=>s(null),disabled:r,className:H(`flex-1 flex items-center justify-center py-1.5 text-sm font-medium transition-colors relative px-4 whitespace-nowrap`,t?`text-foreground`:`text-muted-foreground`,r&&`opacity-50 cursor-not-allowed`,i),children:a??e})}function Mm({kinds:e,tagFilters:t,header:n,hideCompose:r,emptyMessage:i,feedId:a=`home`,globalFirst:o,hotGlobal:s}={}){let{user:c}=V(),{config:l}=Nt(),{isMuted:d}=Gp(),{lovedPubkeys:f}=kt(),{savedFeeds:p}=rm(),{hashtags:m}=Up(),{hashtags:h}=Up(`g`),{data:g,isError:_}=vm(),{data:v}=Hn(),{excludeMuted:y}=Ia(),b=Vp(),x=(()=>{let e=localStorage.getItem(Pr(l.appId,`showGlobalFeed`));return e===null?!1:e===`true`})(),S=(()=>{let e=localStorage.getItem(Pr(l.appId,`showDittoFeed`));return e===null?!0:e===`true`})(),C=(()=>{let e=localStorage.getItem(Pr(l.appId,`showCommunityFeed`));return e===null?!1:e===`true`})(),w=(()=>{try{let e=localStorage.getItem(Pr(l.appId,`community`));if(e)return JSON.parse(e).label||`Community`}catch{}return`Community`})(),[T,E]=Hp(a,void 0,o?`global`:void 0),[D,O]=(0,G.useState)(!1),{startSignup:k}=Br(),ee=!!c&&(f?.length??0)>0,A=T===`loved`&&(e||!ee)?c?`follows`:`global`:e?T===`global`?`global`:T===`follows`&&c?`follows`:o?`global`:c?`follows`:`global`:T,j=(0,G.useMemo)(()=>p.find(e=>e.id===A)??null,[p,A]),M=A.startsWith(`hashtag:`)?A.slice(8):null,N=A.startsWith(`geotag:`)?A.slice(7):null,te=!c&&!e,ne=c&&A===`ditto`&&!e,re=A===`follows`||A===`loved`||A===`global`||A===`communities`||A===`ditto`,P=A===`follows`||A===`loved`||A===`global`||A===`communities`?A:`global`,I=Pp(re?P:`global`,e||t?{kinds:e,tagFilters:t,hotGlobal:s}:void 0),L=Sm(g,te||!!ne),R=te||ne,ie=R?L:I,ae=Fa((0,G.useMemo)(()=>R?[`ditto-curated-feed`]:[`feed`,A],[R,A])),{feedSettings:oe}=Aa(),se=(0,G.useMemo)(()=>{if(P===`follows`){let e=y(v?.pubkeys??[]);return c?[...e,c.pubkey]:e}if(P===`loved`)return y(f??[])},[P,v?.pubkeys,f,c,y]),ce=re&&!R&&(P===`follows`||P===`loved`||P===`global`),{newPostCount:le,reset:ue}=Lp({tab:P,authors:se,kinds:e,showReplies:oe.followsFeedShowReplies,enabled:ce}),de=()=>{ue(),ae(),window.scrollTo({top:0,behavior:`smooth`})},{data:fe,isPending:pe,isLoading:me,isFetching:he,isError:_e,fetchNextPage:ve,hasNextPage:ye,isFetchingNextPage:be}=ie;(0,G.useEffect)(()=>{ye&&!be&&fe?.pages?.length===1&&ve()},[ye,be,fe?.pages?.length,ve]);let{ref:xe,inView:Se}=ba({threshold:0,rootMargin:`400px`});(0,G.useEffect)(()=>{Se&&ye&&!be&&ve()},[Se,ye,be,ve]);let Ce=Cm((0,G.useMemo)(()=>{if(!fe?.pages)return[];let e=new Set;return R?Dm(fe.pages.map(t=>t.filter(t=>!(e.has(t.id)||(e.add(t.id),$r(t))||d(t))).map(e=>({event:e,sortTimestamp:e.created_at})))):fe.pages.flatMap(e=>e.items).filter(t=>{let n=Zr(t);return!(!n||e.has(n)||(e.add(n),$r(t.event))||d(t.event))})},[fe?.pages,d,R]),`${c?.pubkey??``}:${R?`ditto`:A}`),we=(pe||me&&!fe)&&!(R&&_),Te=!!e,Ee=c&&!Te&&!t,De=A===`follows`&&v?.pubkeys.length===0,Oe=(()=>{if(i)return{message:i,onRetry:ae,isRetrying:he,isOffline:!b};if(De)return{message:`Your feed is empty. Follow some people to see their posts here.`,showDiscover:!0,onSwitchToGlobal:x?()=>E(`global`):void 0};let e=A===`follows`,t=A===`loved`;return{message:b?_e?e?`Something went wrong loading posts from people you follow.`:t?`Something went wrong loading posts from the people you love.`:`Something went wrong loading the feed.`:e?`We couldn't find any recent posts from people you follow.`:t?`No recent posts from the people you love. Add more people from their profile's ⋯ menu.`:`No posts found. Check your relay connections or come back soon.`:e?`We couldn't load posts from people you follow.`:t?`We couldn't load posts from the people you love.`:`We couldn't load the feed.`,onRetry:ae,isRetrying:he,isOffline:!b,onSwitchToGlobal:e&&x?()=>E(`global`):void 0}})();return(0,K.jsxs)(`main`,{className:`flex-1 min-w-0 min-h-dvh`,children:[!c&&!e&&(0,K.jsx)(vp,{onLoginClick:()=>O(!0),onSignupClick:k}),!r&&(0,K.jsx)(Ei,{compact:!0,hideBorder:!0}),n,c&&(0,K.jsxs)(Pa,{children:[o&&(0,K.jsx)(jm,{label:`All`,active:A===`global`,onClick:()=>E(`global`)}),!Te&&ee&&(0,K.jsx)(jm,{label:`Loved`,active:A===`loved`,onClick:()=>E(`loved`),children:(0,K.jsxs)(`span`,{className:`flex items-center justify-center gap-1`,children:[(0,K.jsx)(u,{className:H(`size-3.5`,A===`loved`&&`fill-red-500 text-red-500`)}),`Loved`]})}),(0,K.jsx)(jm,{label:`Follows`,active:A===`follows`,onClick:()=>E(`follows`)}),!Te&&S&&(0,K.jsx)(jm,{label:l.appName,active:A===`ditto`,onClick:()=>E(`ditto`)}),!Te&&C&&(0,K.jsx)(jm,{label:w,active:A===`communities`,onClick:()=>E(`communities`)}),!o&&(Te||x)&&(0,K.jsx)(jm,{label:`Global`,active:A===`global`,onClick:()=>E(`global`)}),Ee&&p.map(e=>(0,K.jsx)(jm,{label:e.label,active:A===e.id,onClick:()=>E(e.id)},e.id)),Ee&&m.map(e=>(0,K.jsx)(jm,{label:`#${e}`,active:A===`hashtag:${e}`,onClick:()=>E(`hashtag:${e}`)},`hashtag:${e}`)),Ee&&h.map(e=>(0,K.jsx)(jm,{label:e,active:A===`geotag:${e}`,onClick:()=>E(`geotag:${e}`),children:(0,K.jsxs)(`span`,{className:`flex items-center justify-center gap-1`,children:[(0,K.jsx)(ge,{className:`size-3.5`}),e]})},`geotag:${e}`))]}),c&&(0,K.jsx)(`div`,{style:{height:20}}),M?(0,K.jsx)(Pm,{tag:M}):N?(0,K.jsx)(Fm,{tag:N}):j?(0,K.jsx)(Nm,{feed:j}):(0,K.jsxs)(kp,{onRefresh:ae,children:[(0,K.jsx)(In,{count:le,onClick:de}),Ce.length>0?(0,K.jsxs)(`div`,{children:[Ce.map((e,t)=>(0,K.jsx)(Tp,{className:`cv-feed-item`,initialInView:t<10,children:(0,K.jsx)(Ca,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient})},Zr(e))),ye&&(0,K.jsx)(`div`,{ref:xe,className:`py-4`,children:be&&(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(F,{className:`size-5 animate-spin text-muted-foreground`})})})]}):we?(0,K.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,K.jsx)(Im,{},t))}):(0,K.jsx)(Ap,{...Oe})]}),!e&&(0,K.jsx)(Vr,{isOpen:D,onClose:()=>O(!1),onLogin:()=>O(!1),onSignupClick:k})]})}function Nm({feed:e}){let{ref:t,inView:n}=ba({threshold:0,rootMargin:`400px`}),{user:r}=V(),{isMuted:i}=Gp(),{filter:a,isLoading:o}=_m(e.filter,e.vars??[],r?.pubkey??``),{data:s,isLoading:c,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:d}=nm((0,G.useMemo)(()=>{if(!a)return null;let e=a.search??``,t=e.includes(`protocol:nostr`)?e:e?`${e} protocol:nostr`:`protocol:nostr`;return{...a,search:t}},[a]),`saved-${e.id}`,!o),f=o||c,p=Fa((0,G.useMemo)(()=>[`tab-feed`,`saved-${e.id}`],[e.id]));(0,G.useEffect)(()=>{n&&u&&!d&&l()},[n,u,d,l]);let m=Cm((0,G.useMemo)(()=>{if(!s?.pages)return[];let e=new Set;return s.pages.flatMap(e=>e.items).filter(t=>{let n=Zr(t);return!(!n||e.has(n)||(e.add(n),$r(t.event))||i(t.event))})},[s?.pages,i]),`${r?.pubkey??``}:${e.id}`);return f&&m.length===0?(0,K.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,K.jsx)(Im,{},t))}):m.length===0?(0,K.jsx)(kp,{onRefresh:p,children:(0,K.jsx)(Ap,{message:`No posts found for "${e.label}". Try adjusting your relay connections or check back later.`})}):(0,K.jsx)(kp,{onRefresh:p,children:(0,K.jsxs)(`div`,{children:[m.map((e,t)=>(0,K.jsx)(Tp,{className:`cv-feed-item`,initialInView:t<10,children:(0,K.jsx)(Ca,{event:e.event,repostedBy:e.repostedBy,repostEvent:e.repostEvent,reactedBy:e.reactedBy,zappedBy:e.zappedBy,profileZapRecipient:e.profileZapRecipient})},Zr(e))),u&&(0,K.jsx)(`div`,{ref:t,className:`py-4`,children:d&&(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(F,{className:`size-5 animate-spin text-muted-foreground`})})}),!u&&(0,K.jsx)(`div`,{ref:t,className:`py-2`})]})})}function Pm({tag:e}){let{nostr:t}=Ge(),{isMuted:n}=Gp(),{feedSettings:r}=Aa(),i=Ki(r).filter(e=>!ti(e)),a=[...i].sort().join(`,`),o=(0,G.useMemo)(()=>[`hashtag-feed`,e,a],[e,a]),s=Fa(o),{data:c,isLoading:l}=yt({queryKey:o,queryFn:async({signal:n})=>t.group(qn).query([{kinds:i,"#t":[e.toLowerCase()],limit:40}],{signal:AbortSignal.any([n,AbortSignal.timeout(1e4)])})}),u=Cm((0,G.useMemo)(()=>c?c.filter(e=>!n(e)):[],[c,n]),e);return l&&u.length===0?(0,K.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,K.jsx)(Im,{},t))}):u.length===0?(0,K.jsx)(kp,{onRefresh:s,children:(0,K.jsx)(Ap,{message:`No posts found with #${e}.`})}):(0,K.jsx)(kp,{onRefresh:s,children:(0,K.jsx)(`div`,{children:u.map((e,t)=>(0,K.jsx)(Tp,{className:`cv-feed-item`,initialInView:t<10,children:(0,K.jsx)(Ca,{event:e})},e.id))})})}function Fm({tag:e}){let{nostr:t}=Ge(),{isMuted:n}=Gp(),{feedSettings:r}=Aa(),i=Ki(r).filter(e=>!ti(e)),a=[...i].sort().join(`,`),o=(0,G.useMemo)(()=>[`geotag-feed`,e,a],[e,a]),s=Fa(o),{data:c,isLoading:l}=yt({queryKey:o,queryFn:async({signal:n})=>{let r=t.group(qn),a={kinds:i,limit:40};return a[`#g`]=[e],r.query([a],{signal:AbortSignal.any([n,AbortSignal.timeout(1e4)])})}}),u=Cm((0,G.useMemo)(()=>c?c.filter(e=>!n(e)):[],[c,n]),e);return l&&u.length===0?(0,K.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,K.jsx)(Im,{},t))}):u.length===0?(0,K.jsx)(kp,{onRefresh:s,children:(0,K.jsx)(Ap,{message:`No posts found near ${e}.`})}):(0,K.jsx)(kp,{onRefresh:s,children:(0,K.jsx)(`div`,{children:u.map((e,t)=>(0,K.jsx)(Tp,{className:`cv-feed-item`,initialInView:t<10,children:(0,K.jsx)(Ca,{event:e})},e.id))})})}function Im(){return(0,K.jsxs)(`div`,{className:`px-4 py-3 border-b border-border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(kr,{className:`size-11 rounded-full shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,K.jsx)(kr,{className:`h-4 w-28`}),(0,K.jsx)(kr,{className:`h-3 w-36`})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,K.jsx)(kr,{className:`h-4 w-full`}),(0,K.jsx)(kr,{className:`h-4 w-4/5`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-6 mt-3 -ml-2`,children:[(0,K.jsx)(kr,{className:`h-4 w-8`}),(0,K.jsx)(kr,{className:`h-4 w-8`}),(0,K.jsx)(kr,{className:`h-4 w-8`}),(0,K.jsx)(kr,{className:`h-4 w-8`})]})]})}var Lm=()=>{let{config:e}=Nt(),{user:t}=V();return hp({title:e.appName,description:`Your content. Your vibe. Your rules.`}),va({showFAB:!0,fabKind:1,hasSubHeader:!!t}),(0,K.jsx)(Mm,{})},Rm=()=>{let e=lr(),{config:t}=Nt();return hp({title:`404 - Page Not Found | ${t.appName}`,description:`The page you are looking for could not be found.`}),(0,G.useEffect)(()=>{console.error(`404 Error: User attempted to access non-existent route:`,e.pathname)},[e.pathname]),(0,K.jsx)(`main`,{className:`flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`text-center px-8`,children:[(0,K.jsx)(`h1`,{className:`text-6xl font-bold mb-4 text-primary`,children:`404`}),(0,K.jsx)(`p`,{className:`text-xl text-muted-foreground mb-6`,children:`This page doesn't exist.`}),(0,K.jsx)(or,{to:`/`,className:`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground px-6 py-2.5 font-bold hover:bg-primary/90 transition-colors`,children:`Go home`})]})})},zm=(0,G.lazy)(()=>z(()=>import(`./companion-BH2LoWmw.js`).then(e=>({default:e.BlobbiCompanionLayer})),__vite__mapDeps([131,3,4,15,5,31,32,33,34,40,41,1,8,44,38,36,70,107,6,108,109,125,37,39,132,133,119,134,135,52,136,137,138,139]))),Bm=31124;function Vm(){let{user:e}=V(),{nostr:t}=Ge(),{pathname:n}=lr(),r=n===`/blobbi`||n.startsWith(`/blobbi/`),{data:i}=yt({queryKey:[`blobbi`,`has-companion`,e?.pubkey],enabled:!!e&&!r,staleTime:6e4,queryFn:async n=>(await t.query([{kinds:[Bm],authors:[e.pubkey],limit:1}],{signal:AbortSignal.any([n.signal,AbortSignal.timeout(5e3)])})).length>0});return!e||!(r||i)?null:(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(zm,{})})}var Hm=(0,G.lazy)(()=>z(()=>import(`./EmbeddedPost-DITW2flc.js`).then(e=>e.f).then(e=>({default:e.ReplyComposeModal})),__vite__mapDeps([62,3,4,15,5,41,31,32,33,34,38,63,64,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,45,48,54,56,57,121,27,122,123,124,125,126,59,127,128]))),Um=(0,G.lazy)(()=>z(()=>import(`./EmojiPacksPage-U7yj16V_.js`).then(e=>({default:e.EmojiPacksPage})),__vite__mapDeps([140,3,4,5,41,31,32,33,141,34,36,40,1,7,8,9,10,11,78,39,44,38,67,73,71,82,106,107,6,108,109,115,142,15,64,63,35,37,42,43,65,66,68,69,70,72,74,75,76,77,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,116,117,118,54,56,48,143,45,144,26,121,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178]))),Wm=(0,G.lazy)(()=>z(()=>import(`./HomePage-De2EtDwq.js`).then(e=>({default:e.HomePage})),__vite__mapDeps([179,3,4,5,41,36,40,31,32,33,34,1,70,74,75,67,76,106,107,6,108,109]))),Gm=(0,G.lazy)(()=>z(()=>import(`./AdvancedSettingsPage-CWHWhqVO.js`).then(e=>({default:e.AdvancedSettingsPage})),__vite__mapDeps([180,3,4,5,36,37,31,32,33,34,38,39,40,41,1,6,120,7,8,9,10,11,45,46,47,16,17,20,21,15,22,23,50,148,25,26,149,18,27,28,51,52,181,182,94,164,150,14,19,12,174,70,183,55,56,29,184,102,13,49,155,151,185,173]))),Km=(0,G.lazy)(()=>z(()=>import(`./AIChatPage-DMXptGBZ.js`).then(e=>({default:e.AIChatPage})),__vite__mapDeps([186,3,4,5,36,35,34,37,31,32,33,38,39,40,41,1,42,43,44,8,7,9,10,11,49,115,130,16,18,20,21,15,22,26,29,166,167,187,174,70,183,17,55,25,19,23,56,12,28]))),qm=(0,G.lazy)(()=>z(()=>import(`./ArchivePage-DJYP4fd5.js`).then(e=>({default:e.ArchivePage})),__vite__mapDeps([188,3,4,5,36,8,70,41,45,82]))),Jm=(0,G.lazy)(()=>z(()=>import(`./ArticleEditorPage-D4pDpdea.js`).then(e=>({default:e.ArticleEditorPage})),__vite__mapDeps([189,3,4,5,31,32,33,34,38,40,41,1,8,7,9,10,11,44,36,70,45,54,15,16,17,55,18,25,19,23,56,12,48,57,58,88,13,14,20,21,22,49,99,115,123,170,155,50,150,151,167,190]))),Ym=(0,G.lazy)(()=>z(()=>import(`./BadgesPage-CdfG-8k3.js`).then(e=>({default:e.BadgesPage})),__vite__mapDeps([191,3,4,5,31,32,33,34,38,141,36,40,41,1,8,7,9,10,11,44,78,39,67,70,77,15,43,69,71,72,73,74,75,76,16,17,55,18,25,19,79,80,52,81,45,144,23,26,56,12,48,82,57,58,13,14,20,21,22,49,92,115,142,64,63,35,37,42,6,65,66,68,46,47,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,116,117,118,54,143,121,145,62,119,120,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,169,170,172,192,174,193,194,175,176]))),Xm=(0,G.lazy)(()=>z(()=>import(`./BlobbiPage-BLGQm_rC.js`).then(e=>({default:e.BlobbiPage})),__vite__mapDeps([195,3,4,15,5,31,32,33,34,38,119,36,43,1,66,41,65,39,40,8,7,9,10,11,44,70,76,52,45,54,16,17,55,18,25,19,23,56,12,48,82,57,58,13,14,20,21,22,89,115,170,154,155,50,51,28,151,130,26,29,132,133,134,135,136,137,138,139,196,197,198,199,24,27,183]))),Zm=(0,G.lazy)(()=>z(()=>import(`./BlueskyPage-BfCZNpiE.js`).then(e=>({default:e.BlueskyPage})),__vite__mapDeps([200,3,4,5,34,141,36,40,41,31,32,33,1,8,70,45,54,15,10,16,17,55,18,25,19,23,56,12,48,82,109,62,38,63,64,35,37,39,42,43,44,6,65,66,7,9,11,67,68,69,71,72,73,74,75,76,77,78,79,80,52,81,46,47,20,21,22,83,58,84,85,86,87,88,13,14,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,110,111,112,113,114,115,116,117,118,119,120,57,121,27,122,123,124,125,126,59,127,128]))),Qm=(0,G.lazy)(()=>z(()=>import(`./BookmarksPage-OZO0MFoB.js`).then(e=>({default:e.BookmarksPage})),__vite__mapDeps([201,4,3,5,36,40,41,31,32,33,34,1,82,8,142,15,64,38,63,35,37,39,42,43,44,6,65,66,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,54,56,48,143,45,144,26,121,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,171,174]))),$m=(0,G.lazy)(()=>z(()=>import(`./BooksPage-pnYcOWfe.js`).then(e=>({default:e.BooksPage})),__vite__mapDeps([202,3,4,5,31,32,33,34,141,63,15,64,41,38,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,45,62,119,120,48,54,56,57,121,27,122,123,124,125,126,59,127,128,146,147,49,50,148,26,149,28,150,151,130,29,152,170,171,155,161,162,165,168,172,174,175,176,203,177]))),eh=(0,G.lazy)(()=>z(()=>import(`./ChangelogPage-DNsJi6Gj.js`).then(e=>({default:e.ChangelogPage})),__vite__mapDeps([204,3,4,5,36,82,8,88,15,10,16,17,55,18,25,19,23,115,174,70,41]))),th=(0,G.lazy)(()=>z(()=>import(`./ClientFeedPage-CdkSMTZR.js`).then(e=>({default:e.ClientFeedPage})),__vite__mapDeps([205,3,4,5,36,70,41,121,32,33,8,67,31,86,34,71,85,87,14,15,10,9,16,17,18,19,20,21,22,23,12,13,106,107,6,108,109,125,37,38,39,40,1,206,94,54,55,25,56,48,82,207,173,174]))),nh=(0,G.lazy)(()=>z(()=>import(`./ContentPage-D8R_pUZs.js`).then(e=>({default:e.ContentPage})),__vite__mapDeps([208,3,4,5,31,32,33,34,36,6,40,41,1,8,7,9,10,11,44,38,82,147,39,67,84,13,14,15,16,17,18,19,20,21,22,23,12,130,26,29,209,70,54,55,25,56,48,192,174,210,37,69,45,106,107,108,109,125,155,50,148,149,27,28,51,52,151,152,92,95,183,211,47,212]))),rh=(0,G.lazy)(()=>z(()=>import(`./ContentSettingsPage-CnN2hcDR.js`).then(e=>({default:e.ContentSettingsPage})),__vite__mapDeps([213,5,3,36,4,6,209,70,41,54,15,8,10,16,17,55,18,25,19,23,56,12,48,192,174,210,32,33,37,31,34,38,39,40,1,7,9,11,69,45,82,84,147,44,67,13,14,20,21,22,106,107,108,109,125,155,50,148,26,149,27,28,51,52,151,152,92,95,183,29,211,47,212]))),ih=(0,G.lazy)(()=>z(()=>import(`./CSAEPolicyPage-D27zM5-U.js`).then(e=>({default:e.CSAEPolicyPage})),__vite__mapDeps([214,4,3,5,36,115,174,8,70,41]))),ah=(0,G.lazy)(()=>z(()=>import(`./DataSettingsPage-CCIji56I.js`).then(e=>({default:e.DataSettingsPage})),__vite__mapDeps([215,3,4,5,31,32,33,36,43,6,66,41,1,65,40,34,8,7,9,10,11,94,69,70,54,15,16,17,55,18,25,19,23,56,12,48,85,67,13,14,20,21,22,96,155,159,50,51,52,28,130,26,29,174]))),oh=(0,G.lazy)(()=>z(()=>import(`./DomainFeedPage-ayXHWaHW.js`).then(e=>({default:e.DomainFeedPage})),__vite__mapDeps([216,3,4,5,31,32,33,34,36,70,41,79,8,82,121,67,86,71,85,87,14,15,10,9,16,17,18,19,20,21,22,23,12,13,106,107,6,108,109,142,64,38,63,35,37,39,40,1,42,43,44,65,66,7,11,68,69,72,73,74,75,76,77,78,55,25,80,52,81,46,47,83,58,84,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,115,116,117,118,54,56,48,143,45,144,26,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,171,174]))),sh=(0,G.lazy)(()=>z(()=>import(`./EventsFeedPage-BxuEi6vA.js`).then(e=>({default:e.EventsFeedPage})),__vite__mapDeps([217,3,4,5,36,40,41,31,32,33,34,1,82,8,106,107,6,108,109,115,142,15,64,38,63,35,37,39,42,43,44,65,66,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,116,117,118,54,56,48,143,45,144,26,121,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,170,171,174,175,177]))),ch=(0,G.lazy)(()=>z(()=>import(`./ExternalContentPage-DlkSaAyY.js`).then(e=>e.t).then(e=>({default:e.ExternalContentPage})),__vite__mapDeps([218,3,4,5,31,32,33,34,38,63,15,64,41,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,45,144,26,56,48,121,49,62,119,120,54,57,27,122,123,124,125,126,59,127,128,142,143,145,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,170,203]))),lh=(0,G.lazy)(()=>z(()=>import(`./GeotagPage-DKjW_4RP.js`).then(e=>({default:e.GeotagPage})),__vite__mapDeps([219,4,3,5,36,70,41,220,31,32,33,34,40,1,7,8,9,10,11,94,82,121,67,86,71,85,87,14,15,16,17,18,19,20,21,22,23,12,13,106,107,6,108,109,142,64,38,63,35,37,39,42,43,44,65,66,68,69,72,73,74,75,76,77,78,55,25,79,80,52,81,46,47,83,58,84,88,89,90,91,92,93,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,115,116,117,118,54,56,48,143,45,144,26,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,171,174]))),uh=(0,G.lazy)(()=>z(()=>import(`./HashtagPage-DZBUjooO.js`).then(e=>({default:e.HashtagPage})),__vite__mapDeps([221,5,3,36,4,70,41,220,31,32,33,34,40,1,7,8,9,10,11,94,82,121,67,86,71,85,87,14,15,16,17,18,19,20,21,22,23,12,13,106,107,6,108,109,142,64,38,63,35,37,39,42,43,44,65,66,68,69,72,73,74,75,76,77,78,55,25,79,80,52,81,46,47,83,58,84,88,89,90,91,92,93,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,115,116,117,118,54,56,48,143,45,144,26,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,171,174]))),dh=(0,G.lazy)(()=>z(()=>import(`./HelpPage-se4YD6Fh.js`).then(e=>({default:e.HelpPage})),__vite__mapDeps([222,3,4,5,31,32,33,36,7,8,9,10,11,78,34,39,40,41,1,44,38,67,69,70,82,83,115,192,174,211,16,17,20,21,15,23,47,22,26,27,223,144,55,18,25,19,56,12,48,147,84,150,14]))),fh=(0,G.lazy)(()=>z(()=>import(`./KindFeedPage-CJY6q1zV.js`).then(e=>({default:e.KindFeedPage})),__vite__mapDeps([224,3,4,5,36,40,41,31,32,33,34,1,106,107,6,108,109,115,174,8,70,177,7,9,10,11,79,13,14,15,16,17,18,19,20,21,22,23,12]))),ph=(0,G.lazy)(()=>z(()=>import(`./LetterComposePage-DmfXfGM_.js`).then(e=>({default:e.LetterComposePage})),__vite__mapDeps([225,3,4,5,32,33,34,35,36,37,31,38,39,40,41,1,42,43,44,68,69,8,70,73,71,52,82,13,14,15,10,9,16,17,18,19,20,21,22,23,12,91,115,117,81,67,170,130,26,29,226,227,228,78,51,25,28,172,147,84,183,55,56,229,136]))),mh=(0,G.lazy)(()=>z(()=>import(`./LetterPreferencesPage-Btj1k7OR.js`).then(e=>({default:e.LetterPreferencesPage})),__vite__mapDeps([230,3,4,5,36,40,41,31,32,33,34,1,7,8,9,10,11,68,42,43,70,170,115,51,16,17,25,52,20,21,15,28,227,37,38,39,228,35,44,78,67,82,13,14,18,19,22,23,12,91,172,147,84,183,55,26,56,29,226]))),hh=(0,G.lazy)(()=>z(()=>import(`./LettersPage-CxVo42ey.js`).then(e=>({default:e.LettersPage})),__vite__mapDeps([231,3,4,5,40,41,31,32,33,34,1,7,8,9,10,11,78,39,44,38,36,67,70,107,6,108,109,115,170,172,147,84,174,227,37,232,141,35,42,43,68,13,14,15,16,17,18,19,20,21,22,23,12,91,146,63,64,65,66,69,71,72,73,74,75,76,77,55,25,79,80,52,81,46,47,82,83,58,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,110,111,112,113,114,116,117,118,45,49,62,119,120,48,54,56,57,121,27,122,123,124,125,126,59,127,128,50,148,26,149,28,150,151,130,29,152,156,226,229,136]))),gh=(0,G.lazy)(()=>z(()=>import(`./MagicSettingsPage-CmOviiY0.js`).then(e=>({default:e.MagicSettingsPage})),__vite__mapDeps([233,5,3,36,4,6,50,8,11,21,15,9,10,51,16,17,25,52,41,1,20,28,174,70]))),_h=(0,G.lazy)(()=>z(()=>import(`./MemoryCardsPage-DGz2KY0V.js`).then(e=>({default:e.MemoryCardsPage})),__vite__mapDeps([234,3,4,5,31,32,33,34,36,43,66,41,1,65,40,8,7,9,10,11,44,38,67,78,39,69,70,45,82,85,13,14,15,16,17,18,19,20,21,22,23,12,90,97,106,107,6,108,109,115,170,50,174,177,79]))),vh=(0,G.lazy)(()=>z(()=>import(`./MusicPage-fgpGLZNe.js`).then(e=>({default:e.MusicPage})),__vite__mapDeps([235,3,4,5,31,32,33,34,141,36,43,40,41,1,8,67,78,39,44,38,94,69,70,74,75,76,81,82,145,6,65,7,9,10,11,112,58,90,106,107,108,109,113,115,116,170,127,172,147,84,174,177,79,13,14,15,16,17,18,19,20,21,22,23,12,236]))),yh=(0,G.lazy)(()=>z(()=>import(`./NetworkSettingsPage-DezXkJNZ.js`).then(e=>({default:e.NetworkSettingsPage})),__vite__mapDeps([237,3,4,5,36,37,31,32,33,34,38,39,40,41,1,6,8,7,9,10,11,44,94,69,70,45,54,15,16,17,55,18,25,19,23,56,12,48,58,88,155,159,50,21,51,52,20,28,209,192,174]))),bh=(0,G.lazy)(()=>z(()=>import(`./NIP19Page-DcS1jRRH.js`).then(e=>({default:e.NIP19Page})),__vite__mapDeps([238,3,4,15,75,34,5,67,31,32,33,64,41,38,141,63,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,68,69,70,71,72,73,74,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,45,144,26,56,48,54,143,147,57,121,145,49,62,120,27,122,123,124,125,126,59,127,128,142,146,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,169,170,172,132,53,239,240,241,206,207,173,174,183,193,203,212,178,218,223,236,242,243,244,245,246]))),xh=(0,G.lazy)(()=>z(()=>import(`./NotificationSettings-CnQ_u9eZ.js`).then(e=>({default:e.NotificationSettings})),__vite__mapDeps([247,3,4,5,32,33,36,37,31,34,38,39,40,41,1,6,7,8,9,10,11,70,50,21,15,148,16,17,25,20,22,26,149,18,23,27,28,51,52,174]))),Sh=(0,G.lazy)(()=>z(()=>import(`./NotificationsPage-BI3BQ3K3.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([248,3,4,5,31,32,33,34,141,63,15,64,41,38,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,121,62,119,120,45,48,54,56,57,27,122,123,124,125,126,59,127,128,142,143,144,26,145,49,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,169,170,232,226,229,136]))),Ch=(0,G.lazy)(()=>z(()=>import(`./PhotosFeedPage-BJJpDi4r.js`).then(e=>({default:e.PhotosFeedPage})),__vite__mapDeps([249,3,4,5,41,36,40,31,32,33,34,1,58,106,107,6,108,109,115,170,8,171,168,141,94,174,70,175,116,177,7,9,10,11,79,13,14,15,16,17,18,19,20,21,22,23,12,243,63,64,38,35,37,39,42,43,44,65,66,67,68,69,71,72,73,74,75,76,77,78,55,25,80,52,81,46,47,82,83,84,85,86,87,88,89,90,91,92,93,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,117,118,157,244,146,45,147,49,62,119,120,48,54,56,57,121,27,122,123,124,125,126,59,127,128,50,148,26,149,28,150,151,130,29,152,162,165,245]))),wh=(0,G.lazy)(()=>z(()=>import(`./PodcastsFeedPage-XJjMU1Nx.js`).then(e=>({default:e.PodcastsFeedPage})),__vite__mapDeps([250,5,3,106,4,107,6,108,109,224,36,40,41,31,32,33,34,1,115,174,8,70,177,7,9,10,11,79,13,14,15,16,17,18,19,20,21,22,23,12]))),Th=(0,G.lazy)(()=>z(()=>import(`./PrivacyPolicyPage-DfPfWknQ.js`).then(e=>({default:e.PrivacyPolicyPage})),__vite__mapDeps([251,4,3,5,36,115,174,8,70,41]))),Eh=(0,G.lazy)(()=>z(()=>import(`./ProfileSettings-cWB1AMJt.js`).then(e=>({default:e.ProfileSettings})),__vite__mapDeps([252,3,4,5,31,32,33,34,36,6,253,41,1,66,65,43,39,40,8,9,10,7,11,44,38,69,70,45,46,47,16,17,20,21,15,22,23,144,55,18,25,19,26,56,12,48,143,77,67,78,71,72,73,74,75,76,79,80,52,81,54,82,57,58,88,115,126,50,51,28,2,13,14,24,27,29,209,192,254,92,101,102,241,174,183,194,242,63,64,35,37,42,68,83,84,85,86,87,89,90,91,93,94,95,96,97,98,99,100,103,104,105,106,107,108,109,110,111,112,113,114,116,117,118,119,157,243]))),Dh=(0,G.lazy)(()=>z(()=>import(`./RelayPage-CMC8280U.js`).then(e=>({default:e.RelayPage})),__vite__mapDeps([255,3,4,5,31,32,33,34,36,70,41,82,8,121,67,86,71,85,87,14,15,10,9,16,17,18,19,20,21,22,23,12,13,106,107,6,108,109,115,142,64,38,63,35,37,39,40,1,42,43,44,65,66,7,11,68,69,72,73,74,75,76,77,78,55,25,79,80,52,81,46,47,83,58,84,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,110,111,112,113,114,116,117,118,54,56,48,143,45,144,26,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,170,174]))),Oh=(0,G.lazy)(()=>z(()=>import(`./SearchPage-BlgCFvFy.js`).then(e=>({default:e.SearchPage})),__vite__mapDeps([256,3,4,5,31,32,33,34,36,40,41,1,8,257,37,38,39,115,67,78,44,94,69,70,73,71,45,54,15,10,16,17,55,18,25,19,23,56,12,48,82,121,86,85,87,14,9,20,21,22,13,62,63,64,35,42,43,6,65,66,7,11,68,72,74,75,76,77,79,80,52,81,46,47,83,58,84,88,89,90,91,92,93,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,116,117,118,119,120,57,27,122,123,124,125,126,59,127,128,142,143,144,26,145,49,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,170,172,209,192,174,183,212,246]))),kh=(0,G.lazy)(()=>z(()=>import(`./SettingsPage-wzcKruPh.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([258,3,4,5,41,36,6,40,31,32,33,34,1,70,115,174,8]))),Ah=(0,G.lazy)(()=>z(()=>import(`./SharePage-BKckwPDb.js`).then(e=>({default:e.SharePage})),__vite__mapDeps([259,3,4,5,70,41,62,15,31,32,33,34,38,63,64,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,45,48,54,56,57,121,27,122,123,124,125,126,59,127,128]))),jh=(0,G.lazy)(()=>z(()=>import(`./ThemesPage-CF4nSA77.js`).then(e=>({default:e.ThemesPage})),__vite__mapDeps([260,3,4,5,31,32,33,141,34,36,35,37,38,39,40,41,1,42,43,44,78,67,82,8,115,142,15,64,63,6,65,66,7,9,10,11,68,69,70,71,72,73,74,75,76,77,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,116,117,118,54,56,48,143,45,144,26,121,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,169,170,171,172,30,53,174,175,176]))),Mh=(0,G.lazy)(()=>z(()=>import(`./TreasuresPage-BByQ-acA.js`).then(e=>({default:e.TreasuresPage})),__vite__mapDeps([261,5,3,106,4,107,6,108,109,125,36,37,31,32,33,34,38,39,40,41,1,224,115,174,8,70,177,7,9,10,11,79,13,14,15,16,17,18,19,20,21,22,23,12]))),Nh=(0,G.lazy)(()=>z(()=>import(`./QuizzesPage-ClDF0_zI.js`).then(e=>({default:e.QuizzesPage})),__vite__mapDeps([262,5,3,106,4,107,6,108,109,125,36,37,31,32,33,34,38,39,40,41,1,224,115,174,8,70,177,7,9,10,11,79,13,14,15,16,17,18,19,20,21,22,23,12]))),Ph=(0,G.lazy)(()=>z(()=>import(`./CreateQuizPage-BK-AMC86.js`).then(e=>({default:e.CreateQuizPage})),__vite__mapDeps([263,3,4,5,31,32,33,40,41,34,1,8,7,9,10,11,44,38,36,70,45,57,58,85,67,49,105,43,115,50,21,15,173,183,16,17,55,18,25,19,23,26,56,12,28,29,190]))),Fh=(0,G.lazy)(()=>z(()=>import(`./TrendsPage-CTluRsDQ.js`).then(e=>({default:e.TrendsPage})),__vite__mapDeps([264,3,4,5,36,8,82,116,142,15,64,41,31,32,33,34,38,63,35,37,39,40,1,42,43,44,6,65,66,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,117,118,54,56,48,143,45,144,26,121,145,49,62,119,120,57,27,122,123,124,125,126,59,127,128,146,147,50,148,149,28,150,151,130,29,152,153,154,155,156,157,158,159,160,161,51,162,163,164,165,166,167,168,141,169,171,265,207,173,174]))),Ih=(0,G.lazy)(()=>z(()=>import(`./UserListsPage--HgkTA_I.js`).then(e=>({default:e.UserListsPage})),__vite__mapDeps([266,3,4,5,32,33,36,40,41,31,34,1,7,8,9,10,11,69,70,45,82,13,14,15,16,17,18,19,20,21,22,23,12,150,152,38,39,44,67,92,95,174]))),Lh=(0,G.lazy)(()=>z(()=>import(`./VideosFeedPage-CmAi78FQ.js`).then(e=>({default:e.VideosFeedPage})),__vite__mapDeps([267,3,4,5,31,32,33,34,63,15,64,41,38,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,170,171,157,158,161,168,141,172,147,174,177,268,121,146,45,49,62,119,120,48,54,56,57,27,122,123,124,125,126,59,127,128,50,148,26,149,28,150,151,130,29,152,162,169,245]))),Rh=(0,G.lazy)(()=>z(()=>import(`./VinesFeedPage-x_0HGxDm.js`).then(e=>({default:e.VinesFeedPage})),__vite__mapDeps([268,3,4,5,31,32,33,34,63,15,64,41,38,36,35,37,39,40,1,42,43,44,6,65,66,8,7,9,10,11,67,68,69,70,71,72,73,74,75,76,77,78,16,17,55,18,25,19,79,80,52,81,46,47,20,21,22,23,82,83,58,84,85,86,87,88,13,14,12,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,121,146,45,147,49,62,119,120,48,54,56,57,27,122,123,124,125,126,59,127,128,50,148,26,149,28,150,151,130,29,152,157,162,168,141,169,172,177,245]))),zh=(0,G.lazy)(()=>z(()=>import(`./WalletPage-BrKsD0N_.js`).then(e=>({default:e.WalletPage})),__vite__mapDeps([269,3,4,75,34,5,67,31,32,33,41,38,36,40,1,8,7,9,10,11,44,69,70,73,71,52,45,48,54,15,16,17,55,18,25,19,23,56,12,82,13,14,20,21,22,101,102,122,78,39,153,111,270,163,239,26,149,27,240,241,271,174]))),Bh=(0,G.lazy)(()=>z(()=>import(`./WalletSettingsPage-BZCW-BH2.js`).then(e=>({default:e.WalletSettingsPage})),__vite__mapDeps([272,5,3,36,4,6,40,41,31,32,33,34,1,70,209,54,15,8,10,16,17,55,18,25,19,23,56,12,48,192,174,184,7,9,11,45,102,13,14,20,21,22,49,155,50,151,185,173]))),Vh=(0,G.lazy)(()=>z(()=>import(`./WebxdcFeedPage-JkIXIn6T.js`).then(e=>({default:e.WebxdcFeedPage})),__vite__mapDeps([273,3,4,5,34,40,41,31,32,33,1,7,8,9,10,11,44,38,36,57,58,121,67,86,71,85,87,14,15,16,17,18,19,20,21,22,23,12,13,49,106,107,6,108,109,50,274,114,224,115,174,70,177,79]))),Hh=(0,G.lazy)(()=>z(()=>import(`./WikipediaPage-BjPAd7Ag.js`).then(e=>({default:e.WikipediaPage})),__vite__mapDeps([275,3,4,5,36,120,41,8,70,45,82,108,128,276,34]))),Uh=(0,G.lazy)(()=>z(()=>import(`./WorldPage-CGNJksI9.js`).then(e=>({default:e.WorldPage})),__vite__mapDeps([277,3,4,5,36,70,41,45,8,103,174]))),Wh=(0,G.lazy)(()=>z(()=>import(`./RemoteLoginSuccessPage-RdWRi3wH.js`).then(e=>({default:e.RemoteLoginSuccessPage})),__vite__mapDeps([278,3,4,5,6,1,7,8,9,10,11,70,41]))),Gh=Xi(`polls`),Kh=Xi(`colors`),qh=Xi(`packs`),Jh=Xi(`articles`),Yh=Xi(`decks`),Xh=Xi(`highlights`);function Zh(){let[e,t]=(0,G.useState)(!1);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fh,{kind:Gh.kind,title:Gh.label,icon:na(`polls`,`size-5`),onFabClick:()=>t(!0)}),e&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Hm,{open:e,onOpenChange:t,initialMode:`poll`})})]})}function Qh(){let{user:e,metadata:t}=V(),n=mr(e?.pubkey??``,t);return e?(0,K.jsx)(cr,{to:n,replace:!0}):(0,K.jsx)(cr,{to:`/`,replace:!0})}function $h(){return(0,K.jsx)(_u,{children:(0,K.jsxs)(ur,{useTransitions:!1,children:[(0,K.jsx)(xu,{}),(0,K.jsx)(ep,{}),(0,K.jsx)(sp,{}),(0,K.jsx)(pu,{}),(0,K.jsx)(Pl,{}),(0,K.jsx)(zl,{}),(0,K.jsx)(Hl,{}),(0,K.jsx)(Fl,{}),(0,K.jsx)(tp,{}),(0,K.jsx)(au,{}),(0,K.jsxs)(yu,{children:[(0,K.jsx)(Vm,{}),(0,K.jsx)(sr,{children:(0,K.jsxs)(U,{element:(0,K.jsx)(Gf,{}),children:[(0,K.jsx)(U,{path:`/`,element:(0,K.jsx)(Wm,{})}),(0,K.jsx)(U,{path:`/feed`,element:(0,K.jsx)(Lm,{})}),(0,K.jsx)(U,{path:`/notifications`,element:(0,K.jsx)(Sh,{})}),(0,K.jsx)(U,{path:`/search`,element:(0,K.jsx)(Oh,{})}),(0,K.jsx)(U,{path:`/trends`,element:(0,K.jsx)(Fh,{})}),(0,K.jsx)(U,{path:`/profile`,element:(0,K.jsx)(Qh,{})}),(0,K.jsx)(U,{path:`/t/:tag`,element:(0,K.jsx)(uh,{})}),(0,K.jsx)(U,{path:`/g/:geohash`,element:(0,K.jsx)(lh,{})}),(0,K.jsx)(U,{path:`/feed/:domain`,element:(0,K.jsx)(oh,{})}),(0,K.jsx)(U,{path:`/client/:name`,element:(0,K.jsx)(th,{})}),(0,K.jsx)(U,{path:`/settings`,element:(0,K.jsx)(kh,{})}),(0,K.jsx)(U,{path:`/settings/profile`,element:(0,K.jsx)(Eh,{})}),(0,K.jsx)(U,{path:`/settings/feed`,element:(0,K.jsx)(rh,{})}),(0,K.jsx)(U,{path:`/settings/content`,element:(0,K.jsx)(nh,{})}),(0,K.jsx)(U,{path:`/settings/wallet`,element:(0,K.jsx)(Bh,{})}),(0,K.jsx)(U,{path:`/settings/notifications`,element:(0,K.jsx)(xh,{})}),(0,K.jsx)(U,{path:`/settings/advanced`,element:(0,K.jsx)(Gm,{})}),(0,K.jsx)(U,{path:`/settings/magic`,element:(0,K.jsx)(gh,{})}),(0,K.jsx)(U,{path:`/settings/network`,element:(0,K.jsx)(yh,{})}),(0,K.jsx)(U,{path:`/settings/data`,element:(0,K.jsx)(ah,{})}),(0,K.jsx)(U,{path:`/lists`,element:(0,K.jsx)(Ih,{})}),(0,K.jsx)(U,{path:`/events`,element:(0,K.jsx)(sh,{})}),(0,K.jsx)(U,{path:`/photos`,element:(0,K.jsx)(Ch,{})}),(0,K.jsx)(U,{path:`/videos`,element:(0,K.jsx)(Lh,{})}),(0,K.jsx)(U,{path:`/streams`,element:(0,K.jsx)(cr,{to:`/videos`,replace:!0})}),(0,K.jsx)(U,{path:`/shorts`,element:(0,K.jsx)(Rh,{})}),(0,K.jsx)(U,{path:`/vines`,element:(0,K.jsx)(cr,{to:`/shorts`,replace:!0})}),(0,K.jsx)(U,{path:`/divines`,element:(0,K.jsx)(cr,{to:`/shorts`,replace:!0})}),(0,K.jsx)(U,{path:`/music`,element:(0,K.jsx)(vh,{})}),(0,K.jsx)(U,{path:`/podcasts`,element:(0,K.jsx)(wh,{})}),(0,K.jsx)(U,{path:`/polls`,element:(0,K.jsx)(Zh,{})}),(0,K.jsx)(U,{path:`/treasures`,element:(0,K.jsx)(Mh,{})}),(0,K.jsx)(U,{path:`/quizzes`,element:(0,K.jsx)(Nh,{})}),(0,K.jsx)(U,{path:`/quizzes/new`,element:(0,K.jsx)(Ph,{})}),(0,K.jsx)(U,{path:`/memory-cards`,element:(0,K.jsx)(_h,{})}),(0,K.jsx)(U,{path:`/memory-cards/:npub`,element:(0,K.jsx)(_h,{})}),(0,K.jsx)(U,{path:`/memory-cards/:npub/:cardId`,element:(0,K.jsx)(_h,{})}),(0,K.jsx)(U,{path:`/colors`,element:(0,K.jsx)(fh,{kind:Kh.kind,title:Kh.label,icon:na(`colors`,`size-5`)})}),(0,K.jsx)(U,{path:`/packs`,element:(0,K.jsx)(fh,{kind:qh.kind,title:qh.label,icon:na(`packs`,`size-5`)})}),(0,K.jsx)(U,{path:`/webxdc`,element:(0,K.jsx)(Vh,{})}),(0,K.jsx)(U,{path:`/articles/new`,element:(0,K.jsx)(Jm,{})}),(0,K.jsx)(U,{path:`/articles/edit/:slug`,element:(0,K.jsx)(Jm,{})}),(0,K.jsx)(U,{path:`/articles`,element:(0,K.jsx)(fh,{kind:Jh.kind,title:Jh.label,icon:na(`articles`,`size-5`),fabHref:`/articles/new`})}),(0,K.jsx)(U,{path:`/highlights`,element:(0,K.jsx)(fh,{kind:Xh.kind,title:Xh.label,icon:na(`highlights`,`size-5`),showFAB:!1})}),(0,K.jsx)(U,{path:`/decks`,element:(0,K.jsx)(fh,{kind:Yh.kind,title:Yh.label,icon:na(`decks`,`size-5`)})}),(0,K.jsx)(U,{path:`/emojis`,element:(0,K.jsx)(Um,{})}),(0,K.jsx)(U,{path:`/development`,element:(0,K.jsx)(fh,{kind:Ji(`development`),title:`Development`,icon:na(`development`,`size-5`),showFAB:!1})}),(0,K.jsx)(U,{path:`/themes`,element:(0,K.jsx)(jh,{})}),(0,K.jsx)(U,{path:`/wallet`,element:(0,K.jsx)(zh,{})}),(0,K.jsx)(U,{path:`/bookmarks`,element:(0,K.jsx)(Qm,{})}),(0,K.jsx)(U,{path:`/ai-chat`,element:(0,K.jsx)(Km,{})}),(0,K.jsx)(U,{path:`/blobbi`,element:(0,K.jsx)(Xm,{})}),(0,K.jsx)(U,{path:`/world`,element:(0,K.jsx)(Uh,{})}),(0,K.jsx)(U,{path:`/badges`,element:(0,K.jsx)(Ym,{})}),(0,K.jsx)(U,{path:`/books`,element:(0,K.jsx)($m,{})}),(0,K.jsx)(U,{path:`/archive`,element:(0,K.jsx)(qm,{})}),(0,K.jsx)(U,{path:`/bluesky`,element:(0,K.jsx)(Zm,{})}),(0,K.jsx)(U,{path:`/wikipedia`,element:(0,K.jsx)(Hh,{})}),(0,K.jsx)(U,{path:`/letters`,element:(0,K.jsx)(hh,{})}),(0,K.jsx)(U,{path:`/letters/compose`,element:(0,K.jsx)(ph,{})}),(0,K.jsx)(U,{path:`/settings/letters`,element:(0,K.jsx)(mh,{})}),(0,K.jsx)(U,{path:`/help`,element:(0,K.jsx)(dh,{})}),(0,K.jsx)(U,{path:`/privacy`,element:(0,K.jsx)(Th,{})}),(0,K.jsx)(U,{path:`/safety`,element:(0,K.jsx)(ih,{})}),(0,K.jsx)(U,{path:`/changelog`,element:(0,K.jsx)(eh,{})}),(0,K.jsx)(U,{path:`/r/*`,element:(0,K.jsx)(Dh,{})}),(0,K.jsx)(U,{path:`/settings/lists`,element:(0,K.jsx)(cr,{to:`/lists`,replace:!0})}),(0,K.jsx)(U,{path:`/i/*`,element:(0,K.jsx)(ch,{})}),(0,K.jsx)(U,{path:`/share`,element:(0,K.jsx)(Ah,{})}),(0,K.jsx)(U,{path:`/remoteloginsuccess`,element:(0,K.jsx)(Wh,{})}),(0,K.jsx)(U,{path:`/follow/:npub`,element:(0,K.jsx)(cr,{to:`/`,replace:!0})}),(0,K.jsx)(U,{path:`/:nip19`,element:(0,K.jsx)(bh,{})}),(0,K.jsx)(U,{path:`*`,element:(0,K.jsx)(Rm,{})})]})})]})]})})}var eg=new Wa({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:6e4,gcTime:3e5}}}),tg={appName:`Ditto`,appId:`ditto`,shareOrigin:`https://ditto.pub`,homePage:`feed`,client:`naddr1qvzqqqru7cpzq7q6z5ns2hm5c8msyv83qwzxpxe52j8c4d4q5m92wsp9sflelkh9qqzkg6t5w3hswjl4yp`,magicMouse:!1,theme:`system`,autoShareTheme:!0,useAppRelays:!0,useUserRelays:!1,relayMetadata:{relays:[],updatedAt:0},feedSettings:{feedIncludePosts:!0,feedIncludeComments:!0,feedIncludeReposts:!0,feedIncludeGenericReposts:!0,feedIncludeReactions:!0,feedIncludeZaps:!0,feedIncludeArticles:!0,showArticles:!0,showHighlights:!0,feedIncludeHighlights:!0,feedIncludeCampaigns:!0,feedIncludeClassifiedListings:!0,feedIncludeAttestations:!1,showEvents:!0,feedIncludeEvents:!0,showVines:!0,showPolls:!0,showTreasures:!0,showTreasureGeocaches:!0,showTreasureFoundLogs:!0,showQuizzes:!0,showQuizDefinitions:!0,showQuizResults:!0,feedIncludeQuizzes:!0,feedIncludeQuizResults:!0,showColors:!0,showMemoryCards:!0,showPeopleLists:!0,feedIncludeVines:!0,feedIncludePolls:!0,feedIncludeTreasureGeocaches:!0,feedIncludeTreasureFoundLogs:!0,feedIncludeColors:!0,feedIncludeMemoryCards:!0,feedIncludePeopleLists:!0,showDecks:!0,feedIncludeDecks:!0,showWebxdc:!0,feedIncludeWebxdc:!0,showPhotos:!0,feedIncludePhotos:!0,showVideos:!0,feedIncludeNormalVideos:!0,feedIncludeShortVideos:!0,showProfileThemes:!1,feedIncludeProfileThemes:!0,showThemeDefinitions:!0,feedIncludeThemeDefinitions:!0,showProfileThemeUpdates:!0,feedIncludeProfileThemeUpdates:!0,showCustomProfileThemes:!0,feedIncludeVoiceMessages:!0,showEmojiPacks:!0,feedIncludeEmojiPacks:!0,showCustomEmojis:!0,showUserStatuses:!0,showMusic:!0,feedIncludeMusicTracks:!0,feedIncludeMusicPlaylists:!0,showPodcasts:!0,feedIncludePodcastEpisodes:!0,feedIncludePodcastTrailers:!0,showDevelopment:!0,feedIncludeGitRepos:!0,feedIncludeGitPushes:!1,feedIncludeGitPatches:!0,feedIncludeGitPullRequests:!0,feedIncludeGitPrUpdates:!1,feedIncludeGitIssues:!0,feedIncludeGitStatusReopened:!1,feedIncludeGitStatusResolved:!1,feedIncludeGitStatusClosed:!1,feedIncludeGitStatusDraft:!1,feedIncludeCustomNips:!0,feedIncludeNsiteRoots:!0,feedIncludeNsiteNamed:!0,feedIncludeNsiteSnapshots:!1,feedIncludeZapstoreApps:!0,feedIncludeZapstoreReleases:!0,feedIncludeAppHandlers:!0,showBadges:!0,showBadgeDefinitions:!0,showProfileBadges:!0,showBadgeAwards:!0,feedIncludeBadgeDefinitions:!0,feedIncludeProfileBadges:!0,feedIncludeBadgeAwards:!0,feedIncludeVanish:!0,feedIncludeRelayLists:!0,feedIncludeProfileUpdates:!0,feedIncludeLoveLists:!0,feedIncludeBlobbi:!0,showBirdstar:!0,feedIncludeBirdDetections:!0,feedIncludeBirdex:!0,feedIncludeConstellations:!0,followsFeedShowReplies:!0},sidebarOrder:[`feed`,`notifications`,`search`,`blobbi`,`badges`,`emojis`,`letters`,`themes`,`settings`,`help`],nip85StatsPubkey:`5f68e85ee174102ca8978eef302129f081f03456c884185d5ec1c1224ab633ea`,blossomServerMetadata:{servers:[],updatedAt:0},useAppBlossomServers:!0,faviconUrl:`https://ditto.pub/api/favicon/{hostname}`,linkPreviewUrl:`https://ditto.pub/api/link-preview/{url}`,corsProxy:`https://proxy.shakespeare.diy/?url={href}`,contentWarningPolicy:`blur`,exemptFollowsFromFilters:!1,sentryDsn:``,sentryEnabled:!0,plausibleDomain:``,plausibleEndpoint:``,savedFeeds:[],autoplayVideos:!1,stripTrackingParams:!0,imageQuality:`compressed`,curatorPubkey:`932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d`,sandboxDomain:`iframe.diy`,esploraApis:[...ci],currencyDisplay:`usd`,sidebarWidgets:As,maxCachedEventAge:604800};function ng(){try{let e=JSON.parse(`null`);return e?Xt.parse(e):{}}catch{return{}}}var rg=ng(),ig={...tg,...rg,feedSettings:{...tg.feedSettings,...rg.feedSettings}};function ag(){return Vs(),(0,K.jsx)(ro,{storageKey:qa,defaultConfig:ig,children:(0,K.jsx)(lo,{children:(0,K.jsx)(zs,{children:(0,K.jsx)(Rs,{children:(0,K.jsx)(vt,{client:eg,children:(0,K.jsxs)(Le,{storageKey:`nostr:login`,storage:Us,children:[(0,K.jsx)(no,{}),(0,K.jsxs)(Ds,{children:[(0,K.jsx)(Is,{}),(0,K.jsx)(rs,{}),(0,K.jsx)(Ls,{}),(0,K.jsx)(Ol,{children:(0,K.jsx)(Nl,{children:(0,K.jsx)(si,{children:(0,K.jsx)(Bo,{children:(0,K.jsx)($h,{})})})})})]})]})})})})})})}var og={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},sg={debug:(...e)=>og.debug(...e),info:(...e)=>og.info(...e),warn:(...e)=>og.warn(...e),error:(...e)=>og.error(...e)},cg=e({});if(Ee(),_n.isNativePlatform()){_n.getPlatform()===`ios`&&z(async()=>{let{Keyboard:e}=await import(`./esm-Dx0xmOVX.js`);return{Keyboard:e}},__vite__mapDeps([279,1])).then(({Keyboard:e})=>{e.setAccessoryBarVisible({isVisible:!1}).catch(()=>{})}).catch(()=>{});function e(){let e=Yt()===`dark`;mn.setStyle({style:e?gn.Dark:gn.Light}).catch(()=>{})}e(),new MutationObserver(()=>e()).observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]});let t=new MutationObserver(()=>e()),n=()=>{let e=document.getElementById(`theme-vars`);e&&t.observe(e,{characterData:!0,childList:!0,subtree:!0})};n(),new MutationObserver(()=>n()).observe(document.head,{childList:!0})}(0,Ba.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(Ne,{children:(0,K.jsx)(ag,{})})),requestAnimationFrame(()=>{document.getElementById(`preloader`)?.remove()});export{Cl as $,ef as A,dd as B,Ap as C,If as D,rp as E,gd as F,Zu as G,vd as H,hd as I,vu as J,Eu as K,bd as L,Yd as M,pd as N,gf as O,yd as P,Dl as Q,md as R,Pp as S,hp as T,Sd as U,_d as V,ud as W,Ml as X,Z as Y,kl as Z,tm as _,Mm as a,Fs as at,Up as b,_m as c,Lo as ct,fm as d,ho as dt,wl as et,om as f,uo as ft,em as g,Qp as h,Lm as i,js as it,Qd as j,pf as k,im as l,_o as lt,rm as m,sg as n,Ms as nt,jm as o,Ps as ot,pm as p,Cu as q,Rm as r,Os as rt,vm as s,Io as st,cg as t,Us as tt,mm as u,vo as ut,nm as v,kp as w,Hp as x,Gp as y,fd as z};