1import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{bt as t,ut as n,wt as r}from"./vendor-Bb9yCo9K.js";import{t as i}from"./vendor-i18n-C715PcBm.js";import{p as a}from"./session-CrIHvR3Q.js";import{t as o}from"./authStore-Dtvixuf6.js";import{h as s,p as c}from"./index-Bbv-53qk.js";import{t as l}from"./RemoteImage-B6DlP5IB.js";import{i as u}from"./messageCard-q28SQzd1.js";import{n as d,t as f}from"./DeleteMenuAction-B9UxEFZW.js";import{t as p}from"./PageStatusState-BMoqM_4H.js";import{t as m}from"./EmptyContentState-BRzhgaI6.js";var h=e(r(),1),g=t(),_=220,v=`cubic-bezier(0.22, 1, 0.36, 1)`;function y(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=new Set(t.map(n)),a=t.map(e=>{let t=n(e),i=r.get(t);return{id:t,phase:i?.phase===`entering`?`entering`:i?`stable`:`entering`,snapshot:e}});return e.forEach((e,t)=>{if(i.has(e.id))return;let n=Math.min(t,a.length);a.splice(n,0,{...e,phase:`exiting`})}),a}function b({className:e,getKey:t,itemClassName:n,items:r,renderItem:i}){let a=(0,h.useRef)(new Map),o=(0,h.useRef)(new Map),s=(0,h.useRef)(new Map),c=(0,h.useRef)(null),l=r.map(t).join(`�`),u=(0,h.useRef)(l),d=(0,h.useMemo)(()=>new Map(r.map(e=>[t(e),e])),[t,r]),[f,p]=(0,h.useState)(()=>r.map(e=>({id:t(e),phase:`stable`,snapshot:e}))),m=(0,h.useCallback)(()=>{let e=new Map;return a.current.forEach((t,n)=>{e.set(n,t.getBoundingClientRect())}),e},[]);return(0,h.useLayoutEffect)(()=>{u.current!==l&&(c.current=m(),u.current=l,p(e=>y(e,r,t)))},[t,r,m,l]),(0,h.useLayoutEffect)(()=>{let e=c.current;e&&(c.current=null,!(window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1)&&f.forEach(t=>{if(t.phase!==`stable`)return;let n=a.current.get(t.id),r=e.get(t.id);if(!n||!r||typeof n.animate!=`function`)return;let i=n.getBoundingClientRect(),o=r.left-i.left,c=r.top-i.top;if(Math.abs(o)<.5&&Math.abs(c)<.5)return;s.current.get(t.id)?.cancel();let l=n.animate([{transform:`translate3d(${o}px, ${c}px, 0)`},{transform:`translate3d(0, 0, 0)`}],{duration:_,easing:v});s.current.set(t.id,l),l.finished.catch(()=>void 0).finally(()=>{s.current.get(t.id)===l&&s.current.delete(t.id)})}))},[f]),(0,h.useEffect)(()=>{f.forEach(e=>{if(e.phase===`stable`||o.current.has(e.id))return;let t=window.setTimeout(()=>{if(o.current.delete(e.id),e.phase===`entering`){p(t=>t.map(t=>t.id===e.id&&t.phase===`entering`?{...t,phase:`stable`}:t));return}c.current=m(),p(t=>t.filter(t=>t.id!==e.id||t.phase!==`exiting`))},_);o.current.set(e.id,t)})},[m,f]),(0,h.useEffect)(()=>()=>{o.current.forEach(e=>window.clearTimeout(e)),o.current.clear(),s.current.forEach(e=>e.cancel()),s.current.clear()},[]),(0,g.jsx)(`div`,{className:e,"data-testid":`im-conversation-list`,children:f.map(e=>{let t=d.get(e.id)??e.snapshot;return(0,g.jsx)(`div`,{className:n,"data-motion-phase":e.phase,ref:t=>{t?a.current.set(e.id,t):a.current.delete(e.id)},children:i(t)},e.id)})})}var x={rowShell:`_rowShell_4gf0w_1`,menu:`_menu_4gf0w_6`};function S({deleting:e,label:t,onDelete:n}){return(0,g.jsx)(`div`,{className:x.menu,role:`menu`,"data-conversation-delete-menu":`true`,"data-testid":`conversation-delete-menu`,children:(0,g.jsx)(f,{deleting:e,label:t,onDelete:n})})}var C={page:`_page_1pwin_1`,creatorList:`_creatorList_1pwin_20`,creatorRow:`_creatorRow_1pwin_24`,creatorContent:`_creatorContent_1pwin_30`,creatorMeta:`_creatorMeta_1pwin_33`,creatorNameLine:`_creatorNameLine_1pwin_41`,creatorActivity:`_creatorActivity_1pwin_45`,rowAvatar:`_rowAvatar_1pwin_60`,rowAvatarLive:`_rowAvatarLive_1pwin_61`,deactivatedBadge:`_deactivatedBadge_1pwin_72`,header:`_header_1pwin_81`,accountMenu:`_accountMenu_1pwin_105`,accountAvatar:`_accountAvatar_1pwin_111`,accountPopover:`_accountPopover_1pwin_126`,logoutButton:`_logoutButton_1pwin_163`,liveSection:`_liveSection_1pwin_188`,liveScroller:`_liveScroller_1pwin_200`,liveCard:`_liveCard_1pwin_219`,liveAvatar:`_liveAvatar_1pwin_240`,allSection:`_allSection_1pwin_278`,creatorRowMotion:`_creatorRowMotion_1pwin_306`,"conversation-enter":`_conversation-enter_1pwin_1`,conversationEnter:`_conversation-enter_1pwin_1`,"conversation-exit":`_conversation-exit_1pwin_1`,conversationExit:`_conversation-exit_1pwin_1`,emptyState:`_emptyState_1pwin_475`},w=500,T=8,E=new Set([`biz_guid`,`biz_wish_guid`,`bizWishGuid`,`card_type`,`cardType`,`guid`,`type`,`wish_guid`,`wishGuid`]);function D(e){if(!e)return{};try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`string`))}catch{return{}}}function O(e){return Object.keys(D(e)).some(e=>E.has(e))}function k(e,t){switch(e.trim().toLowerCase()){case`[image]`:return t.image;case`[audio]`:case`[voice]`:return t.voice;default:return``}}function A(e){let t={...e?.customData??{}};for(let n of Object.values(e?.customData??{}))Object.assign(t,D(n));return Object.assign(t,D(e?.content)),t}function ee(e,t){if(!e)return``;if(e.contentType===`image`)return t.image;if(e.contentType===`voice`)return t.voice;if(e.card&&u(e.card))return t.pollCard;
1if(e.card)return e.card.fallback?.trim()||e.card.title.trim()||t.card;if(e.contentType===`custom`){let n=A(e),r=(n.fallback||n.summary||n.title||e.content||``).trim();return k(r,t)||(!r||O(r)?``:r)}let n=e.content?.trim()??``;return k(n,t)||(O(n)?``:n)}function te(e,t){if(!e)return``;let n=new Date(Number(e));return Number.isNaN(n.getTime())?``:new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`}).format(n)}function ne(e,t){return t?.displayName?.trim()||e.title?.trim()||e.peerUid}function re(e,t){return t?.avatarUrl||e.avatar||``}function j(e){return typeof e==`number`&&e>0}function M(e,t){return e.avatarUrl===t.avatarUrl&&e.cid===t.cid&&e.creatorDeactivated===t.creatorDeactivated&&e.deactivatedLabel===t.deactivatedLabel&&e.creatorName===t.creatorName&&e.lastMessagePreview===t.lastMessagePreview&&e.lastMessageTime===t.lastMessageTime&&e.peerUid===t.peerUid&&e.profileUsername===t.profileUsername&&e.selected===t.selected&&e.unread===t.unread}function ie(e){return e.cid}var ae=(0,h.memo)(function({deleteLabel:e,deleteMenuOpen:t,deleting:n,model:r,onDelete:i,onOpen:a,onRequestDelete:o}){let s=!!(r.lastMessageTime||j(r.unread)),c=(0,h.useRef)(!1),u=(0,h.useRef)(null),d=(0,h.useRef)(null),f=(0,h.useRef)(!1),p=(0,h.useCallback)(()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),d.current=null},[]);(0,h.useEffect)(()=>p,[p]);let m=e=>{if(f.current){f.current=!1,e.preventDefault();return}a(r)},_=e=>{e.preventDefault(),o(r)},v=e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||!e.isPrimary||e.button!==0||(p(),c.current=!1,f.current=!1,d.current={x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture?.(e.pointerId),u.current=window.setTimeout(()=>{u.current=null,d.current=null,c.current=!0,o(r)},w))},y=e=>{let t=d.current;t&&(Math.abs(e.clientX-t.x)>T||Math.abs(e.clientY-t.y)>T)&&p()},b=()=>{let e=c.current;p(),c.current=!1,e&&(f.current=!0)},E=()=>{p(),c.current=!1};return(0,g.jsxs)(`div`,{className:x.rowShell,children:[(0,g.jsxs)(`button`,{className:C.creatorRow,type:`button`,"aria-current":r.selected?`page`:void 0,"data-selected":r.selected,"data-testid":`im-conversation-${r.cid}`,onClick:m,onContextMenu:_,onLostPointerCapture:E,onPointerCancel:E,onPointerDown:v,onPointerMove:y,onPointerUp:b,children:[(0,g.jsx)(`span`,{className:C.rowAvatar,children:(0,g.jsx)(l,{sources:[r.avatarUrl],alt:``,size:`100%`})}),(0,g.jsxs)(`span`,{className:C.creatorContent,children:[(0,g.jsxs)(`span`,{className:C.creatorMeta,children:[(0,g.jsxs)(`span`,{className:C.creatorNameLine,children:[(0,g.jsx)(`strong`,{children:r.creatorName}),r.creatorDeactivated?(0,g.jsx)(`span`,{className:C.deactivatedBadge,children:r.deactivatedLabel}):null]}),r.lastMessagePreview?(0,g.jsx)(`small`,{children:r.lastMessagePreview}):null]}),s?(0,g.jsxs)(`span`,{className:C.creatorActivity,"aria-hidden":`true`,children:[r.lastMessageTime?(0,g.jsx)(`time`,{children:r.lastMessageTime}):null,j(r.unread)?(0,g.jsx)(`em`,{children:r.unread}):null]}):null]})]}),t?(0,g.jsx)(S,{deleting:n,label:e,onDelete:()=>i(r)}):null]})},(e,t)=>e.deleteLabel===t.deleteLabel&&e.deleteMenuOpen===t.deleteMenuOpen&&e.deleting===t.deleting&&e.onDelete===t.onDelete&&e.onOpen===t.onOpen&&e.onRequestDelete===t.onRequestDelete&&M(e.model,t.model));function N({layout:e=`default`,selectedPeerUid:t=``,showAccountMenu:r=!0,showHeader:u=!0,showSectionTitle:f=!0,surface:_=`default`,title:v}={}){let{i18n:y,t:x}=i(),S=y?.resolvedLanguage||y?.language||`en`,w=n(),T=o(e=>e.account),E=o(e=>e.reset),D=c(e=>e.deleteConversation),O=c(e=>e.disconnect),k=c(e=>e.conversationListStatus),A=c(e=>e.conversationOrder),j=c(e=>e.conversationsByCid),M=c(e=>e.error),N=c(e=>e.loadCreatorProfile),P=c(e=>e.profilesByPeerUid),F=c(e=>e.syncConversations),I=(0,h.useRef)(null),L=(0,h.useRef)(null),[R,z]=(0,h.useState)(!1),[B,V]=(0,h.useState)(null),[H,U]=(0,h.useState)(null),[W,oe]=(0,h.useState)(!1),G=(0,h.useMemo)(()=>({card:x(`creators.cardMessagePreview`),image:x(`creators.imageMessagePreview`),pollCard:x(`creators.pollCardMessagePreview`),voice:x(`creators.voiceMessagePreview`)}),[x]),K=(0,h.useMemo)(()=>A.map(e=>j[e]).filter(e=>!!e),[A,j]),q=T?.userDto,J=q?.username||q?.email?.split(`@`)[0]||x(`creators.accountFallbackName`),Y=q?.email||x(`creators.accountEmailFallback`),se=q?.avatarUrl||``,ce=K.length===0&&typeof F==`function`&&k!==`ready`&&k!==`error`,X=k===`error`&&M?d(M):``,Z=(0,h.useMemo)(()=>K.map(e=>{let n=P[e.peerUid];return{avatarUrl:re(e,n),cid:e.cid,creatorDeactivated:!!n?.deactivated,deactivatedLabel:x(`creators.deactivated`),creatorName:ne(e,n),lastMessagePreview:ee(e.lastMessage,G),lastMessageTime:te(e.lastMessage?.timestamp||e.updateTime,S),peerUid:e.peerUid,profileUsername:n?.profileCode,selected:t===e.peerUid,unread:e.unread}}),[K,S,G,P,t,x]),Q=(0,h.useCallback)(e=>{V(null),s(e.peerUid,{avatarUrl:e.avatarUrl,creatorName:e.creatorName,profileUsername:e.profileUsername}),w(`/creator-chat/${encodeURIComponent(e.peerUid)}`,{state:{avatarUrl:e.avatarUrl,cid:e.cid,creatorDeactivated:e.creatorDeactivated,creatorName:e.creatorName,profileUsername:e.profileUsername}})},[w]),$=(0,h.useCallback)(e=>{V(e.cid)},[]),le=(0,h.useCallback)(async e=>{if(!L.current){L.current=e.cid,U(e.cid);try{await D(e.cid),V(null),e.selected&&w(`/chats`,{replace:!0})}finally{L.current=null,U(null)}}},[D,w]),ue=(0,h.useCallback)(e=>(0,g.jsx)(ae,{deleteLabel:x(`creators.deleteConversation`),deleteMenuOpen:B===e.cid,deleting:H===e.cid,model:e,onDelete:le,onOpen:Q,onRequestDelete:$}),[B,H,le,Q,$,x]);return(0,h.useEffect)(()=>
1{if(!R)return;let e=e=>{I.current?.contains(e.target)||z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t)}},[R]),(0,h.useEffect)(()=>{if(!B)return;let e=e=>{(!(e.target instanceof Element)||!e.target.closest(`[data-conversation-delete-menu="true"]`))&&V(null)},t=e=>{e.key===`Escape`&&V(null)};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t)}},[B]),(0,h.useEffect)(()=>{typeof F==`function`&&F().catch(()=>void 0)},[F]),(0,h.useEffect)(()=>{for(let e of K)N(e.peerUid)},[K,N]),(0,g.jsxs)(`main`,{className:C.page,"data-layout":e,"data-surface":_,children:[u?(0,g.jsxs)(`header`,{className:C.header,children:[(0,g.jsx)(`div`,{children:(0,g.jsx)(`h1`,{children:v||x(`creators.title`)})}),r?(0,g.jsxs)(`div`,{className:C.accountMenu,ref:I,children:[(0,g.jsx)(`button`,{className:C.accountAvatar,type:`button`,"aria-label":x(`creators.accountMenu`),"aria-expanded":R,onClick:()=>z(e=>!e),children:(0,g.jsx)(l,{sources:[se],alt:``,size:`100%`})}),R?(0,g.jsxs)(`div`,{className:C.accountPopover,role:`menu`,children:[(0,g.jsx)(`strong`,{title:J,children:J}),(0,g.jsx)(`span`,{title:Y,children:Y}),(0,g.jsxs)(`button`,{className:C.logoutButton,type:`button`,role:`menuitem`,onClick:async()=>{if(!W){oe(!0);try{await a()}catch{}finally{O(),E(),w(`/landing`,{replace:!0})}}},disabled:W,children:[(0,g.jsx)(`i`,{className:`iconfont icon-dengchu`,"aria-hidden":`true`}),x(W?`creators.signingOut`:`creators.signOut`)]})]}):null]}):null]}):null,ce?(0,g.jsx)(`section`,{className:C.emptyState,children:(0,g.jsx)(`p`,{children:x(`creators.loading`)})}):Z.length>0?(0,g.jsxs)(`section`,{className:C.allSection,"aria-label":f?void 0:v||x(`creators.title`),"aria-labelledby":f?`all-conversations-title`:void 0,children:[f?(0,g.jsx)(`h2`,{id:`all-conversations-title`,children:x(`creators.allCreators`)}):null,(0,g.jsx)(b,{className:C.creatorList,getKey:ie,itemClassName:C.creatorRowMotion,items:Z,renderItem:ue})]}):(0,g.jsx)(g.Fragment,{children:X?(0,g.jsx)(p,{kind:X,variant:`chat`,onRefresh:()=>{typeof F==`function`&&F().catch(()=>void 0)}}):(0,g.jsx)(m,{description:x(`emptyStates.chatsDescription`,{defaultValue:`Slide into a conversation with a creator your messages will show up right here.`}),title:x(`emptyStates.chatsTitle`,{defaultValue:`It's too quiet here, isn't it?`}),variant:e===`mobile`?`chat-mobile`:`chat-sidebar`})})]})}export{N as ChatListPage};
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.