PageSourceSearch

https://limewire.com/build/chunks/share-nearby-provider-CoGBu4zh.js

js limewire.com collected 2026-09-24 08:25:15 UTC 11,045 bytes, 4 lines download raw bytes

1import{j as o}from"./jsx-runtime-D_zvdyIk.js";import{v as d,R as f,L as J}from"./chunk-4N6VE7H7-CYH4PXiQ.js";import{u as U}from"./env-context-DebTkedx.js";import{u as _}from"./use-const-CyuDI2Jw.js";import{u as p}from"./use-callback-ref-CJ9SODNh.js";import{u as B}from"./user-context-H9i7VnPA.js";import{c as z}from"./index-5zs3RZdd.js";import{a as j}from"./creator-name-CiLx5-S8.js";import{O as $}from"./tooltip-Dh-GCyoz.js";import{I}from"./focus-visible-outline-CA5WDHp1.js";import{M as H,d as W,h as G,g as V}from"./modal-content-window-title-header-DByhHMtf.js";import{C as X}from"./copy-input-0I8Jahig.js";import{B as E}from"./button-CB2fQLpx.js";const Y=10,q=e=>1e3*e,g=e=>e?e.readyState===e.CLOSED:!0;class K{constructor(t,n){this.registeredEventListeners=new Map,this.eventSourceListeners=new Map,this.windowListeners=new Map,this.closed=!1,this.reconnectAttempts=0,this.reconnectTimeoutId=void 0;const r=()=>{const a=new EventSource(t,n);return a.addEventListener("open",()=>{this.reconnectAttempts=0}),a.addEventListener("error",()=>{var c;g(a)&&this.reconnectAttempts<Y&&((c=this.eventSource)==null||c.close(),clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=setTimeout(()=>{s(),this.reconnectAttempts++},q(this.reconnectAttempts)))}),a},s=()=>{this.closed||(this.eventSource=r(),this.updateEventListeners())},i=()=>{g(this.eventSource)&&s()};this.eventSource=r(),this.windowListeners.set("beforeunload",()=>{var a;(a=this.eventSource)==null||a.close()}),this.windowListeners.set("focus",i),this.windowListeners.set("online",i),this.windowListeners.forEach((a,c)=>{window.addEventListener(c,a)})}getEventSource(){return this.eventSource}addEventListener(t,n){if(!t||!n)return;const r=this.registeredEventListeners.get(t)||new Set;r.add(n),this.registeredEventListeners.set(t,r),this.updateEventListeners()}removeEventListener(t,n){if(!t||!n)return;const r=this.registeredEventListeners.get(t);r&&(r.delete(n),r.size===0?this.registeredEventListeners.delete(t):this.registeredEventListeners.set(t,r),this.updateEventListeners())}close(){var t;this.closed=!0,(t=this.eventSource)==null||t.close(),this.updateEventListeners(!0),this.windowListeners.forEach((n,r)=>{window.removeEventListener(r,n)}),clearTimeout(this.reconnectTimeoutId)}updateEventListeners(t){if(this.eventSourceListeners.forEach((n,r)=>{var s;(s=this.eventSource)==null||s.removeEventListener(r,n)}),this.eventSourceListeners.clear(),t){this.registeredEventListeners.clear();return}this.registeredEventListeners.forEach((n,r)=>{var i;const s=a=>{n.forEach(c=>c(a))};(i=this.eventSource)==null||i.addEventListener(r,s),this.eventSourceListeners.set(r,s)})}}const Q=(e,t)=>`${typeof e=="string"?e:e.toString()}${JSON.stringify(t||{})}`;class Z{constructor(){this.openEventSources=new Map}openEventSource(t,n,r,s){const{onOpen:i,onError:a,onMessage:c}=s||{},S=Q(t,n),u=this.openEventSources.get(S)||{eventSource:new K(t,n),subscribers:0},{eventSource:l}=u;return l.addEventListener("open",i),l.addEventListener("error",a),l.addEventListener(r,c),u.subscribers++,this.openEventSources.set(S,u),{getEventSource:()=>l.getEventSource(),close:()=>{l.removeEventListener("open",i),l.removeEventListener("error",a),l.removeEventListener(r,c),u.subscribers--,u.subscribers||(l.close(),this.openEventSources.delete(S))}}}}const O=d.createContext(null);function tt({children:e}){const t=_(()=>new Z),n=d.useMemo(()=>({openEventSource:(...r)=>t.openEventSource(...r)}),[t]);return o.jsx(O.Provider,{value:n,children:e})}function ee(){const e=d.useContext(O);if(!e)throw Error("SseContext not found");return e}function te(e){return ne(e)}function ne(e,t){return e==null?e:{id:e.id,code:e.code,message:e.message}}function re(e){return se(e)}function se(e,t){return e==null?e:{id:e.id,toolName:e.toolName,toolInputs:e.toolInputs,toolOutput:e.toolOutput}}function oe(e){return ie(e)}function ie(e,t){return e==null?e:{id:e.id,text:e.text}}function ae(e){return ce(e)}function ce(e,t){return e}function ue(e){return le(e)}function le(e,t){return e}function C(e){return de(e)}function de(e,t){return e==null?e:{clientId:e.clientId,nick:e.nick==null?void 0:e.nick,avatarUrl:e.avatarUrl==null?void 0:e.avatarUrl,operatingSystem:ue(e.operatingSystem),deviceClass:ae(e.deviceClass)}}function Se(e){return ve(e)}function ve(e,t){return e==null?e:{peers:e.peers.map(C)}}function me(e){return fe(e)}function fe(e,t){return e==null?e:{sequenceNumber:e.sequenceNumber}}const L={CurrentPeers:"CURRENT_PEERS",SharingBucketShare:"SHARING_BUCKET_SHARE"};function pe(e){return he(e)}function he(e,t){return e==null?e:{url:e.url,sourcePeerInfo:C(e.sourcePeerInfo)}}const y={"/users/self/stream":{HEARTBEAT_SENT:{deserializeMessageEventData:e=>me(JSON.parse(e))},AI_GENERATION_FAILED:{deserializeMessageEventData:e=>te(JSON.parse(e))},CHUNKED_TEXT_RESPONSE:{deserializeMessageEventData:e=>oe(JSON.parse(e))},ASSISTANT_TOOL_USE:{deserializeMessageEventData:e=>re(JSON.parse(e))}},"/clients/stream":{CURRENT_PEERS:{deserializeMessageEventData:e=>{const t=JSON.parse(e);return Se(Array.isArray(t)?{peers:t}:t)}
1,urlParams:e=>new URLSearchParams(e)},SHARING_BUCKET_SHARE:{deserializeMessageEventData:e=>pe(JSON.parse(e)),urlParams:e=>new URLSearchParams(e)}}},Ee=(e,t,n)=>{const r=y[e][t].deserializeMessageEventData;if(!r)throw new Error(`No deserialize message event data function defined for "${e}" "${t}" event`);if(typeof n!="string")throw new Error(`Event "${e}" "${t}" message isn't a string`);return r(n)},ge=(e,t,n)=>{const r=y[e][t].urlParams;if(!r)throw new Error(`No url params function defined for "${e}" "${t}" event`);return r(n)},Ne=e=>({getSseInfo:(t,n,r)=>{const s=new URL(e.basePath);return s.pathname=t,r&&ge(t,n,r).forEach((a,c)=>{s.searchParams.set(c,a)}),{url:s.href,messageEventKey:n,deserializeMessageEventData:i=>Ee(t,n,i)}}});function T({pathname:e,eventKey:t,eventSourceInitDict:n={withCredentials:!0},request:r,onError:s,onMessage:i,onOpen:a}){const{API_BASE_URL:c}=U(),{openEventSource:S}=ee(),u=p(s),l=p(i),v=p(a),m=p(()=>n);d.useEffect(()=>{const{getSseInfo:h}=Ne({basePath:c}),A=m(),{url:D,deserializeMessageEventData:R}=h(e,t),{close:F}=S(D,A,t,{onOpen:v,onError:u,onMessage(k){l(R(k.data))}});return()=>{F()}},[c,t,m,u,l,v,S,e,r])}const N=e=>{let t;const n=new Set,r=(u,l)=>{const v=typeof u=="function"?u(t):u;if(!Object.is(v,t)){const m=t;t=l??(typeof v!="object"||v===null)?v:Object.assign({},t,v),n.forEach(h=>h(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>S,subscribe:u=>(n.add(u),()=>n.delete(u))},S=t=e(r,s,c);return c},xe=(e=>e?N(e):N),we=e=>e;function be(e,t=we){const n=f.useSyncExternalStore(e.subscribe,f.useCallback(()=>t(e.getState()),[e,t]),f.useCallback(()=>t(e.getInitialState()),[e,t]));return f.useDebugValue(n),n}const x=e=>{const t=xe(e),n=r=>be(t,r);return Object.assign(n,t),n},Ie=(e=>e?x(e):x);function Oe(e,t){return(...n)=>Object.assign({},e,t(...n))}const Ce=()=>Ie(Oe({peers:[]},e=>({setPeers:t=>{e(()=>({peers:t}))}}))),Le="/build/assets/windows-DO-PY806.svg",w="/build/assets/apple-7VCvRW6F.svg",ye="/build/assets/linux-1zvpkNad.svg",Te="/build/assets/android-D3w-agkY.svg",Pe="/build/assets/desktop-Cv_dAENd.svg",b="/build/assets/phone-DlZQ-6Yt.svg",Me={DESKTOP:Pe,PHONE:b,TABLET:b},Ae={DESKTOP:"PC",PHONE:"Phone",TABLET:"Tablet"},De={ANDROID:Te,IOS:w,LINUX:ye,MACOS:w,WINDOWS:Le},Re={ANDROID:"Android",IOS:"iOS",LINUX:"Linux",MACOS:"MacOS",WINDOWS:"Windows"},P=e=>{const{clientId:t,deviceClass:n,operatingSystem:r,nick:s}=e;return s||`${Re[r]||""} ${Ae[n]||""}`.trim()||t},Fe=e=>Me[e.deviceClass],ke=e=>De[e.operatingSystem],Je=(e,t)=>{const{avatarUrl:n}=e;if(n)return o.jsx(j,{avatarAsset:n,className:"w-full h-full"});const[r,s]=t.split(" ").map(a=>a[0]||""),i=Fe(e);return o.jsx("span",{className:"w-full h-full flex items-center justify-center bg-[#C2EFCA] rounded-full",children:i?o.jsx(I,{url:i,className:"w-[60%] h-[60%] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"}):o.jsxs("span",{className:"uppercase type-d-200-medium",children:[r,s||t[1]]})})},Ue=({className:e,peer:t,tooltip:n})=>{const r=d.useMemo(()=>P(t),[t]),s=d.useMemo(()=>Je(t,r),[t,r]),i=d.useMemo(()=>ke(t),[t]);return o.jsx($,{content:n&&o.jsx(o.Fragment,{children:"To share files with this device, simply upload your files and click on the Share button. Then, select the device again to share your files."}),side:"top",children:({triggerProps:a})=>o.jsxs("span",{...a,className:z("flex flex-col justify-center items-center gap-y-2 w-24",e),children:[o.jsxs("span",{className:"relative w-14 h-14",children:[s,o.jsx("div",{className:"absolute bg-[#333] rounded-sm p-1 bottom-0 right-0 flex gap-x-1 text-white empty:hidden",children:i&&o.jsx(I,{url:i,className:"w-3 h-3"})})]}),o.jsx("span",{className:"type-d-50-medium whitespace-nowrap max-w-full overflow-hidden text-ellipsis",title:r,children:r})]})})},_e=({peer:e,url:t})=>{const n=d.useRef(null),r=P(e);return d.useEffect(()=>{var s;(s=n.current)==null||s.focus()},[]),o.jsx(W,{header:o.jsxs(V,{children:["Download link from ",r]}),children:({closeModal:s})=>o.jsxs("div",{className:"flex flex-col gap-y-6 w-full",children:[o.jsxs("div",{children:[o.jsx(Ue,{className:"mb-6 mx-auto",peer:e}),o.jsxs("div",{className:"text-center",children:[o.jsxs("p",{className:"type-d-75 text-slate-600 mb-2",children:['"',o.jsx("span",{className:"text-slate-900 type-d-75-semibold",children:r}),'" has shared a download link with you.']}),o.jsx(X,{className:"flex flex-row gap-x-1 items-center w-full",copyLabel:"Copy Link",copiedLabel:"Link Copied",value:t})]})]}),o.jsxs(G,{children:[o.jsx(E,{ref:n,tag:J,to:t,target:"_blank",children:"Open"}),o.jsx(E,{theme:"white",onClick:()=>s(),children:"Close"})]})]})})},Be=e=>{const{peer:t,url:n,...r}=e;return o.jsx(H,{content:o.jsx(_e,{peer:t,url:n}),...r})},M=d.createContext(null),nt=()=>{const e=d.useContext(M);if(!e)throw new Error("ShareNearbyContext not found.");return e},ze=()=>{const[e,t]=d.useState(new Set);
1return T({pathname:"/clients/stream",eventKey:L.SharingBucketShare,onMessage:({url:n,sourcePeerInfo:r})=>{const s=o.jsx(Be,{peer:r,url:n,onClosed:()=>{t(i=>(i.delete(s),new Set(i)))},defaultOpen:!0},`${r.clientId}${Date.now()}`);t(i=>new Set([...i,s]))}}),o.jsx(o.Fragment,{children:e})},rt=({children:e})=>{const{selfClientId:t}=B(),n=d.useMemo(()=>Ce(),[]),r=n(i=>i.setPeers),s=d.useMemo(()=>({useShareNearbyStore:n}),[n]);return T({pathname:"/clients/stream",eventKey:L.CurrentPeers,onOpen(){r([])},onError(){r([])},onMessage:({peers:i})=>{const a=[...i.filter(({clientId:c})=>c!==t)].sort((c,S)=>c.clientId.localeCompare(S.clientId));r(a)}}),o.jsxs(M.Provider,{value:s,children:[e,o.jsx(ze,{})]})};export{Ue as S,rt as a,tt as b,P as g,nt as u};
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="03367189-210d-592c-8935-521bf8d67917")}catch(e){}}()
3//# debugId=03367189-210d-592c-8935-521bf8d67917
4//# sourceMappingURL=share-nearby-provider-CoGBu4zh.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.