k2-im 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/chat-kit-pinia.d.ts +5 -5
- package/dist/chat-kit-pinia.js +1 -1
- package/dist/chat-kit-vue.d.ts +2 -2
- package/dist/chat-kit-vue.js +1 -1
- package/dist/chat-kit.d.ts +130 -26
- package/dist/chat-kit.js +1 -1
- package/dist/chunk-GMVR64GN.js +7 -0
- package/dist/chunk-LX7YEO5G.js +2 -0
- package/dist/chunk-SVJGRV4M.js +2 -0
- package/dist/chunk-UNGWXAYA.js +1 -0
- package/dist/{chunk-FUEAUHMC.js → chunk-V7ULSSTZ.js} +1 -1
- package/dist/chunk-VMKTMZ3K.js +1 -0
- package/dist/chunk-WYQXQOLW.js +2 -0
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +1 -1
- package/dist/index.d.ts +1039 -937
- package/dist/index.js +1 -1
- package/dist/sdk.d.ts +9 -9
- package/dist/sdk.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EM4YNWX4.js +0 -2
- package/dist/chunk-HNSTHP6F.js +0 -2
- package/dist/chunk-HQ7FTY2C.js +0 -1
- package/dist/chunk-MO2EU56Q.js +0 -7
- package/dist/chunk-W5SQGPRQ.js +0 -2
- package/dist/chunk-YQSRQ25X.js +0 -1
package/dist/chat-kit-vue.d.ts
CHANGED
|
@@ -572,12 +572,12 @@ interface ImMessage {
|
|
|
572
572
|
body: ImMessageBody;
|
|
573
573
|
/** P0 统一毫秒 number(本地创建时间,乐观渲染用)。 */
|
|
574
574
|
createdAt: number;
|
|
575
|
-
/**
|
|
575
|
+
/** SDK 内部排序键;有效服务端时间优先,ACK 后可以更新。宿主不解析它,消息身份始终使用 id。 */
|
|
576
576
|
sortKey: string;
|
|
577
577
|
status: MessageSendStatus;
|
|
578
578
|
/** 失败原因(status==='failed' 时)。 */
|
|
579
579
|
failure?: ImMessageFailure;
|
|
580
|
-
/**
|
|
580
|
+
/** 服务端回传的 epoch 毫秒时间;有效时用于正式排序与展示,createdAt 仍保留创建记录。 */
|
|
581
581
|
serverTime?: number;
|
|
582
582
|
/** P0 默认 'unread'。 */
|
|
583
583
|
receipt: MessageReceipt;
|
package/dist/chat-kit-vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-YQSRQ25X.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-HQ7FTY2C.js';import'./chunk-EM4YNWX4.js';import'./chunk-MO2EU56Q.js';import'./chunk-W5SQGPRQ.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function Ut(t){let a=0,v=0;for(let f of t)f.kind==="video"?v+=1:a+=1;return {imageCount:a,videoCount:v}}function qt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.mediaAlbum===void 0?{}:{mediaAlbum:Ut(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var St=Symbol("ImThreadReadActions");function Pt(t){provide(St,t);}function zt(){return inject(St,void 0)}var qe=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:v}){return Pt(t.readActions),()=>{let f=h(t.message),m=t.rendererRegistry.resolve(f);return m!==void 0?h$1(m,{...a,message:t.message,presentation:t.presentation}):v["unsupported-body"]!==void 0?v["unsupported-body"]({kind:f,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":f,"aria-hidden":"true"})}}});var Ge=Symbol("ImThreadViewportRegistration");function At(){return inject(Ge,void 0)}var We=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let v=At();function f(o,d){let I=Array.isArray(d)?d:[d];return I.length===1&&isVNode(I[0])?cloneVNode(I[0],{key:o}):h$1(Fragment,{key:o},I)}function m(o){return d=>{v?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function k(o,d){return I=>{v?.registerDateNode(o,d,I instanceof HTMLElement?I:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function p(o){let d=k(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function w(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function R(o){let d=m(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:d}):h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(qe,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:I=>a["unsupported-body"]?.(I)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,M(o));case "date-separator":return a.item!==void 0?f(o.key,a.item({item:o,setElement:k(o.key,o.label)})):f(o.key,p(o));case "entry-unread":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,w(o));case "system":case "message":return f(o.key,R(o))}return o}))}});var Vt=120,ir=500,le=.5,ar=8,ze=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:v,slots:f}){let m$1=ref(null),k=ref(null),M=new Map,p$1=new Map,w=new Set,R=new Map,o$1=0,d=[],I,H,O,N,X=false,x,U=new Set,Y=false,L,G="",s=1,F=false,J=false,_=true,D=false,Q=false,j$1=false,$=0,Z=-1,ie=-1,u,S,h,c,P,B$1=ref(true),q$1=ref(0),W=C(e=>{q$1.value=e,a("new-message-count",e);});function ye(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function fe(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let T=i.getBoundingClientRect(),y=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:T.top,bottom:T.bottom,anchorTop:y?.getBoundingClientRect().top??T.top}]})}function Se(e="",n=1){let i=Math.min(1,Math.max(0,n));G!==""&&G!==e&&R.get(G)?.element.style.removeProperty("opacity"),G=e,s=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function ae(){Se();}function Pe(){let e=m$1.value;if(Y||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,A])=>e.contains(A.element)).map(([A,C])=>{let z=C.element.getBoundingClientRect();return {key:A,label:C.label,top:z.top,height:z.height}}).sort((A,C)=>A.top-C.top),i=e.getBoundingClientRect(),T=n.find(A=>A.height>0)?.height??28,y=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:T});if(y===null){ae(),a("active-date-change",null);return}Se(y.inlineDateKey,y.inlineOpacity),a("active-date-change",y);}function Ve(e){H={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Ee(e){let n=H;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=le}function Ae(e){return Ee(e)||L!==void 0&&(L.behavior==="smooth"||Math.abs(e.scrollTop-L.targetTop)<=le)?0:e.scrollTop-o$1}function me(e,n){n!==0&&(o$1=e.scrollTop-n,L=void 0,g$1());}function je(e,n){let i=Ae(e);if(c!==void 0)return c.expectedOffset-=i,se(),me(e,i),D||oe(),false;let T=H;if(T===void 0)return false;let y=I,A=y===void 0?void 0:fe([y.id])[0],C=e.scrollTop-T.scrollTop,z=Ee(e)?0:C,we=y===void 0||A===void 0?0:(A.anchorTop??A.top)-n.top-y.offset+C;return T.scrollHeight!==e.scrollHeight||T.width!==e.clientWidth||T.height!==e.clientHeight||Math.abs(we)>le?(H=void 0,!F&&!t.loadingNewer&&t.resizeFollowEnabled&&B$1.value&&Math.abs(z)<=le?(Ke(),true):(y!==void 0&&ke({...y,offset:y.offset-z}),me(e,i),false)):false}function ee(){let e=m$1.value;if(Y||e===null)return;let n=e.getBoundingClientRect();if(je(e,n))return;let i=N!==void 0&&X?t.messageIds.filter(C=>w.has(C)):t.messageIds,T=fe(i);if(N!==void 0&&X&&T.length===0){B$1.value=ye(e);return}let y=T.filter(C=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:C.top,messageBottom:C.bottom,margin:t.visibleMargin})).map(C=>C.id),A=y.length!==d.length||y.some((C,z)=>d[z]!==C);d=Object.freeze(y),I=o(T,{top:n.top,bottom:n.bottom}),Ve(e),W.acknowledgeVisible(y),B$1.value=ye(e),A&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:B$1.value,newMessageCount:q$1.value});}function ge(e){if(U.add(e),x!==void 0)return;let n=()=>{x=void 0;let i=[...U];U.clear(),i.forEach(T=>T());};typeof globalThis.requestAnimationFrame=="function"?x=globalThis.requestAnimationFrame(n):x=globalThis.setTimeout(n,0);}function Oe(){x!==void 0&&(typeof x=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(x):globalThis.clearTimeout(x),x=void 0,U.clear());}function re(){ge(ee);}function be(){let e=m$1.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(fe(),{top:n.top,bottom:n.bottom});i!==void 0&&(I=i,Ve(e));}function ve(){return _&&c===void 0&&!J&&!t.loadingOlder}function Ce(){be(),_=false,Z=$,J=true,a("reach-start"),ge(()=>{t.loadingOlder||(J=false);});}function xe(e){return t.hasNewer&&!F&&!t.loadingOlder&&!t.loadingNewer&&ye(e)}function r(){F=true,B$1.value=false,ie=$,a("reach-end"),ge(()=>{t.loadingNewer||(F=false);});}function l(){let e=m$1.value;e===null||$===ie||!xe(e)||r();}function g$1(){let e=m$1.value;if(Y||e===null)return;let n=e.scrollTop,i=Ee(e),T=L,y=false;if(T!==void 0){let C=Math.abs(n-T.targetTop)<=le;y=T.behavior==="smooth"||C,(T.behavior!=="smooth"||C)&&(L=void 0);}!y&&!i&&!D&&c===void 0&&n!==o$1&&(D=true,Q=true,$+=1);let A=D&&!y&&!i&&n!==o$1;if(A&&(a("user-scroll"),ge(Pe)),D&&!j$1&&Te(),!_&&Q&&$!==Z&&n<o$1&&n>Ze()&&(_=true),c!==void 0&&!y)if(D){let C=K();C!==void 0&&(c.expectedOffset=C);}else se(),oe();ve()&&A&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&Ce(),A&&xe(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:ye(e),isHistoryWindow:t.hasNewer,isPageSettling:y})&&r(),o$1=n,re();}function b(e,n="auto"){L={targetTop:e,behavior:n};}function V(e){let n=c,i=k.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=le?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function E(){P!==void 0&&(clearTimeout(P),P=void 0),c!==void 0&&c.visualOffset!==0&&(I=void 0,H=void 0);let e=k.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),c=void 0,L=void 0;}function K(){let e=m$1.value,n=c;if(e===null||n===void 0)return;let i=fe().find(T=>T.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function se(){let e=c,n=K();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=le||(V(e.visualOffset+i),e.committed=false,e.attempts=0);}function ne(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,!(D||c?.committed!==true)&&E();},ir);}function he(){let e=m$1.value,n=c;if(Y||e===null||n===void 0||D)return;let i=n.visualOffset;if(Math.abs(i)<=le){n.committed=true,ne();return}let T=Math.max(0,e.scrollHeight-e.clientHeight),y=Math.min(T,Math.max(0,e.scrollTop-i));if(b(y),e.scrollTop=y,Math.abs(e.scrollTop-y)>le){L=void 0,n.committed=false,n.attempts+=1,n.attempts<ar?oe():(E(),L=void 0,o$1=e.scrollTop);return}V(0),o$1=e.scrollTop,n.expectedOffset=K()??n.expectedOffset,n.committed=true,n.attempts=0,ne();}function oe(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,he();},Vt);}function Ie(e){e!==void 0&&(c===void 0&&(c={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),se(),!D&&he());}function ke(e){let n=m$1.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),T=q(e,fe(),{top:i.top,bottom:i.bottom});if(T!==void 0){let y=Math.max(0,n.scrollHeight-n.clientHeight),A=Math.min(y,Math.max(0,n.scrollTop+T));b(A),n.scrollTop=A,o$1=n.scrollTop,H=void 0;}}function Ze(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){L?.behavior==="smooth"&&(L=void 0),Q=false,D||(D=true,$+=1),u!==void 0&&(clearTimeout(u),u=void 0);}function Ne(){let e=m$1.value;e===null||$===Z||(c!==void 0&&E(),_=true,e.scrollTop<=Ze()&&ve()&&Ce());}function et(){I=void 0,H=void 0,u!==void 0&&(clearTimeout(u),u=void 0),E(),D=false,Q=false,j$1=false,S=void 0,h=void 0,$+=1,Z=-1,ie=-1,_=true,J=false,F=false,L=void 0;}function tt(){j$1||(u!==void 0&&(clearTimeout(u),u=void 0),D=false,Q=false,c!==void 0&&(c.attempts=0),he());}function Te(){j$1||(u!==void 0&&clearTimeout(u),u=setTimeout(()=>{u=void 0,tt();},Vt));}function rt(){L=void 0,tt();}function nt(e){j$1=true,De(),S=e.touches?.[0]?.clientY;}function ot(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(S!==void 0&&n>S?Ne():S!==void 0&&n<S&&l(),S=n);}function Le(){j$1=false,S=void 0,Te();}function it(e){De(),e.deltaY<0?Ne():e.deltaY>0&&l(),Te();}function at(e){e.pointerType!=="touch"&&(De(),h=e.clientY,Te());}function st(e){e.pointerType==="touch"||!D||h===void 0||(e.clientY<h?Ne():e.clientY>h&&l(),h=e.clientY,Te());}function He(e){e.pointerType!=="touch"&&(h=void 0,Te());}function lt(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Ne():l(),Te());}function Ke(e="auto"){let n=m$1.value;if(n===null)return;H=void 0,E();let i=Math.max(0,n.scrollHeight-n.clientHeight);b(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,W.clear(),ee();}function dt(){let e=m$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Dt(){let e=m$1.value;return dt()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Nt(e,n={}){let i=m$1.value,T=M.get(e);if(i===null||T===void 0||!i.contains(T)||i.clientHeight<=0)return false;E();let y=i.getBoundingClientRect(),A=T.getBoundingClientRect(),C=n.block??"center",z;C==="start"?z=i.scrollTop+A.top-y.top:C==="end"?z=i.scrollTop+A.bottom-y.bottom:C==="nearest"?A.top>=y.top&&A.bottom<=y.bottom?z=i.scrollTop:A.top<y.top?z=i.scrollTop+A.top-y.top:z=i.scrollTop+A.bottom-y.bottom:z=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:A.height,targetTop:A.top,viewportHeight:i.clientHeight,viewportTop:y.top});let we=Math.max(0,i.scrollHeight-i.clientHeight),pe=Math.min(we,Math.max(0,z));H=void 0;let Me=n.behavior??"auto";return b(pe,Me),i.scrollTo?.({top:pe,behavior:Me}),i.scrollTop!==pe&&(i.scrollTop=pe),o$1=i.scrollTop,ee(),true}function Lt(){W.clear();}function Ht(){F=true,B$1.value=false;}function Bt(){F=false,re();}function Ft(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(N?.unobserve(i),O?.unobserve?.(i),p$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),p$1.set(n,e),N?.observe(n),O?.observe(n),re();}function _t(e,n,i){let T=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),G===e&&i.style.setProperty("opacity",String(s)),T?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(Ge,{registerMessageNode:Ft,registerDateNode:_t}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;et();let i=m$1.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=m$1.value;if(i===null)return;let T=new Set(n);n.length>0&&e.length>0&&!e.some(Be=>T.has(Be))&&et();let A=i.getBoundingClientRect(),C=p(I,fe(),{top:A.top,bottom:A.bottom}),z=B$1.value,we=n[n.length-1],pe=we===void 0?-1:e.indexOf(we),Me=pe<0?[]:e.slice(pe+1).filter(Be=>!T.has(Be)),jt=F||t.loadingNewer;if(await nextTick(),Y)return;let ut=n[0];if(ut!==void 0&&e.indexOf(ut)>0&&(J=false,Ie(C)),Me.length>0){if(jt){F=false,c===void 0&&ke(C),B$1.value=false,re();return}(z||Me.some(Kt=>t.shouldFollowAppendedMessage?.(Kt)===true))&&t.followNewMessages?Ke():W.add(Me);}re();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!F||ge(()=>{t.loadingNewer||(F=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!J||ge(()=>{t.loadingOlder||(J=false);});},{flush:"pre"}),onMounted(()=>{let e=m$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",g$1,{passive:true}),e.addEventListener("scrollend",rt,{passive:true}),e.addEventListener("touchstart",nt,{passive:true}),e.addEventListener("touchmove",ot,{passive:true}),e.addEventListener("touchend",Le,{passive:true}),e.addEventListener("touchcancel",Le,{passive:true}),e.addEventListener("wheel",it,{passive:true}),e.addEventListener("pointerdown",at,{passive:true}),e.addEventListener("pointermove",st,{passive:true}),e.addEventListener("pointerup",He,{passive:true}),e.addEventListener("pointercancel",He,{passive:true}),e.addEventListener("keydown",lt),typeof globalThis.ResizeObserver=="function"){O=new globalThis.ResizeObserver(()=>{Y||m$1.value===null||ee();}),O.observe(e),k.value!==null&&O.observe(k.value);for(let n of M.values())O.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){N=new globalThis.IntersectionObserver(n=>{for(let i of n){let T=p$1.get(i.target);T!==void 0&&(i.isIntersecting?w.add(T):w.delete(T));}X=true,re();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())N.observe(n);}re();}}),onBeforeUnmount(()=>{Y=true;let e=m$1.value;e!==null&&e.removeEventListener("scroll",g$1),e!==null&&(e.removeEventListener("scrollend",rt),e.removeEventListener("touchstart",nt),e.removeEventListener("touchmove",ot),e.removeEventListener("touchend",Le),e.removeEventListener("touchcancel",Le),e.removeEventListener("wheel",it),e.removeEventListener("pointerdown",at),e.removeEventListener("pointermove",st),e.removeEventListener("pointerup",He),e.removeEventListener("pointercancel",He),e.removeEventListener("keydown",lt)),u!==void 0&&clearTimeout(u),E(),Oe(),O?.disconnect(),N?.disconnect(),ae(),M.clear(),p$1.clear(),w.clear(),R.clear(),W.clear();}),v({getViewportElement:()=>m$1.value,clearNewMessageBadge:Lt,clearActiveDate:ae,isAtBottom:computed(()=>B$1.value),isMeasurable:dt,isScrollable:Dt,newMessageCount:computed(()=>q$1.value),prepareHistoryPageAppend:Ht,cancelHistoryPageAppend:Bt,trackRemoteMessageIds:(e,n)=>W.trackRemote(e,n),scrollToLatest:Ke,scrollToMessage:Nt,focusViewport:()=>m$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:m$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:k,"data-im-thread-viewport-content":""},f.default?.())])}});var Ct=Symbol("ImThreadSurfaceContext");function dr(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function ur(t){provide(Ct,t);}function Ye(){let t=inject(Ct);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Xe=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Je=Object.freeze({enabled:true,maxFillPages:8}),mr=8,gr=160;function pr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var vr=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:v}){let f=t.context??Ye(),m=ref(null),k=ref(0),M=ref(true),p=[],w,R=0,o=0,d=null,I="",H="",O="",N=false,X=false,x=ref(false),U=ref(""),Y=ref(false),L,G,s=computed(()=>f.getState()),F=computed(()=>s.value.pageVisible??f.isPageVisible?.()??true),J=computed(()=>s.value.pageEngaged??f.isPageEngaged?.()??true),_=computed(()=>pr(s.value.activeConversation,t.conversation)),D=computed(()=>({...Xe,...t.viewportOptions})),Q=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Je.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Je.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Je.maxFillPages}}),j=computed(()=>!_.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),$=computed(()=>_.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:f.formatDate,leadingItems:f.leadingItems?.(),beforeMessageItems:f.beforeMessageItems}):[]),Z=computed(()=>$.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ie(){L!==void 0&&(clearTimeout(L),L=void 0),G!==void 0&&(clearTimeout(G),G=void 0);}function u(r=false){if(ie(),Y.value=false,r){m.value?.clearActiveDate(),U.value="";return}G=setTimeout(()=>{G=void 0,!Y.value&&(m.value?.clearActiveDate(),U.value="");},gr);}function S(r){if(r===null){u();return}ie(),U.value=r.label,Y.value=true;let l=D.value.activeDateIdleDelay,g=Number.isFinite(l)?Math.max(0,l):Xe.activeDateIdleDelay;L=setTimeout(()=>{L=void 0,u();},g);}async function h(r,l){t.hooks?.beforeAction?.(r);try{let g=await l();return t.hooks?.afterAction?.(r,g),g}catch(g){throw t.hooks?.onError?.(r,g),g}}function c(r="automatic"){return !_.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):h({kind:"load-older",source:r},()=>f.actions.loadOlder())}function P(){let r=f.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !_.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):h({kind:"load-newer"},()=>r())}async function B(r){for(let l=0;l<mr;l+=1){if(!_.value)return;let g=r==="older"?s.value.hasOlder:s.value.hasNewer,b=r==="older"?s.value.olderError:s.value.newerError;if(!g||b!==null||(r==="older"?await c("user-scroll"):await P())>0)return;let E=r==="older"?s.value.hasOlder:s.value.hasNewer,K=r==="older"?s.value.olderError:s.value.newerError;if(!E||K!==null)return}}async function q(){return !_.value||f.actions.loadNewer===void 0?0:h({kind:"load-newer"},()=>f.actions.retryNewer?.()??f.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function W(){if(!_.value)return 0;let r=j.value,l=++R;d=null,O="";let g;try{g=await h({kind:"retry-older"},()=>f.actions.retryOlder?.()??f.actions.loadOlder({force:!0}));}catch(b){throw ee(r,l)&&(O=r),b}return ee(r,l)&&!x.value&&(d=null,be()),g}async function ye(){if(!_.value)return false;let r=await h({kind:"jump-to-latest"},()=>f.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow));return r&&(await nextTick(),m.value?.scrollToLatest()),r}function fe(r){M.value=r.isAtBottom,k.value=r.newMessageCount,be();}function Se(r,l){return m.value?.scrollToMessage(r,l)??false}function ae(r,l){return !X&&o===l&&j.value===r&&_.value}async function Pe(r,l,g,b){for(let V=0;V<60;V+=1){if(!ae(r,l))return false;if(Se(g,b))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}async function Ve(r,l,g){let b=m.value;if(b===null||!b.isMeasurable()||b.isScrollable())return true;let V=0,E=!s.value.hasOlder,K=!s.value.hasNewer||f.actions.loadNewer===void 0,se=async()=>(await nextTick(),await nextTick(),Pe(r,l,g,{behavior:"auto",block:"center"})),ne=async oe=>{if(!ae(r,l)||V>=Q.value.maxFillPages)return false;let Ie=0;if(oe==="older"){if(E||!s.value.hasOlder)return false;Ie=await c(),E=!s.value.hasOlder;}else {if(K||!s.value.hasNewer)return false;b.prepareHistoryPageAppend();try{Ie=await P();}catch(ke){throw b.cancelHistoryPageAppend(),ke}Ie<=0&&!s.value.hasNewer&&b.cancelHistoryPageAppend(),K=!s.value.hasNewer;}return V+=1,Ie>0?se():!(oe==="older"?E:K)};!E&&!await ne("older")&&(E=true),!K&&!await ne("newer")&&(K=true);let he="older";for(;ae(r,l)&&V<Q.value.maxFillPages&&b.isMeasurable()&&!b.isScrollable()&&(!E||!K);){let oe=he==="older"?E?"newer":"older":K?"older":"newer";he=oe==="older"?"newer":"older",await ne(oe)||(oe==="older"?E=true:K=true);}return ae(r,l)}async function Ee(r,l={behavior:"auto",block:"center"}){if(!_.value||r==="")return false;let g=j.value,b=++o;if(!Z.value.includes(r)){let K=f.actions.loadAround;if(K===void 0||!await h({kind:"locate-message",messageId:r},()=>K(r))||!ae(g,b))return false}return !await Pe(g,b,r,{...l,behavior:"auto"})||!await Ve(g,b,r)?false:Pe(g,b,r,l)}function Ae(){w!==void 0&&(clearTimeout(w),w=void 0);}function me(){if(Ae(),!x.value)return;let r=t.readActions;if(r===void 0||p.length===0)return;let l=Number.isFinite(D.value.visibleReadDelay)?Math.max(0,D.value.visibleReadDelay):Xe.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!_.value||!J.value)return;let g=p[p.length-1];if(g===void 0)return;let b=r.resolveTarget===void 0?g:r.resolveTarget(g);b!=null&&Promise.resolve(r.markRead(b)).catch(V=>{t.hooks?.onError?.({kind:"visible-range",messageIds:p},V);});},l);}function je(r){p=Object.freeze([...r]);let l={kind:"visible-range",messageIds:p};t.hooks?.beforeAction?.(l);try{f.actions.onVisibleRange?.(p),t.hooks?.afterAction?.(l,void 0);}catch(g){throw t.hooks?.onError?.(l,g),g}x.value?me():be();}function ee(r,l){return !X&&R===l&&j.value===r&&!N}function ge(r,l){ee(r,l)&&(I=r,H=Oe(s.value.entryUnread),x.value=true,me());}function Oe(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function re(r,l,g){for(let b=0;b<60;b+=1){if(!ee(r,l))return false;if(m.value?.scrollToMessage(g,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}function be(){let r=j.value,l=Oe(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||I===r&&(H===l||N)||O===r||d!==null)return;if(!Q.value.enabled){I=r,H=l,x.value=true,me();return}let g=++R;N=false,x.value=false;let b=(async()=>{if(await nextTick(),!ee(r,g))return;let V=m.value;if(V===null||!V.isMeasurable())return;let E=s.value.entryUnread;if(E.state==="located"&&!Z.value.includes(E.firstMessageId))return;let K=E.state==="located"?await re(r,g,E.firstMessageId):false;if(E.state==="located"&&!K)return;K||V.scrollToLatest();let se=0;for(;ee(r,g)&&se<Q.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&V.isMeasurable()&&!V.isScrollable();)if(await c(),!ee(r,g)||(se+=1,await nextTick(),await nextTick(),!V.isMeasurable()))return;if(!ee(r,g)||!V.isMeasurable())return;let ne=s.value.entryUnread;if(ne.state==="located"){if(!Z.value.includes(ne.firstMessageId)||!await re(r,g,ne.firstMessageId))return}else V.scrollToLatest();await nextTick(),ge(r,g);})().catch(()=>{ee(r,g)&&(O=r);}).finally(()=>{d===b&&(d=null);});d=b;}function ve(r,l=false){R+=1,d=null,N=false,x.value=r,(I="",H="",l||(O="")),Ae();}function Ce(){if(x.value)return;let r=j.value;N=true,R+=1,d=null,I=r,x.value=true,me();}let xe=Object.freeze({getViewportElement:()=>m.value?.getViewportElement()??null,loadOlder:c,retryOlder:W,loadNewer:P,retryNewer:q,jumpToLatest:ye,scrollToMessage:Se,locateMessage:Ee,focusViewport:()=>m.value?.focusViewport()});return a(xe),watch(J,r=>{r&&x.value?me():Ae();}),watch([()=>s.value.activeRemoteMessageRevision??0,m,j],()=>{let r=m.value;if(r===null||!_.value)return;let l=f.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:F.value})&&(M.value=false);},{flush:"post"}),watch([j,()=>s.value.loading,()=>s.value.error,()=>Z.value.length,()=>s.value.hasOlder,()=>Oe(s.value.entryUnread),Q],([r,l,g,,,b],[V,,,,,E])=>{if(r!==V&&(o+=1,ve(false),u(true),m.value?.clearNewMessageBadge(),k.value=0,M.value=true),r!==""&&r===V&&b!==E&&!N&&b.startsWith("located:")&&(I="",H="",x.value=false),r===""){ve(false);return}if(g!==null&&s.value.messages.length===0){x.value||ve(false,true);return}l||be();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{X=true,o+=1,ve(false),u(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:$.value,actions:xe},l=[v.header?.(r),v["before-list"]?.(r)];if(!_.value)l.push(v.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(v.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(v.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let g=h$1(ze,{ref:m,messageIds:Z.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:D.value.followThreshold,olderPrefetchThreshold:D.value.olderPrefetchThreshold,visibleMargin:D.value.visibleMargin,activeDateOffset:D.value.activeDateOffset,activeDateEnabled:v["active-date"]!==void 0,resizeFollowEnabled:x.value,followNewMessages:F.value,shouldFollowAppendedMessage:b=>{let V=s.value.messages.find(E=>E.id===b);return V===void 0?false:f.shouldFollowMessage?.(V)===true},onReachStart:()=>{B("older").catch(()=>{});},onReachEnd:()=>{B("newer").catch(()=>{});},onSettled:fe,onUserScroll:Ce,onActiveDateChange:S,onVisibleRange:je,onNewMessageCount:b=>{k.value=b;}},{default:()=>[v["viewport-before"]?.(r),h$1(We,{items:$.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:v.item,"date-separator":v["date-separator"],"entry-unread":v["entry-unread"],encryption:v.encryption,system:v.system,message:v.message,"recalled-message":v["recalled-message"],"deleted-message":v["deleted-message"],"unsupported-body":v["unsupported-body"]}),v["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[v["active-date"]?.({label:U.value,visible:Y.value&&U.value!==""}),g])),s.value.error!==null&&l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(v["after-list"]?.(r),v["jump-to-latest"]?.({...r,count:k.value,visible:!M.value||s.value.isHistoryWindow}),v["context-menu"]?.(r),v.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function hr(t){let a=new Map;for(let f of t){if(a.has(f.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${f.kind}`);a.set(f.kind,f.component);}let v=Object.freeze([...a.keys()]);return Object.freeze({kinds:v,resolve:f=>a.get(f)})}var yr=140,br=120;function kt(t,a){if(t.width<=0||t.height<=0)return 0;let v=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),f=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,v*f/(t.width*t.height))}function Ir(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function Qe(t){let a=Math.max(0,t.scrollIdleMs??yr),v=Math.max(0,t.visibilityDwellMs??br),f=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),m=Math.max(0,t.revealMarginPx??0),k=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,p=new Map,w=reactive(new Set),R=new Set,o=new Set,d=null,I=null,H=null,O=false,N=false,X=false,x,U;function Y(){x!==void 0&&clearTimeout(x),x=void 0;}function L(){U!==void 0&&clearTimeout(U),U=void 0;}function G(u=false){if(!u&&I!==null||d===null)return;let S=d.getBoundingClientRect(),h=Ir(S,m);for(let[c,P]of M){let B=c.getBoundingClientRect();P.ratio=kt(B,S),P.intersecting=P.ratio>0,P.revealIntersecting=m>0?kt(B,h)>0:P.intersecting&&P.ratio>=f;}}function s(u){return u.intersecting&&u.ratio>=f}function F(){for(let u of M.values())!u.revealIntersecting||w.has(u.key)||(w.add(u.key),t.onRevealed?.(u.item));}function J(u){let S=new Set(u.map(c=>c.key));if(S.size!==o.size||[...S].some(c=>!o.has(c))){o.clear();for(let c of S)o.add(c);t.onSettledVisibleChange?.(u.map(c=>c.item));}}function _(){if(N||O)return;G(),F();let u=d?.getBoundingClientRect(),S=u===void 0?0:(u.top+u.bottom)/2,h=[...M.entries()].filter(([,c])=>s(c)).sort(([c],[P])=>{let B=c.getBoundingClientRect(),q=P.getBoundingClientRect();return Math.abs((B.top+B.bottom)/2-S)-Math.abs((q.top+q.bottom)/2-S)}).slice(0,k).map(([,c])=>c);J(h);for(let c of h)R.has(c.key)||(R.add(c.key),t.onActivated?.(c.item));}function D(){N||O||(L(),U=setTimeout(()=>{U=void 0,_();},v));}function Q(){N||(j(true),G(),F(),J([]),L(),Y(),x=setTimeout(()=>{x=void 0,j(false),D();},a));}function j(u){O!==u&&(O=u,t.onScrollingChange?.(u));}function $(){d?.removeEventListener("scroll",Q),I?.disconnect(),H?.disconnect(),I=null,H=null,d=null;}function Z(u=true){if(N)return;let S=t.getRoot();if(!(S===d&&d!==null)){if($(),d=S,d===null){u&&!X&&(X=true,Promise.resolve().then(()=>{X=false,N||(Z(false),D());}));return}if(d.addEventListener("scroll",Q,{passive:true}),typeof IntersectionObserver<"u"){I=new IntersectionObserver(h=>{for(let c of h){let P=M.get(c.target);P!==void 0&&(P.intersecting=c.isIntersecting,P.ratio=c.intersectionRatio,m===0&&(P.revealIntersecting=c.isIntersecting&&c.intersectionRatio>=f));}F(),D();},{root:d,threshold:[0,f,1]}),m>0&&(H=new IntersectionObserver(h=>{for(let c of h){let P=M.get(c.target);P!==void 0&&(P.revealIntersecting=c.isIntersecting);}F();},{root:d,rootMargin:`${m}px 0px`,threshold:0}));for(let h of M.keys())I.observe(h);for(let h of M.keys())H?.observe(h);}else G(),F();}}function ie(u){w.delete(u),R.delete(u),o.delete(u);}return {register(u,S){if(N)return;let h=t.getKey(u),c=w.has(h),P=R.has(h),B=S===null?void 0:M.get(S);B!==void 0&&B.key!==h&&(p.delete(B.key),M.delete(S),ie(B.key));let q=p.get(h);if(q!==void 0&&q!==S&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(h)),S===null){q!==void 0&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(h)),ie(h);return}let W=M.get(S);if(W?.key===h&&W.item===u){Z();return}M.set(S,{item:u,key:h,intersecting:W?.key===h?W.intersecting:false,ratio:W?.key===h?W.ratio:0,revealIntersecting:W?.key===h?W.revealIntersecting:false}),p.set(h,S),Z(),I?.observe(S),H?.observe(S),G(true),F(),c&&t.onRevealed?.(u),P?t.onActivated?.(u):D();},isRevealed:u=>w.has(t.getKey(u)),isActivated:u=>R.has(t.getKey(u)),isSettledVisible:u=>o.has(t.getKey(u)),isScrolling:()=>O,notifyScroll:Q,refresh(){Z(),G(true),F(),D();},reset(){Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear();},dispose(){N||(Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear(),N=true);}}}function wr(t){let a=new Map,v=new Map,f=false,m=p=>{let w=a.get(p.channel);return w===void 0?p.channel:`${p.channel}\0${w.getKey(p.item)}`},k=Qe({getRoot:t.getRoot,getKey:m,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:p=>{for(let w of a.values())w.onScrollingChange?.(p);},onRevealed:p=>a.get(p.channel)?.onRevealed?.(p.item),onActivated:p=>a.get(p.channel)?.onActivated?.(p.item),onSettledVisibleChange:p=>{for(let[w,R]of a){let o=p.filter(I=>I.channel===w).map(I=>I.item),d=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(d);}}});function M(p){return w=>{if(f)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(p))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${p}`);a.set(p,w);let R=new Map;v.set(p,R);let o=false,d=O=>({channel:p,item:O});function I(){for(let O of R.values())k.register(O.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(O,N){if(o||f)return;let X=w.getKey(O),x=R.get(X);if(N===null){x!==void 0&&(k.register(x.target,null),R.delete(X));return}let U=d(O);R.set(X,{target:U,element:N}),k.register(U,N);},isRevealed:O=>k.isRevealed(d(O)),isActivated:O=>k.isActivated(d(O)),isSettledVisible:O=>k.isSettledVisible(d(O)),isScrolling:k.isScrolling,notifyScroll:k.notifyScroll,refresh:k.refresh,reset:I,dispose(){o||(I(),o=true,a.delete(p),v.delete(p));}}}}return {createFactory:M,refresh:k.refresh,dispose(){if(!f){for(let p of v.values())for(let w of p.values())k.register(w.target,null);v.clear(),a.clear(),k.dispose(),f=true;}}}}export{qe as ImThreadBodySwitch,We as ImThreadItems,vr as ImThreadSurface,ze as ImThreadViewport,dr as createImThreadSurfaceContext,hr as createMessageRendererRegistry,wr as createThreadVisibilityTargetGroup,Qe as createThreadVisibilityTargets,ur as provideImThreadSurfaceContext,qt as useImText,Ye as useImThreadSurfaceContext,zt as useOptionalImThreadReadActions};
|
|
1
|
+
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-UNGWXAYA.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-VMKTMZ3K.js';import'./chunk-SVJGRV4M.js';import'./chunk-GMVR64GN.js';import'./chunk-LX7YEO5G.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function qt(t){let a=0,v=0;for(let f of t)f.kind==="video"?v+=1:a+=1;return {imageCount:a,videoCount:v}}function Gt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.mediaAlbum===void 0?{}:{mediaAlbum:qt(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var Et=Symbol("ImThreadReadActions");function At(t){provide(Et,t);}function Yt(){return inject(Et,void 0)}var Ge=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:v}){return At(t.readActions),()=>{let f=h(t.message),m=t.rendererRegistry.resolve(f);return m!==void 0?h$1(m,{...a,message:t.message,presentation:t.presentation}):v["unsupported-body"]!==void 0?v["unsupported-body"]({kind:f,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":f,"aria-hidden":"true"})}}});var We=Symbol("ImThreadViewportRegistration");function xt(){return inject(We,void 0)}var ze=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let v=xt();function f(o,d){let I=Array.isArray(d)?d:[d];return I.length===1&&isVNode(I[0])?cloneVNode(I[0],{key:o}):h$1(Fragment,{key:o},I)}function m(o){return d=>{v?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function k(o,d){return I=>{v?.registerDateNode(o,d,I instanceof HTMLElement?I:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function p(o){let d=k(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function w(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function R(o){let d=m(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:d}):h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(Ge,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:I=>a["unsupported-body"]?.(I)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,M(o));case "date-separator":return a.item!==void 0?f(o.key,a.item({item:o,setElement:k(o.key,o.label)})):f(o.key,p(o));case "entry-unread":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,w(o));case "system":case "message":return f(o.key,R(o))}return o}))}});var kt=120,ar=500,le=.5,sr=8,Ye=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:v,slots:f}){let m$1=ref(null),k=ref(null),M=new Map,p$1=new Map,w=new Set,R=new Map,o$1=0,d=[],I,H,O,D,X=false,x,U=new Set,Y=false,L,W="",s=1,F=false,J=false,_=true,N=false,Q=false,j$1=false,$=0,Z=-1,ie=-1,u,S,T,c,P,B$1=ref(true),q$1=ref(0),z$1=C(e=>{q$1.value=e,a("new-message-count",e);});function be(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function fe(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let h=i.getBoundingClientRect(),y=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:h.top,bottom:h.bottom,anchorTop:y?.getBoundingClientRect().top??h.top}]})}function Pe(e="",n=1){let i=Math.min(1,Math.max(0,n));W!==""&&W!==e&&R.get(W)?.element.style.removeProperty("opacity"),W=e,s=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function ae(){Pe();}function Ee(){let e=m$1.value;if(Y||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,A])=>e.contains(A.element)).map(([A,C])=>{let G=C.element.getBoundingClientRect();return {key:A,label:C.label,top:G.top,height:G.height}}).sort((A,C)=>A.top-C.top),i=e.getBoundingClientRect(),h=n.find(A=>A.height>0)?.height??28,y=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:h});if(y===null){ae(),a("active-date-change",null);return}Pe(y.inlineDateKey,y.inlineOpacity),a("active-date-change",y);}function Ce(e){H={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Ae(e){let n=H;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=le}function Oe(e){return Ae(e)||L!==void 0&&(L.behavior==="smooth"||Math.abs(e.scrollTop-L.targetTop)<=le)?0:e.scrollTop-o$1}function me(e,n){n!==0&&(o$1=e.scrollTop-n,L=void 0,g$1());}function Ke(e,n){let i=Oe(e);if(c!==void 0)return c.expectedOffset-=i,se(),me(e,i),N||oe(),false;let h=H;if(h===void 0)return false;let y=I,A=y===void 0?void 0:fe([y.id])[0],C=e.scrollTop-h.scrollTop,G=Ae(e)?0:C,Me=y===void 0||A===void 0?0:(A.anchorTop??A.top)-n.top-y.offset+C;return h.scrollHeight!==e.scrollHeight||h.width!==e.clientWidth||h.height!==e.clientHeight||Math.abs(Me)>le?(H=void 0,!F&&!t.loadingNewer&&t.resizeFollowEnabled&&B$1.value&&Math.abs(G)<=le?(Fe(),true):(y!==void 0&&Ne({...y,offset:y.offset-G}),me(e,i),false)):false}function ee(){let e=m$1.value;if(Y||e===null)return;let n=e.getBoundingClientRect();if(Ke(e,n))return;let i=D!==void 0&&X?t.messageIds.filter(C=>w.has(C)):t.messageIds,h=fe(i);if(D!==void 0&&X&&h.length===0){B$1.value=be(e);return}let y=h.filter(C=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:C.top,messageBottom:C.bottom,margin:t.visibleMargin})).map(C=>C.id),A=y.length!==d.length||y.some((C,G)=>d[G]!==C);d=Object.freeze(y),I=o(h,{top:n.top,bottom:n.bottom}),Ce(e),z$1.acknowledgeVisible(y),B$1.value=be(e),A&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:B$1.value,newMessageCount:q$1.value});}function ge(e){if(U.add(e),x!==void 0)return;let n=()=>{x=void 0;let i=[...U];U.clear(),i.forEach(h=>h());};typeof globalThis.requestAnimationFrame=="function"?x=globalThis.requestAnimationFrame(n):x=globalThis.setTimeout(n,0);}function xe(){x!==void 0&&(typeof x=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(x):globalThis.clearTimeout(x),x=void 0,U.clear());}function re(){ge(ee);}function Ie(){let e=m$1.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(fe(),{top:n.top,bottom:n.bottom});i!==void 0&&(I=i,Ce(e));}function he(){return _&&c===void 0&&!J&&!t.loadingOlder}function ke(){Ie(),_=false,Z=$,J=true,a("reach-start"),ge(()=>{t.loadingOlder||(J=false);});}function Ve(e){return t.hasNewer&&!F&&!t.loadingOlder&&!t.loadingNewer&&be(e)}function r(){F=true,B$1.value=false,ie=$,a("reach-end"),ge(()=>{t.loadingNewer||(F=false);});}function l(){let e=m$1.value;e===null||$===ie||!Ve(e)||r();}function g$1(){let e=m$1.value;if(Y||e===null)return;let n=e.scrollTop,i=Ae(e),h=L,y=false;if(h!==void 0){let C=Math.abs(n-h.targetTop)<=le;y=h.behavior==="smooth"||C,(h.behavior!=="smooth"||C)&&(L=void 0);}!y&&!i&&!N&&c===void 0&&n!==o$1&&(N=true,Q=true,$+=1);let A=N&&!y&&!i&&n!==o$1;if(A&&(a("user-scroll"),ge(Ee)),N&&!j$1&&ye(),!_&&Q&&$!==Z&&n<o$1&&n>et()&&(_=true),c!==void 0&&!y)if(N){let C=K();C!==void 0&&(c.expectedOffset=C);}else se(),oe();he()&&A&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&ke(),A&&Ve(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:be(e),isHistoryWindow:t.hasNewer,isPageSettling:y})&&r(),o$1=n,re();}function b(e,n="auto"){L={targetTop:e,behavior:n};}function V(e){let n=c,i=k.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=le?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function E(){P!==void 0&&(clearTimeout(P),P=void 0),c!==void 0&&c.visualOffset!==0&&(I=void 0,H=void 0);let e=k.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),c=void 0,L=void 0;}function K(){let e=m$1.value,n=c;if(e===null||n===void 0)return;let i=fe().find(h=>h.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function se(){let e=c,n=K();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=le||(V(e.visualOffset+i),e.committed=false,e.attempts=0);}function ne(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,!(N||c?.committed!==true)&&E();},ar);}function Te(){let e=m$1.value,n=c;if(Y||e===null||n===void 0||N)return;let i=n.visualOffset;if(Math.abs(i)<=le){n.committed=true,ne();return}let h=Math.max(0,e.scrollHeight-e.clientHeight),y=Math.min(h,Math.max(0,e.scrollTop-i));if(b(y),e.scrollTop=y,Math.abs(e.scrollTop-y)>le){L=void 0,n.committed=false,n.attempts+=1,n.attempts<sr?oe():(E(),L=void 0,o$1=e.scrollTop);return}V(0),o$1=e.scrollTop,n.expectedOffset=K()??n.expectedOffset,n.committed=true,n.attempts=0,ne();}function oe(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,Te();},kt);}function we(e){e!==void 0&&(c===void 0&&(c={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),se(),!N&&Te());}function Ne(e){let n=m$1.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),h=q(e,fe(),{top:i.top,bottom:i.bottom});if(h!==void 0){let y=Math.max(0,n.scrollHeight-n.clientHeight),A=Math.min(y,Math.max(0,n.scrollTop+h));b(A),n.scrollTop=A,o$1=n.scrollTop,H=void 0;}}function et(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){L?.behavior==="smooth"&&(L=void 0),Q=false,N||(N=true,$+=1),u!==void 0&&(clearTimeout(u),u=void 0);}function Le(){let e=m$1.value;e===null||$===Z||(c!==void 0&&E(),_=true,e.scrollTop<=et()&&he()&&ke());}function tt(){I=void 0,H=void 0,u!==void 0&&(clearTimeout(u),u=void 0),E(),N=false,Q=false,j$1=false,S=void 0,T=void 0,$+=1,Z=-1,ie=-1,_=true,J=false,F=false,L=void 0;}function rt(){j$1||(u!==void 0&&(clearTimeout(u),u=void 0),N=false,Q=false,c!==void 0&&(c.attempts=0),Te());}function ye(){j$1||(u!==void 0&&clearTimeout(u),u=setTimeout(()=>{u=void 0,rt();},kt));}function nt(){L=void 0,rt();}function ot(e){j$1=true,De(),S=e.touches?.[0]?.clientY;}function it(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(S!==void 0&&n>S?Le():S!==void 0&&n<S&&l(),S=n);}function He(){j$1=false,S=void 0,ye();}function at(e){De(),e.deltaY<0?Le():e.deltaY>0&&l(),ye();}function st(e){e.pointerType!=="touch"&&(De(),T=e.clientY,ye());}function lt(e){e.pointerType==="touch"||!N||T===void 0||(e.clientY<T?Le():e.clientY>T&&l(),T=e.clientY,ye());}function Be(e){e.pointerType!=="touch"&&(T=void 0,ye());}function dt(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Le():l(),ye());}function Fe(e="auto"){let n=m$1.value;if(n===null)return;H=void 0,E();let i=Math.max(0,n.scrollHeight-n.clientHeight);b(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,z$1.clear(),ee();}function ut(){let e=m$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Lt(){let e=m$1.value;return ut()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Ht(e,n={}){let i=m$1.value,h=M.get(e);if(i===null||h===void 0||!i.contains(h)||i.clientHeight<=0)return false;E();let y=i.getBoundingClientRect(),A=h.getBoundingClientRect(),C=n.block??"center",G;C==="start"?G=i.scrollTop+A.top-y.top:C==="end"?G=i.scrollTop+A.bottom-y.bottom:C==="nearest"?A.top>=y.top&&A.bottom<=y.bottom?G=i.scrollTop:A.top<y.top?G=i.scrollTop+A.top-y.top:G=i.scrollTop+A.bottom-y.bottom:G=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:A.height,targetTop:A.top,viewportHeight:i.clientHeight,viewportTop:y.top});let Me=Math.max(0,i.scrollHeight-i.clientHeight),pe=Math.min(Me,Math.max(0,G));H=void 0;let Re=n.behavior??"auto";return b(pe,Re),i.scrollTo?.({top:pe,behavior:Re}),i.scrollTop!==pe&&(i.scrollTop=pe),o$1=i.scrollTop,ee(),true}function Bt(){z$1.clear();}function Ft(){F=true,B$1.value=false;}function _t(){F=false,re();}function jt(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(D?.unobserve(i),O?.unobserve?.(i),p$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),p$1.set(n,e),D?.observe(n),O?.observe(n),re();}function Kt(e,n,i){let h=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),W===e&&i.style.setProperty("opacity",String(s)),h?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(We,{registerMessageNode:jt,registerDateNode:Kt}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;tt();let i=m$1.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=m$1.value;if(i===null)return;let h=new Set(n);n.length>0&&e.length>0&&!e.some(ve=>h.has(ve))&&tt();let A=i.getBoundingClientRect(),C=p(I,fe(),{top:A.top,bottom:A.bottom}),G=B$1.value,Me=n[n.length-1],pe=Me===void 0?-1:e.indexOf(Me),Re=pe<0?[]:e.slice(pe+1).filter(ve=>!h.has(ve)),ct=F||t.loadingNewer,Ut=e.length===n.length&&e.every(ve=>h.has(ve))&&e.some((ve,Ue)=>ve!==n[Ue]);if(await nextTick(),Y)return;if(Ut&&G&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ct){Fe();return}let ft=n[0];if(ft!==void 0&&e.indexOf(ft)>0&&(J=false,we(C)),Re.length>0){if(ct){F=false,c===void 0&&Ne(C),B$1.value=false,re();return}(G||Re.some(Ue=>t.shouldFollowAppendedMessage?.(Ue)===true))&&t.followNewMessages?Fe():z$1.add(Re);}re();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!F||ge(()=>{t.loadingNewer||(F=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!J||ge(()=>{t.loadingOlder||(J=false);});},{flush:"pre"}),onMounted(()=>{let e=m$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",g$1,{passive:true}),e.addEventListener("scrollend",nt,{passive:true}),e.addEventListener("touchstart",ot,{passive:true}),e.addEventListener("touchmove",it,{passive:true}),e.addEventListener("touchend",He,{passive:true}),e.addEventListener("touchcancel",He,{passive:true}),e.addEventListener("wheel",at,{passive:true}),e.addEventListener("pointerdown",st,{passive:true}),e.addEventListener("pointermove",lt,{passive:true}),e.addEventListener("pointerup",Be,{passive:true}),e.addEventListener("pointercancel",Be,{passive:true}),e.addEventListener("keydown",dt),typeof globalThis.ResizeObserver=="function"){O=new globalThis.ResizeObserver(()=>{Y||m$1.value===null||ee();}),O.observe(e),k.value!==null&&O.observe(k.value);for(let n of M.values())O.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){D=new globalThis.IntersectionObserver(n=>{for(let i of n){let h=p$1.get(i.target);h!==void 0&&(i.isIntersecting?w.add(h):w.delete(h));}X=true,re();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())D.observe(n);}re();}}),onBeforeUnmount(()=>{Y=true;let e=m$1.value;e!==null&&e.removeEventListener("scroll",g$1),e!==null&&(e.removeEventListener("scrollend",nt),e.removeEventListener("touchstart",ot),e.removeEventListener("touchmove",it),e.removeEventListener("touchend",He),e.removeEventListener("touchcancel",He),e.removeEventListener("wheel",at),e.removeEventListener("pointerdown",st),e.removeEventListener("pointermove",lt),e.removeEventListener("pointerup",Be),e.removeEventListener("pointercancel",Be),e.removeEventListener("keydown",dt)),u!==void 0&&clearTimeout(u),E(),xe(),O?.disconnect(),D?.disconnect(),ae(),M.clear(),p$1.clear(),w.clear(),R.clear(),z$1.clear();}),v({getViewportElement:()=>m$1.value,clearNewMessageBadge:Bt,clearActiveDate:ae,isAtBottom:computed(()=>B$1.value),isMeasurable:ut,isScrollable:Lt,newMessageCount:computed(()=>q$1.value),prepareHistoryPageAppend:Ft,cancelHistoryPageAppend:_t,trackRemoteMessageIds:(e,n)=>z$1.trackRemote(e,n),scrollToLatest:Fe,scrollToMessage:Ht,focusViewport:()=>m$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:m$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:k,"data-im-thread-viewport-content":""},f.default?.())])}});var Nt=Symbol("ImThreadSurfaceContext");function ur(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function cr(t){provide(Nt,t);}function $e(){let t=inject(Nt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Je=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Qe=Object.freeze({enabled:true,maxFillPages:8}),gr=8,pr=160;function vr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var hr=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:v}){let f=t.context??$e(),m=ref(null),k=ref(0),M=ref(true),p=[],w,R=0,o=0,d=null,I="",H="",O="",D=false,X=false,x=ref(false),U=ref(""),Y=ref(false),L,W,s=computed(()=>f.getState()),F=computed(()=>s.value.pageVisible??f.isPageVisible?.()??true),J=computed(()=>s.value.pageEngaged??f.isPageEngaged?.()??true),_=computed(()=>vr(s.value.activeConversation,t.conversation)),N=computed(()=>({...Je,...t.viewportOptions})),Q=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Qe.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Qe.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Qe.maxFillPages}}),j=computed(()=>!_.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),$=computed(()=>_.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:f.formatDate,leadingItems:f.leadingItems?.(),beforeMessageItems:f.beforeMessageItems}):[]),Z=computed(()=>$.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ie(){L!==void 0&&(clearTimeout(L),L=void 0),W!==void 0&&(clearTimeout(W),W=void 0);}function u(r=false){if(ie(),Y.value=false,r){m.value?.clearActiveDate(),U.value="";return}W=setTimeout(()=>{W=void 0,!Y.value&&(m.value?.clearActiveDate(),U.value="");},pr);}function S(r){if(r===null){u();return}ie(),U.value=r.label,Y.value=true;let l=N.value.activeDateIdleDelay,g=Number.isFinite(l)?Math.max(0,l):Je.activeDateIdleDelay;L=setTimeout(()=>{L=void 0,u();},g);}async function T(r,l){t.hooks?.beforeAction?.(r);try{let g=await l();return t.hooks?.afterAction?.(r,g),g}catch(g){throw t.hooks?.onError?.(r,g),g}}function c(r="automatic"){return !_.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):T({kind:"load-older",source:r},()=>f.actions.loadOlder())}function P(){let r=f.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !_.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):T({kind:"load-newer"},()=>r())}async function B(r){for(let l=0;l<gr;l+=1){if(!_.value)return;let g=r==="older"?s.value.hasOlder:s.value.hasNewer,b=r==="older"?s.value.olderError:s.value.newerError;if(!g||b!==null||(r==="older"?await c("user-scroll"):await P())>0)return;let E=r==="older"?s.value.hasOlder:s.value.hasNewer,K=r==="older"?s.value.olderError:s.value.newerError;if(!E||K!==null)return}}async function q(){return !_.value||f.actions.loadNewer===void 0?0:T({kind:"load-newer"},()=>f.actions.retryNewer?.()??f.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function z(){if(!_.value)return 0;let r=j.value,l=++R;d=null,O="";let g;try{g=await T({kind:"retry-older"},()=>f.actions.retryOlder?.()??f.actions.loadOlder({force:!0}));}catch(b){throw ee(r,l)&&(O=r),b}return ee(r,l)&&!x.value&&(d=null,Ie()),g}async function be(){if(!_.value)return false;let r=await T({kind:"jump-to-latest"},()=>f.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow));return r&&(await nextTick(),m.value?.scrollToLatest()),r}function fe(r){M.value=r.isAtBottom,k.value=r.newMessageCount,Ie();}function Pe(r,l){return m.value?.scrollToMessage(r,l)??false}function ae(r,l){return !X&&o===l&&j.value===r&&_.value}async function Ee(r,l,g,b){for(let V=0;V<60;V+=1){if(!ae(r,l))return false;if(Pe(g,b))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}async function Ce(r,l,g){let b=m.value;if(b===null||!b.isMeasurable()||b.isScrollable())return true;let V=0,E=!s.value.hasOlder,K=!s.value.hasNewer||f.actions.loadNewer===void 0,se=async()=>(await nextTick(),await nextTick(),Ee(r,l,g,{behavior:"auto",block:"center"})),ne=async oe=>{if(!ae(r,l)||V>=Q.value.maxFillPages)return false;let we=0;if(oe==="older"){if(E||!s.value.hasOlder)return false;we=await c(),E=!s.value.hasOlder;}else {if(K||!s.value.hasNewer)return false;b.prepareHistoryPageAppend();try{we=await P();}catch(Ne){throw b.cancelHistoryPageAppend(),Ne}we<=0&&!s.value.hasNewer&&b.cancelHistoryPageAppend(),K=!s.value.hasNewer;}return V+=1,we>0?se():!(oe==="older"?E:K)};!E&&!await ne("older")&&(E=true),!K&&!await ne("newer")&&(K=true);let Te="older";for(;ae(r,l)&&V<Q.value.maxFillPages&&b.isMeasurable()&&!b.isScrollable()&&(!E||!K);){let oe=Te==="older"?E?"newer":"older":K?"older":"newer";Te=oe==="older"?"newer":"older",await ne(oe)||(oe==="older"?E=true:K=true);}return ae(r,l)}async function Ae(r,l={behavior:"auto",block:"center"}){if(!_.value||r==="")return false;let g=j.value,b=++o;if(!Z.value.includes(r)){let K=f.actions.loadAround;if(K===void 0||!await T({kind:"locate-message",messageId:r},()=>K(r))||!ae(g,b))return false}return !await Ee(g,b,r,{...l,behavior:"auto"})||!await Ce(g,b,r)?false:Ee(g,b,r,l)}function Oe(){w!==void 0&&(clearTimeout(w),w=void 0);}function me(){if(Oe(),!x.value)return;let r=t.readActions;if(r===void 0||p.length===0)return;let l=Number.isFinite(N.value.visibleReadDelay)?Math.max(0,N.value.visibleReadDelay):Je.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!_.value||!J.value)return;let g=p[p.length-1];if(g===void 0)return;let b=r.resolveTarget===void 0?g:r.resolveTarget(g);b!=null&&Promise.resolve(r.markRead(b)).catch(V=>{t.hooks?.onError?.({kind:"visible-range",messageIds:p},V);});},l);}function Ke(r){p=Object.freeze([...r]);let l={kind:"visible-range",messageIds:p};t.hooks?.beforeAction?.(l);try{f.actions.onVisibleRange?.(p),t.hooks?.afterAction?.(l,void 0);}catch(g){throw t.hooks?.onError?.(l,g),g}x.value?me():Ie();}function ee(r,l){return !X&&R===l&&j.value===r&&!D}function ge(r,l){ee(r,l)&&(I=r,H=xe(s.value.entryUnread),x.value=true,me());}function xe(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function re(r,l,g){for(let b=0;b<60;b+=1){if(!ee(r,l))return false;if(m.value?.scrollToMessage(g,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}function Ie(){let r=j.value,l=xe(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||I===r&&(H===l||D)||O===r||d!==null)return;if(!Q.value.enabled){I=r,H=l,x.value=true,me();return}let g=++R;D=false,x.value=false;let b=(async()=>{if(await nextTick(),!ee(r,g))return;let V=m.value;if(V===null||!V.isMeasurable())return;let E=s.value.entryUnread;if(E.state==="located"&&!Z.value.includes(E.firstMessageId))return;let K=E.state==="located"?await re(r,g,E.firstMessageId):false;if(E.state==="located"&&!K)return;K||V.scrollToLatest();let se=0;for(;ee(r,g)&&se<Q.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&V.isMeasurable()&&!V.isScrollable();)if(await c(),!ee(r,g)||(se+=1,await nextTick(),await nextTick(),!V.isMeasurable()))return;if(!ee(r,g)||!V.isMeasurable())return;let ne=s.value.entryUnread;if(ne.state==="located"){if(!Z.value.includes(ne.firstMessageId)||!await re(r,g,ne.firstMessageId))return}else V.scrollToLatest();await nextTick(),ge(r,g);})().catch(()=>{ee(r,g)&&(O=r);}).finally(()=>{d===b&&(d=null);});d=b;}function he(r,l=false){R+=1,d=null,D=false,x.value=r,(I="",H="",l||(O="")),Oe();}function ke(){if(x.value)return;let r=j.value;D=true,R+=1,d=null,I=r,x.value=true,me();}let Ve=Object.freeze({getViewportElement:()=>m.value?.getViewportElement()??null,loadOlder:c,retryOlder:z,loadNewer:P,retryNewer:q,jumpToLatest:be,scrollToMessage:Pe,locateMessage:Ae,focusViewport:()=>m.value?.focusViewport()});return a(Ve),watch(J,r=>{r&&x.value?me():Oe();}),watch([()=>s.value.activeRemoteMessageRevision??0,m,j],()=>{let r=m.value;if(r===null||!_.value)return;let l=f.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:F.value})&&(M.value=false);},{flush:"post"}),watch([j,()=>s.value.loading,()=>s.value.error,()=>Z.value.length,()=>s.value.hasOlder,()=>xe(s.value.entryUnread),Q],([r,l,g,,,b],[V,,,,,E])=>{if(r!==V&&(o+=1,he(false),u(true),m.value?.clearNewMessageBadge(),k.value=0,M.value=true),r!==""&&r===V&&b!==E&&!D&&b.startsWith("located:")&&(I="",H="",x.value=false),r===""){he(false);return}if(g!==null&&s.value.messages.length===0){x.value||he(false,true);return}l||Ie();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{X=true,o+=1,he(false),u(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:$.value,actions:Ve},l=[v.header?.(r),v["before-list"]?.(r)];if(!_.value)l.push(v.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(v.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(v.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let g=h$1(Ye,{ref:m,messageIds:Z.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:N.value.followThreshold,olderPrefetchThreshold:N.value.olderPrefetchThreshold,visibleMargin:N.value.visibleMargin,activeDateOffset:N.value.activeDateOffset,activeDateEnabled:v["active-date"]!==void 0,resizeFollowEnabled:x.value,followNewMessages:F.value,shouldFollowAppendedMessage:b=>{let V=s.value.messages.find(E=>E.id===b);return V===void 0?false:f.shouldFollowMessage?.(V)===true},onReachStart:()=>{B("older").catch(()=>{});},onReachEnd:()=>{B("newer").catch(()=>{});},onSettled:fe,onUserScroll:ke,onActiveDateChange:S,onVisibleRange:Ke,onNewMessageCount:b=>{k.value=b;}},{default:()=>[v["viewport-before"]?.(r),h$1(ze,{items:$.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:v.item,"date-separator":v["date-separator"],"entry-unread":v["entry-unread"],encryption:v.encryption,system:v.system,message:v.message,"recalled-message":v["recalled-message"],"deleted-message":v["deleted-message"],"unsupported-body":v["unsupported-body"]}),v["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[v["active-date"]?.({label:U.value,visible:Y.value&&U.value!==""}),g])),s.value.error!==null&&l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(v["after-list"]?.(r),v["jump-to-latest"]?.({...r,count:k.value,visible:!M.value||s.value.isHistoryWindow}),v["context-menu"]?.(r),v.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Tr(t){let a=new Map;for(let f of t){if(a.has(f.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${f.kind}`);a.set(f.kind,f.component);}let v=Object.freeze([...a.keys()]);return Object.freeze({kinds:v,resolve:f=>a.get(f)})}var br=140,Ir=120;function Dt(t,a){if(t.width<=0||t.height<=0)return 0;let v=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),f=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,v*f/(t.width*t.height))}function wr(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function Ze(t){let a=Math.max(0,t.scrollIdleMs??br),v=Math.max(0,t.visibilityDwellMs??Ir),f=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),m=Math.max(0,t.revealMarginPx??0),k=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,p=new Map,w=reactive(new Set),R=new Set,o=new Set,d=null,I=null,H=null,O=false,D=false,X=false,x,U;function Y(){x!==void 0&&clearTimeout(x),x=void 0;}function L(){U!==void 0&&clearTimeout(U),U=void 0;}function W(u=false){if(!u&&I!==null||d===null)return;let S=d.getBoundingClientRect(),T=wr(S,m);for(let[c,P]of M){let B=c.getBoundingClientRect();P.ratio=Dt(B,S),P.intersecting=P.ratio>0,P.revealIntersecting=m>0?Dt(B,T)>0:P.intersecting&&P.ratio>=f;}}function s(u){return u.intersecting&&u.ratio>=f}function F(){for(let u of M.values())!u.revealIntersecting||w.has(u.key)||(w.add(u.key),t.onRevealed?.(u.item));}function J(u){let S=new Set(u.map(c=>c.key));if(S.size!==o.size||[...S].some(c=>!o.has(c))){o.clear();for(let c of S)o.add(c);t.onSettledVisibleChange?.(u.map(c=>c.item));}}function _(){if(D||O)return;W(),F();let u=d?.getBoundingClientRect(),S=u===void 0?0:(u.top+u.bottom)/2,T=[...M.entries()].filter(([,c])=>s(c)).sort(([c],[P])=>{let B=c.getBoundingClientRect(),q=P.getBoundingClientRect();return Math.abs((B.top+B.bottom)/2-S)-Math.abs((q.top+q.bottom)/2-S)}).slice(0,k).map(([,c])=>c);J(T);for(let c of T)R.has(c.key)||(R.add(c.key),t.onActivated?.(c.item));}function N(){D||O||(L(),U=setTimeout(()=>{U=void 0,_();},v));}function Q(){D||(j(true),W(),F(),J([]),L(),Y(),x=setTimeout(()=>{x=void 0,j(false),N();},a));}function j(u){O!==u&&(O=u,t.onScrollingChange?.(u));}function $(){d?.removeEventListener("scroll",Q),I?.disconnect(),H?.disconnect(),I=null,H=null,d=null;}function Z(u=true){if(D)return;let S=t.getRoot();if(!(S===d&&d!==null)){if($(),d=S,d===null){u&&!X&&(X=true,Promise.resolve().then(()=>{X=false,D||(Z(false),N());}));return}if(d.addEventListener("scroll",Q,{passive:true}),typeof IntersectionObserver<"u"){I=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.intersecting=c.isIntersecting,P.ratio=c.intersectionRatio,m===0&&(P.revealIntersecting=c.isIntersecting&&c.intersectionRatio>=f));}F(),N();},{root:d,threshold:[0,f,1]}),m>0&&(H=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.revealIntersecting=c.isIntersecting);}F();},{root:d,rootMargin:`${m}px 0px`,threshold:0}));for(let T of M.keys())I.observe(T);for(let T of M.keys())H?.observe(T);}else W(),F();}}function ie(u){w.delete(u),R.delete(u),o.delete(u);}return {register(u,S){if(D)return;let T=t.getKey(u),c=w.has(T),P=R.has(T),B=S===null?void 0:M.get(S);B!==void 0&&B.key!==T&&(p.delete(B.key),M.delete(S),ie(B.key));let q=p.get(T);if(q!==void 0&&q!==S&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(T)),S===null){q!==void 0&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(T)),ie(T);return}let z=M.get(S);if(z?.key===T&&z.item===u){Z();return}M.set(S,{item:u,key:T,intersecting:z?.key===T?z.intersecting:false,ratio:z?.key===T?z.ratio:0,revealIntersecting:z?.key===T?z.revealIntersecting:false}),p.set(T,S),Z(),I?.observe(S),H?.observe(S),W(true),F(),c&&t.onRevealed?.(u),P?t.onActivated?.(u):N();},isRevealed:u=>w.has(t.getKey(u)),isActivated:u=>R.has(t.getKey(u)),isSettledVisible:u=>o.has(t.getKey(u)),isScrolling:()=>O,notifyScroll:Q,refresh(){Z(),W(true),F(),N();},reset(){Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear();},dispose(){D||(Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear(),D=true);}}}function Mr(t){let a=new Map,v=new Map,f=false,m=p=>{let w=a.get(p.channel);return w===void 0?p.channel:`${p.channel}\0${w.getKey(p.item)}`},k=Ze({getRoot:t.getRoot,getKey:m,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:p=>{for(let w of a.values())w.onScrollingChange?.(p);},onRevealed:p=>a.get(p.channel)?.onRevealed?.(p.item),onActivated:p=>a.get(p.channel)?.onActivated?.(p.item),onSettledVisibleChange:p=>{for(let[w,R]of a){let o=p.filter(I=>I.channel===w).map(I=>I.item),d=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(d);}}});function M(p){return w=>{if(f)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(p))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${p}`);a.set(p,w);let R=new Map;v.set(p,R);let o=false,d=O=>({channel:p,item:O});function I(){for(let O of R.values())k.register(O.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(O,D){if(o||f)return;let X=w.getKey(O),x=R.get(X);if(D===null){x!==void 0&&(k.register(x.target,null),R.delete(X));return}let U=d(O);R.set(X,{target:U,element:D}),k.register(U,D);},isRevealed:O=>k.isRevealed(d(O)),isActivated:O=>k.isActivated(d(O)),isSettledVisible:O=>k.isSettledVisible(d(O)),isScrolling:k.isScrolling,notifyScroll:k.notifyScroll,refresh:k.refresh,reset:I,dispose(){o||(I(),o=true,a.delete(p),v.delete(p));}}}}return {createFactory:M,refresh:k.refresh,dispose(){if(!f){for(let p of v.values())for(let w of p.values())k.register(w.target,null);v.clear(),a.clear(),k.dispose(),f=true;}}}}export{Ge as ImThreadBodySwitch,ze as ImThreadItems,hr as ImThreadSurface,Ye as ImThreadViewport,ur as createImThreadSurfaceContext,Tr as createMessageRendererRegistry,Mr as createThreadVisibilityTargetGroup,Ze as createThreadVisibilityTargets,cr as provideImThreadSurfaceContext,Gt as useImText,$e as useImThreadSurfaceContext,Yt as useOptionalImThreadReadActions};
|
package/dist/chat-kit.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/** IM 领域支持的 5 个展示 locale(与宿主规范 locale 一致)。 */
|
|
2
|
-
type ImLocale = 'en-US' | 'th-TH' | 'vi-VN' | 'zh-CN' | 'zh-TW';
|
|
3
|
-
|
|
4
1
|
/** 媒体业务类型:实现据此选对象存储逻辑桶;sticker 对应 app-sticker。 */
|
|
5
2
|
type MediaKind = 'image' | 'video' | 'voice' | 'file' | 'sticker';
|
|
6
3
|
|
|
@@ -613,12 +610,12 @@ interface ImMessage {
|
|
|
613
610
|
body: ImMessageBody;
|
|
614
611
|
/** P0 统一毫秒 number(本地创建时间,乐观渲染用)。 */
|
|
615
612
|
createdAt: number;
|
|
616
|
-
/**
|
|
613
|
+
/** SDK 内部排序键;有效服务端时间优先,ACK 后可以更新。宿主不解析它,消息身份始终使用 id。 */
|
|
617
614
|
sortKey: string;
|
|
618
615
|
status: MessageSendStatus;
|
|
619
616
|
/** 失败原因(status==='failed' 时)。 */
|
|
620
617
|
failure?: ImMessageFailure;
|
|
621
|
-
/**
|
|
618
|
+
/** 服务端回传的 epoch 毫秒时间;有效时用于正式排序与展示,createdAt 仍保留创建记录。 */
|
|
622
619
|
serverTime?: number;
|
|
623
620
|
/** P0 默认 'unread'。 */
|
|
624
621
|
receipt: MessageReceipt;
|
|
@@ -1020,8 +1017,8 @@ type ChannelMiniProgramRelConfigType = 'pinned-game' | 'float-link' | 'float-gam
|
|
|
1020
1017
|
/**
|
|
1021
1018
|
* 频道资料上的关联小程序(`/user_radio/info` 的 `mini_program_rel_list`)。
|
|
1022
1019
|
*
|
|
1023
|
-
* @remarks 这不是消息 22。语言/币种 CSV
|
|
1024
|
-
*
|
|
1020
|
+
* @remarks 这不是消息 22。语言/币种 CSV 原样保留,SDK 不过滤;可见性与打开资格由 Chat Kit 纯函数处理。
|
|
1021
|
+
* 打开器、半屏 iframe 与鉴权属于宿主,不进本 DTO。
|
|
1025
1022
|
*/
|
|
1026
1023
|
interface ChannelMiniProgramRel {
|
|
1027
1024
|
configType: ChannelMiniProgramRelConfigType;
|
|
@@ -2543,18 +2540,6 @@ interface ImPushApi {
|
|
|
2543
2540
|
subscribe: (listener: (snapshot: ImPushSnapshot) => void) => () => void;
|
|
2544
2541
|
}
|
|
2545
2542
|
|
|
2546
|
-
/**
|
|
2547
|
-
* IM 语义文案 catalog 的键、参数和完整性合同。
|
|
2548
|
-
* 键描述领域含义而非组件位置,使 Web/H5/SSR 可共享 formatter,宿主布局文案不进入此 schema。
|
|
2549
|
-
*/
|
|
2550
|
-
|
|
2551
|
-
/**
|
|
2552
|
-
* 命令/生命周期「操作提示」文案 key(formatServiceText 用;供 kit services / runtime 产语义码、宿主按 locale 渲染)。
|
|
2553
|
-
* 二期收敛:kit 框架无关层不再直接产中文,改产本联合里的码 + 参数(如 {reason}/{label}/{size}),由宿主经 im-i18n 渲染。
|
|
2554
|
-
* 动态原始报错(error.message)作为 `{reason}` 参数拼接,不入 catalog(属诊断,不翻译)。
|
|
2555
|
-
*/
|
|
2556
|
-
type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
|
|
2557
|
-
|
|
2558
2543
|
/**
|
|
2559
2544
|
* 后端协议的目标服务命名。
|
|
2560
2545
|
*
|
|
@@ -4051,6 +4036,8 @@ interface ImChannelPermissions {
|
|
|
4051
4036
|
dismissChannel?: boolean;
|
|
4052
4037
|
transferOwnership?: boolean;
|
|
4053
4038
|
}
|
|
4039
|
+
/** 产品层频道关联小程序;字段与 Core `ChannelMiniProgramRel` 相同,避免宿主再读 wire。 */
|
|
4040
|
+
type ImChannelMiniProgramRel = ChannelMiniProgramRel;
|
|
4054
4041
|
/**
|
|
4055
4042
|
* default CHANNEL 资料 DTO。
|
|
4056
4043
|
*
|
|
@@ -5509,7 +5496,7 @@ interface ConversationSearchPage<TType extends ProductHandleConversationType = P
|
|
|
5509
5496
|
/**
|
|
5510
5497
|
* 产品消息搜索结果;只暴露稳定定位身份和搜索面板所需的展示字段。
|
|
5511
5498
|
*
|
|
5512
|
-
* @remarks `
|
|
5499
|
+
* @remarks `createdAt` 是搜索面板展示时间,与线程一致优先使用服务端时间;结果不携带 sortKey 或 history cursor。
|
|
5513
5500
|
*/
|
|
5514
5501
|
interface ProductMessageSearchResult<TContent extends MessageContentType = MessageContentType> {
|
|
5515
5502
|
ref: ConversationRef<ProductHandleConversationType>;
|
|
@@ -6200,6 +6187,110 @@ interface ImClient extends Omit<ImProductClient, 'capabilities' | 'channels' | '
|
|
|
6200
6187
|
*/
|
|
6201
6188
|
type ImAdvancedClient = ImClient;
|
|
6202
6189
|
|
|
6190
|
+
/**
|
|
6191
|
+
* 频道 rel 能否打开:跨宿主纯决策。打开器、Toast、分享快照仍归 Host。
|
|
6192
|
+
* 置顶/悬浮游戏都要有 appId 和可拼地址;无 appId 的置顶游戏根本不会进入可见列表。
|
|
6193
|
+
*/
|
|
6194
|
+
|
|
6195
|
+
interface ChannelMiniProgramOpenGame {
|
|
6196
|
+
id: string;
|
|
6197
|
+
name: string;
|
|
6198
|
+
cover: string;
|
|
6199
|
+
appId?: string;
|
|
6200
|
+
developerId?: string;
|
|
6201
|
+
domain?: string;
|
|
6202
|
+
suffixAddress?: string;
|
|
6203
|
+
h5Url?: string;
|
|
6204
|
+
isDynamic?: boolean;
|
|
6205
|
+
productId?: number;
|
|
6206
|
+
}
|
|
6207
|
+
type ChannelMiniProgramRelOpenDecision = {
|
|
6208
|
+
kind: 'refuse';
|
|
6209
|
+
} | {
|
|
6210
|
+
kind: 'open-link';
|
|
6211
|
+
url: string;
|
|
6212
|
+
} | {
|
|
6213
|
+
kind: 'open-game';
|
|
6214
|
+
game: ChannelMiniProgramOpenGame;
|
|
6215
|
+
currencyType: number | string;
|
|
6216
|
+
};
|
|
6217
|
+
declare function decideChannelMiniProgramRelOpen(rel: ImChannelMiniProgramRel, input: {
|
|
6218
|
+
name: string;
|
|
6219
|
+
currentCurrencyType: number | null;
|
|
6220
|
+
}): ChannelMiniProgramRelOpenDecision;
|
|
6221
|
+
|
|
6222
|
+
/**
|
|
6223
|
+
* 频道 `miniProgramRels` 的跨宿主可见性与展示纯规则。
|
|
6224
|
+
* SDK mapper 原样保留 CSV 和空 appId;是否展示由这里按当前语言号与大厅币种决定。
|
|
6225
|
+
*/
|
|
6226
|
+
|
|
6227
|
+
/** 与旧 H5 `languageGetNumber` / 频道 rel `lang_types` 一致:1 简中 2 繁中 3 英 4 越 5 泰。 */
|
|
6228
|
+
declare const MINI_PROGRAM_LANG_NUMBERS: {
|
|
6229
|
+
readonly 'zh-CN': 1;
|
|
6230
|
+
readonly 'zh-TW': 2;
|
|
6231
|
+
readonly 'en-US': 3;
|
|
6232
|
+
readonly 'vi-VN': 4;
|
|
6233
|
+
readonly 'th-TH': 5;
|
|
6234
|
+
};
|
|
6235
|
+
type MiniProgramHostLocale = keyof typeof MINI_PROGRAM_LANG_NUMBERS;
|
|
6236
|
+
declare function csvIncludes(csv: string | undefined, value: string | number): boolean;
|
|
6237
|
+
/** 频道 rel 名称按当前 locale 取对应字段,再按 en → 简中 → 繁中 → 越 → 泰回退。 */
|
|
6238
|
+
declare function resolveChannelMiniProgramRelName(rel: ImChannelMiniProgramRel, locale: string): string;
|
|
6239
|
+
declare function resolveChannelMiniProgramRelIcon(rel: ImChannelMiniProgramRel): string;
|
|
6240
|
+
declare function resolveChannelMiniProgramRelUrl(rel: ImChannelMiniProgramRel): string;
|
|
6241
|
+
interface VisibleChannelMiniProgramRels {
|
|
6242
|
+
pinnedGame: ImChannelMiniProgramRel | null;
|
|
6243
|
+
floatingItems: readonly ImChannelMiniProgramRel[];
|
|
6244
|
+
}
|
|
6245
|
+
/** 置顶游戏与消息卡共用全屏;右下角最底部悬浮游戏走半屏。 */
|
|
6246
|
+
type ChannelMiniProgramRelOpenSurface = 'page' | 'half';
|
|
6247
|
+
/**
|
|
6248
|
+
* 频道 rel 打开面:只有 `float-game` 半屏,其余与点击小程序消息一致走全屏。
|
|
6249
|
+
* `float-link` 实际仍开外链,surface 不影响决策。
|
|
6250
|
+
*/
|
|
6251
|
+
declare function resolveChannelMiniProgramRelOpenSurface(rel: ImChannelMiniProgramRel): ChannelMiniProgramRelOpenSurface;
|
|
6252
|
+
/**
|
|
6253
|
+
* 对齐 iOS `ChatSetTopMsgViewMiniProgramMsgContentView setChannelInfo`:
|
|
6254
|
+
* 主标题取频道简介,胶囊取 rel 当前语言游戏名。
|
|
6255
|
+
* `rel.introduction` 是产品/社交内容简介,不是频道简介,不能拿来当标题。
|
|
6256
|
+
*/
|
|
6257
|
+
declare function resolveChannelPinnedGameCopy(input: {
|
|
6258
|
+
channelDescription?: string | null;
|
|
6259
|
+
rel: ImChannelMiniProgramRel;
|
|
6260
|
+
locale: string;
|
|
6261
|
+
}): {
|
|
6262
|
+
title: string;
|
|
6263
|
+
tag: string;
|
|
6264
|
+
name: string;
|
|
6265
|
+
};
|
|
6266
|
+
/** 右下角浮窗:链接在上、游戏在最底部。 */
|
|
6267
|
+
declare function sortChannelMiniProgramFloatingItems(items: readonly ImChannelMiniProgramRel[]): ImChannelMiniProgramRel[];
|
|
6268
|
+
/**
|
|
6269
|
+
* 按当前语言号与大厅币种过滤 `miniProgramRels`。
|
|
6270
|
+
* `undefined` 表示 info 尚未回填,不展示;空数组表示 info 已确认没有配置。
|
|
6271
|
+
* 置顶游戏还要有 appId 才展示,对齐 iOS `hasGamePromptWithChannelInfo`。
|
|
6272
|
+
*/
|
|
6273
|
+
declare function resolveVisibleChannelMiniProgramRels(rels: readonly ImChannelMiniProgramRel[] | undefined, input: {
|
|
6274
|
+
locale: string;
|
|
6275
|
+
currencyType: number | string | null | undefined;
|
|
6276
|
+
}): VisibleChannelMiniProgramRels;
|
|
6277
|
+
declare function channelMiniProgramRelKey(conversationId: string, rel: ImChannelMiniProgramRel): string;
|
|
6278
|
+
|
|
6279
|
+
/** IM 领域支持的 5 个展示 locale(与宿主规范 locale 一致)。 */
|
|
6280
|
+
type ImLocale = 'en-US' | 'th-TH' | 'vi-VN' | 'zh-CN' | 'zh-TW';
|
|
6281
|
+
|
|
6282
|
+
/**
|
|
6283
|
+
* IM 语义文案 catalog 的键、参数和完整性合同。
|
|
6284
|
+
* 键描述领域含义而非组件位置,使 Web/H5/SSR 可共享 formatter,宿主布局文案不进入此 schema。
|
|
6285
|
+
*/
|
|
6286
|
+
|
|
6287
|
+
/**
|
|
6288
|
+
* 命令/生命周期「操作提示」文案 key(formatServiceText 用;供 kit services / runtime 产语义码、宿主按 locale 渲染)。
|
|
6289
|
+
* 二期收敛:kit 框架无关层不再直接产中文,改产本联合里的码 + 参数(如 {reason}/{label}/{size}),由宿主经 im-i18n 渲染。
|
|
6290
|
+
* 动态原始报错(error.message)作为 `{reason}` 参数拼接,不入 catalog(属诊断,不翻译)。
|
|
6291
|
+
*/
|
|
6292
|
+
type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
|
|
6293
|
+
|
|
6203
6294
|
/** 会话列表摘要的框架无关分段;宿主可自行决定表情使用图片、文本或其它组件呈现。 */
|
|
6204
6295
|
type ConversationListPreviewSegment = {
|
|
6205
6296
|
kind: 'text' | 'mention';
|
|
@@ -6355,6 +6446,20 @@ type MessageNotificationDecision = {
|
|
|
6355
6446
|
/** PC/H5 共用的实时消息提醒规则;离线历史回放不逐条弹通知。 */
|
|
6356
6447
|
declare function resolveMessageNotificationDecision(input: MessageNotificationInput): MessageNotificationDecision;
|
|
6357
6448
|
|
|
6449
|
+
/**
|
|
6450
|
+
* 拼装频道 rel / 消息 22 打开小程序用的地址。
|
|
6451
|
+
* 有 host 时按大厅规则拼 suffix;只有 suffix 时只接受完整 URL 或带点的主机名,
|
|
6452
|
+
* 不能把 `/path` 当成域名。
|
|
6453
|
+
*/
|
|
6454
|
+
interface MiniProgramOpenUrlInput {
|
|
6455
|
+
domain?: string;
|
|
6456
|
+
suffixAddress?: string;
|
|
6457
|
+
h5Url?: string;
|
|
6458
|
+
}
|
|
6459
|
+
declare function resolveMiniProgramOpenUrl(input: MiniProgramOpenUrlInput): string;
|
|
6460
|
+
/** 悬浮外链:suffix 已是完整地址或主机名时直接用;只有路径时必须拼到 domain 上。 */
|
|
6461
|
+
declare function resolveMiniProgramFloatLinkUrl(input: MiniProgramOpenUrlInput): string;
|
|
6462
|
+
|
|
6358
6463
|
/**
|
|
6359
6464
|
* 官方 Chat Kit 和受控诊断工具使用的 SDK internal 入口。
|
|
6360
6465
|
* 它暴露完整 client、adapter 装配和领域原子,但仍不属于普通产品 API;生产宿主不得据此解析协议或持有密钥。
|
|
@@ -8513,11 +8618,10 @@ interface FormatTimeDisplayContext {
|
|
|
8513
8618
|
*/
|
|
8514
8619
|
declare function resolveDisplayTimestamp(primary: number | null | undefined, fallback: number | null | undefined): number | undefined;
|
|
8515
8620
|
/**
|
|
8516
|
-
*
|
|
8621
|
+
* 解析气泡和日期条共用的消息时间,与 SDK 时间线排序来源保持一致。
|
|
8517
8622
|
*
|
|
8518
|
-
*
|
|
8519
|
-
*
|
|
8520
|
-
* 入站或旧数据缺少有效 `createdAt` 时才回退服务端时间。
|
|
8623
|
+
* 收到有效 `serverTime` 后采用服务端时间,避免设备时钟快慢导致气泡时间、日期条与正式顺序不一致。
|
|
8624
|
+
* 尚未确认的乐观消息或缺少有效服务端时间的旧数据保留 `createdAt`;不修改原始发送意图时间。
|
|
8521
8625
|
*/
|
|
8522
8626
|
declare function resolveMessageTimelineTimestamp(createdAt: number | null | undefined, serverTime: number | null | undefined): number | undefined;
|
|
8523
8627
|
/**
|
|
@@ -8587,5 +8691,5 @@ declare function resampleWaveform(data: readonly number[], targetCount: number):
|
|
|
8587
8691
|
*/
|
|
8588
8692
|
declare function placeholderWaveform(seed: string, count: number): number[];
|
|
8589
8693
|
|
|
8590
|
-
export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, classifyGifFile, createChatRuntime, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createNewMessageBadgeController, createThreadItems, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
|
|
8591
|
-
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry };
|
|
8694
|
+
export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MINI_PROGRAM_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, createChatRuntime, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
|
|
8695
|
+
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MiniProgramHostLocale, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry, VisibleChannelMiniProgramRels };
|
package/dist/chat-kit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{p as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,o as DEFAULT_LOADING_SHOW_DELAY_MS,d as MINI_PROGRAM_LANG_NUMBERS,H as SPIKE_STEP,D as calculateMediaBox,s as canPromoteMediaPresentationSource,u as captureRuntimeClientOperation,t as captureRuntimeOperation,m as channelMiniProgramRelKey,q as createDelayedLoadingIndicator,B as createLinkMatcher,e as csvIncludes,c as decideChannelMiniProgramRelOpen,F as formatFileSize,E as formatMediaDuration,G as getFileExtension,A as hasLinkCandidate,y as highlightSegments,v as mediaService,z as normalizeLinkHref,K as placeholderWaveform,w as readService,J as resampleWaveform,r as resolveBestMediaPresentationSource,g as resolveChannelMiniProgramRelIcon,f as resolveChannelMiniProgramRelName,i as resolveChannelMiniProgramRelOpenSurface,h as resolveChannelMiniProgramRelUrl,j as resolveChannelPinnedGameCopy,n as resolveConversationListPresentation,C as resolveMediaPresentation,b as resolveMiniProgramFloatLinkUrl,a as resolveMiniProgramOpenUrl,x as resolveQuotedMessagePresentation,l as resolveVisibleChannelMiniProgramRels,k as sortChannelMiniProgramFloatingItems,I as spikeCountForDuration}from'./chunk-WYQXQOLW.js';export{j as DEFAULT_EMOJI_ASSET_BASE,i as EMOJI_CATALOG,c as EMOJI_GAME_DICE_STABLE_KEY,b as EMOJI_GAME_RPS_STABLE_KEY,m as EMOJI_TOKEN_RE,L as MAX_BATCH_FILES,a as MAX_RECENT_EMOJI_COUNT,g as UNICODE_EMOJI_CATALOG,K as blockReasonForChannelSession,J as blockReasonForChannelState,Q as blockReasonForGroupState,T as blockReasonForSession,E as canEditMessage,u as canPinChannelMessage,t as canPinGroupMessage,v as canPinMessage,D as canRecallMessage,aa as cancelMediaUpload,O as classifyGifFile,s as createChatRuntime,p as createEmojiMatcher,G as decideConversationAction,I as decideMemberTargetAction,H as decideMessageAction,l as emojiAssetUrl,n as emojiUrlByCode,Aa as fetchConversationFileBatch,Ba as fetchConversationImageBatch,ya as fetchConversationMessageBatch,Ca as fetchConversationVideoBatch,Da as fetchConversationVoiceBatch,Ea as fetchNextConversationSearchBatch,da as forwardService,o as hasEmojiCandidate,P as isGifFile,w as isPinnedMessageProtected,X as isVoiceStorageConfigured,M as mediaBatchBudgetBytes,ia as messageService,e as parseUnicodeEmojiCode,na as pinnedMessageService,d as prependRecentEmoji,xa as profileService,W as replaceInterruptedMediaFile,R as requiresConversationEncryption,z as resolveChannelMemberAvatarUrl,y as resolveChannelMemberDisplayName,k as resolveEmojiToken,C as resolveFriendDisplayName,oa as resolveImProfileAccessDestination,x as resolveMemberDisplayName,r as resolveMessageNotificationDecision,B as resolvePublicNickname,A as resolveSenderAvatarUrl,q as resolveStandaloneEmojiMessage,h as resolveUnicodeEmoji,ba as retryMessage,N as runMediaSendBatch,$ as sendAsFilesBatch,F as sendBlockReasonForDecision,Z as sendMediaAlbum,V as sendMediaFile,_ as sendMediaFilesBatch,U as sendText,Y as sendVoice,S as supportsConversationMention,f as unicodeEmojiTextFromCode}from'./chunk-V7ULSSTZ.js';export{C as createNewMessageBadgeController,i as createThreadItems,f as formatChatDateSeparator,e as formatConversationDisplayTime,c as getLocalDayKey,l as isMessageLocateScrollProtected,v as isMessageTailChangeFromOlderWindowTrim,k as isMessageViewportMeasurable,B as isMessageVisibleForNewMessageBadge,x as loadOlderUntilBoundary,p as refreshPrependMessageAnchorPosition,j as resolveCenteredMessageScrollTop,a as resolveDisplayTimestamp,g as resolveImThreadActiveDate,h as resolveMessageBodyKind,b as resolveMessageTimelineTimestamp,n as resolvePrependMessageAnchor,q as resolvePrependMessageAnchorAdjustment,o as resolvePrependMessageAnchorPosition,s as resolveSurvivingMessageAnchorAdjustment,r as resolveVisibleMessageAnchorPositions,t as shouldCompleteInitialViewport,y as shouldFillInitialHistoryViewport,u as shouldFollowIncomingMessage,z as shouldLoadNewerHistoryPage,m as shouldPrefetchOlderHistory,w as shouldRestoreMessageViewportFocus,d as shouldShowChatDateSeparator,A as shouldTrackRemoteMessageForBadge}from'./chunk-UNGWXAYA.js';import'./chunk-VMKTMZ3K.js';import'./chunk-SVJGRV4M.js';import'./chunk-GMVR64GN.js';export{ra as canTransmit,pa as canTransmitByType,qa as canTransmitContent,oa as requiresForwardTypeConfirmation}from'./chunk-LX7YEO5G.js';import'./chunk-WOT6VMZA.js';
|