import{c as se,a as f,f as I}from"./yjcpNk9y.js";import{b6 as W,ao as z,b3 as Q,a_ as A,bC as G,a6 as T,bd as k,bs as ae,ar as Pe,bK as Be,as as g,bO as Ae,ag as p}from"./DURqPrI0.js";import{s as M}from"./DzOcMAzI.js";import{fr as je,dX as Ce,ev as B,ei as H,lO as N,eB as oe,l1 as Oe,P as re,e7 as De,aK as ze,eL as ne,k$ as Ge,dW as He,dI as Ne,eQ as Ze,hc as ce,ea as ie,j9 as le,iB as Fe,cM as V,cF as de,iY as me,eX as We,cz as b,lo as ue,l2 as Qe,dP as Ve,jd as Ke,jx as Xe,mM as qe,j7 as U,dD as pe,k2 as S,mV as u,cT as R,gT as y,kR as _,gO as Je,cR as Ye,ba as $e,k5 as m,gq as K,gA as X,ma as j,ij as ge,jy as es,fz as Z,mZ as ve,jZ as ss,mo as ts,mq as as,i_ as os,bo as rs,lf as fe,kv as ns,md as cs,h2 as is,jI as ls,mQ as ds,l4 as ms,hf as us,hs as ps,hp as gs,jp as vs,dE as te}from"./BQCsJfSh.js";import{p as F,r as fs,i as ys}from"./DM3z28FY.js";import{g as q}from"./BvpFJAFp.js";import{p as x}from"./BSpZGo8_.js";const hs=e=>e.replace(/^nostr:\/?\/?/,""),bs=e=>e.startsWith("nostr:")?e:`nostr:${e}`;function at(e,s){W(s,!0);const t=F(s,"tag",3,"div"),a=fs(s,["$$slots","$$events","$$legacy","children","tag"]);var o=se(),r=z(o);je(r,t,!1,(c,d)=>{Ce(c,i=>({...a,class:i}),[()=>B("flex flex-col overflow-hidden",s.class)]);var l=se(),n=z(l);M(n,()=>s.children??A),f(d,l)}),f(e,o),Q()}var Rs=I("
");function ot(e,s){W(s,!0);var t=Rs(),a=T(t);M(a,()=>s.children??A),k(t),G(o=>N(t,1,o),[()=>H(B("scroll-container overflow-y-auto min-h-0 flex flex-col gap-4 p-6",s.class))]),f(e,t),Q()}const _s="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMS41IiBkPSJtOSA1IDYgNy02IDciLz48L3N2Zz4=",rt=Object.freeze(Object.defineProperty({__proto__:null,default:_s},Symbol.toStringTag,{value:"Module"}));var ws=I(""),Ts=I("
");function nt(e,s){W(s,!0);const t=F(s,"size",3,"md"),a=F(s,"loading",3,!0),o=Be(()=>B("spinner",{"spinner-sm":t()==="sm","spinner-xs":t()==="xs"}));var r=Ts(),c=T(r);{var d=n=>{var i=ws();G(()=>N(i,1,H(Pe(o)))),f(n,i)};ys(c,n=>{a()&&n(d)})}var l=ae(c,2);M(l,()=>s.children??A),k(r),G(n=>N(r,1,n),[()=>H(B("flex items-center gap-2",s.class))]),f(e,r),Q()}const ct=e=>{if(/^[a-f0-9]{64}$/i.test(e))return e.toLowerCase();try{const s=oe(hs(e));return s.type==="npub"?s.data:s.type==="nprofile"?s.data.pubkey:void 0}catch{return}},it=e=>{const{type:s,data:t}=oe(e);if(s!=="nsec")throw new Error(`Invalid nsec: ${e}`);return De(t)},ks=e=>Math.floor(e/re),lt=(e,s)=>[...Oe(e,s,re)].map(ks),dt=e=>e.slice(0,1).toUpperCase()+e.slice(1),mt=e=>String(e).replace(/^.*Error: /,"");class Is extends Error{constructor(){super("Aborted"),this.name="AbortError"}}class Ms extends Error{constructor(s="Timed out"){super(s),this.name="TimeoutError"}}const ut=e=>e?new Promise((s,t)=>{const a=()=>t(new Is);e.aborted?a():e.addEventListener("abort",a,{once:!0})}):new Promise(()=>{}),pt=(e,s={})=>new Promise((t,a)=>{var r;const o=setTimeout(()=>a(new Ms(s.message)),e);(r=s.signal)==null||r.addEventListener("abort",()=>clearTimeout(o),{once:!0})}),gt=(e,...s)=>{const t=new URL(e);return t.pathname="/"+s.join("/"),t.toString()},vt=e=>(e+".").replace(/\.+$/,"."),ft=e=>e.trim().replace(/^#+/,"").toLowerCase(),yt=e=>e.replace(/^\w+: /,""),Ss="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMS41IiBkPSJtMTUgNS02IDcgNiA3Ii8+PC9zdmc+",ht=Object.freeze(Object.defineProperty({__proto__:null,default:Ss},Symbol.toStringTag,{value:"Module"}));var Us=I('');function bt(e,s){var t=Us(),a=T(t);M(a,()=>s.children),k(t),f(e,t)}var xs=I('');function Rt(e,s){var t=xs(),a=T(t);M(a,()=>s.children),k(t),f(e,t)}var Ls=I(' ',1);function _t(e,s){var t=Ls(),a=ae(z(t),2),o=T(a),r=T(o);M(r,()=>s.children??A),k(o),k(a),f(e,t)}const Es=new ze,C=Ae({}),O=e=>e.slice(1).split(",").filter(Boolean),wt=ne([x,C],([e,s])=>O(e.url.hash).map(t=>s[t]).filter(Boolean)),Tt=ne([x,C],([e,s])=>{const t=O(e.url.hash);return s[t.at(-1)||""]}),kt=(e,s={},t={})=>{const a=Ge(),o=t.path||"",r=O(g(x).url.hash),c=t.nested?[...r,a]:[a];return C.update(He(a,{id:a,component:e,props:s,options:t})),q(o+"#"+c.join(","),{replaceState:t.replaceState}),a},It=()=>{const e=g(x).url,s=O(e.hash);if(s.length===0)return;const t=s.slice(0,-1).join(","),a=t?`#${t}`:"";q(e.pathname+e.search+a,{replaceState:!0})},Mt=()=>{const e=g(x).url;q(e.pathname+e.search,{replaceState:!0}),C.update(Ne({})),Es.emit("close")},Ps="h",ye=["-"];var he=(e=>(e.Text="text",e.Voice="voice",e))(he||{});const Bs=e=>e.livekit?"voice":"text",h=(e,s)=>`${e}'${s}`,As=e=>e.includes("'"),be=e=>e.split("'"),Re=Ze({tracker:qe,repository:ue,filters:[{kinds:[V,de]}]}),J=p(Re,e=>{const s=new Map;for(const[t,a]of e.entries()){const[o,r]=ns(cs({kind:V}),a.values()),c=new Map;for(const l of r)for(const n of is("h",l.tags))c.set(n,ls([c.get(n),l.created_at]));const d=new Map;for(const l of o){const n=ds(()=>ms(l));if(!n||us(c.get(n.h),n.event.created_at))continue;const i=h(t,n.h);d.set(i,{...n,url:t,id:i})}d.size>0&&s.set(t,Array.from(d.values()))}return s}),L=p(J,e=>ps(s=>s.id,Array.from(e.values()).flatMap(gs))),_e=ce(L),Y=e=>_e().get(e),we=ie(()=>{const s=le(async t=>{const[a,o]=be(t);await Fe({relays:[a],filters:[{kinds:[V],"#d":[o]},{kinds:[de],"#h":[o]}]})},Y);return(t,a)=>s(h(t,a))}),js=ie(()=>{const e=me(L,we);return(s,t)=>p(e(h(s,t)),a=>a||{url:s,id:h(s,t),...vs({h:t})})}),Te=(e,s)=>{var t;return((t=Y(h(e,s)))==null?void 0:t.name)||s},E=e=>s=>Te(e,s).toLowerCase(),$=e=>p(L,s=>{const t=new Set;for(const a of s.values())a.url===e&&a.livekit&&t.add(a.h);return t}),Cs=e=>p([$(e),ee(e)],([s,t])=>{const a=[];for(const o of s)t.includes(o)||a.push(o);return j(E(e),u(a))}),P=We({repository:ue,filters:[{kinds:[b]}],getKey:e=>e.event.pubkey,eventToItem:e=>Qe(Ve(e))}),ke=ce(P),Ie=e=>ke().get(e),D=le(Ke(b),Ie),Os=me(P,D),Me=p(P,e=>{const s=new Map;for(const t of e.values()){const a=X(t);for(const o of y(a))te(s,m(o),t.event.pubkey);for(const o of K(a)){const r=o[2]||"";ge(r)&&te(s,m(r),t.event.pubkey)}}return s}),Ds=e=>p(Me,s=>new Set(s.get(e))),Se=e=>{const s=X(e),t=y(s);for(const a of K(s)){const o=a[2]||"";ge(o)&&t.push(o)}return u(t.map(m))},Ue=(e,s)=>{const t=[],a=m(e);for(const[o,r,c]of K(X(s)))a===m(c)&&t.push(r);return j(E(e),u(t))},v=Xe(P,D),zs=es(D),Gs=p(v,Se),ee=e=>p([v,L],([s,t])=>{const a=[];for(const o of Ue(e,s))t.has(h(e,o))&&a.push(o);return j(E(e),a)}),Hs=e=>p([ee(e),$(e),J],([s,t,a])=>{const o=[];for(const{h:r}of a.get(e)||[])!s.includes(r)&&!t.has(r)&&o.push(r);return j(E(e),u(o))}),Ns=async e=>{const s=g(v)||U({kind:b}),t=await pe(s,["r",e]).reconcile(S),a=u([...R.get().FromUser().getUrls(),...y(t.tags)]);return _({event:t,relays:a})},Zs=async e=>{const s=g(v)||U({kind:b}),a=await fe(s,r=>m(r[r[0]==="r"?1:2])===e).reconcile(S),o=u([e,...R.get().FromUser().getUrls(),...y(a.tags)]);return _({event:a,relays:o})},Fs=async e=>{const s=g(v)||U({kind:b}),t=u(e.map(m)),a=s.publicTags.filter(i=>i[0]==="r"),o=s.publicTags.filter(i=>i[0]!=="r"),r=new Map(a.map(i=>[m(i[1]),i])),d=[...t.map(i=>r.get(i)||["r",i]),...o],l=await ve(s,{publicTags:d}).reconcile(S),n=u([...R.get().FromUser().getUrls(),...y(l.tags)]);return _({event:l,relays:n})},Ws=async(e,s)=>{const t=m(e),a=m(s),o=g(v);if(!o||t===a)return;const r=Ee=>Ee.map(w=>w[0]==="r"&&m(w[1])===t?["r",a]:w[0]==="group"&&m(w[2]||"")===t?["group",w[1],a]:w),c=r(o.publicTags),d=r(o.privateTags),l=!Z(c,o.publicTags),n=!Z(d,o.privateTags);if(!l&&!n)return;const i=await ve(o,{publicTags:l?c:void 0,privateTags:n?d:void 0}).reconcile(S),Le=u([e,s,...R.get().FromUser().getUrls(),...y(i.tags)]);return _({event:i,relays:Le})},Qs=async(e,s)=>{const t=g(v)||U({kind:b}),o=await pe(t,...[["r",e],["group",s,e]]).reconcile(S),r=u([...R.get().FromUser().getUrls(),...y(o.tags)]);return _({event:o,relays:r})},Vs=async(e,s)=>{const t=g(v)||U({kind:b}),o=await fe(t,c=>Z(["group",s,e],c.slice(0,3))).reconcile(S),r=u([e,...R.get().FromUser().getUrls(),...y(o.tags)]);return _({event:o,relays:r})},Ks=e=>{const s=Je(e,Ye.Write);return s.length?s:$e},xe=(e,{content:s,tags:t},a)=>{if(e){const o=a?[a]:R.get().Event(e).limit(3).getUrls(),r=ss({...e,relays:o});t=[...t,ts(e,a),as(e.pubkey)],s=bs(r)+`
`+s}return{content:s,tags:t}},Xs=({url:e,h:s,parent:t,protect:a,delay:o})=>{const r=[];s&&r.push(["h",s]),a&&r.push(ye);const c=os(rs,xe(t,{content:"",tags:r},e));return _({relays:[e],event:c,delay:o})},St=Object.freeze(Object.defineProperty({__proto__:null,PROTECTED:ye,ROOM:Ps,RoomType:he,addRoom:Qs,addSpace:Ns,deriveGroupList:Os,deriveGroupListPubkeys:Ds,deriveOtherRooms:Hs,deriveOtherVoiceRooms:Cs,deriveRoom:js,deriveUserRooms:ee,deriveVoiceRooms:$,displayRoom:Te,getGroupList:Ie,getGroupListsByPubkey:ke,getPubkeyHints:Ks,getRoom:Y,getRoomType:Bs,getRoomsById:_e,getSpaceRoomsFromGroupList:Ue,getSpaceUrlsFromGroupList:Se,groupListPubkeysByUrl:Me,groupListsByPubkey:P,isRoomId:As,loadGroupList:D,loadRoom:we,loadUserGroupList:zs,makeRoomId:h,moveSpace:Ws,prependParent:xe,publishRoomQuote:Xs,removeRoom:Vs,removeSpace:Zs,roomComparator:E,roomMetaEventsByIdByUrl:Re,roomsById:L,roomsByUrl:J,setSpaces:Fs,splitRoomId:be,userGroupList:v,userSpaceUrls:Gs},Symbol.toStringTag,{value:"Module"}));export{Fs as $,Is as A,Ue as B,Se as C,Me as D,St as E,As as F,D as G,zs as H,h as I,Tt as J,wt as K,Ws as L,at as M,ft as N,it as O,ye as P,It as Q,Ps as R,nt as S,Ms as T,xe as U,Xs as V,kt as W,Vs as X,Zs as Y,J as Z,ht as _,Ss as a,be as a0,yt as a1,bs as a2,dt as a3,v as a4,Gs as a5,ut as a6,pt as a7,_s as b,ot as c,_t as d,bt as e,Rt as f,he as g,rt as h,vt as i,Qs as j,Ns as k,gt as l,Mt as m,lt as n,ct as o,Os as p,Ds as q,Hs as r,Cs as s,js as t,ee as u,Te as v,mt as w,hs as x,Y as y,Bs as z};
//# sourceMappingURL=CSZ2C-U5.js.map