"use strict";const e=require("../../../../common/vendor.js");require("../../../adapter-vue.js");const t=require("../utils/conversationDraft.js"),l=require("../emoji-config/index.js"),n=require("../../../utils/env.js"),a=require("../utils/sendMessage.js"),o=e.defineComponent({__name:"message-input-editor",props:{placeholder:{type:String,default:"this is placeholder"},replayOrReferenceMessage:{type:Object,default:()=>({}),required:!1},isMuted:{type:Boolean,default:!0},muteText:{type:String,default:""},enableInput:{type:Boolean,default:!0},enableAt:{type:Boolean,default:!0},enableTyping:{type:Boolean,default:!0},isGroup:{type:Boolean,default:!1}},emits:["onTyping","onFocus","onAt"],setup(o,{expose:u,emit:i}){const r=o,s=i,d=e.ref("");e.ref();const v=e.ref(!0),c=e.ref(!0),f=new Map,p=e.ref(),m=e.ref(""),g=e.ref();e.onMounted((()=>{e.Jt.watch(e.o.CONV,{currentConversation:T}),e.Jt.watch(e.o.CHAT,{quoteMessage:b}),e.index.$on("insert-emoji",(e=>{var t;d.value+=null==(t=null==e?void 0:e.emoji)?void 0:t.name})),e.index.$on("send-message-in-emoji-picker",(()=>{h()}))})),e.onUnmounted((()=>{m.value&&t.DraftManager.setStore(m.value,d.value,d.value,g.value),e.index.$off("insertEmoji"),e.index.$off("send-message-in-emoji-picker"),e.Jt.unwatch(e.o.CONV,{currentConversation:T}),e.Jt.unwatch(e.o.CHAT,{quoteMessage:b}),v.value=!0,p.value=null,m.value="",g.value=null,j()}));const h=()=>{const e=y();j(),a.sendMessages(e,p.value)},y=()=>{let e=d.value;e=l.transformTextWithEmojiNamesToKeys(e);const t=[];null==f||f.forEach(((l,n)=>{(null==e?void 0:e.includes("@"+l))&&t.push(n)}));const n={text:e};return(null==t?void 0:t.length)&&(n.atUserList=t),[{type:"text",payload:n}]},j=()=>{d.value="",c.value=!0,null==f||f.clear()},x=e=>{d.value=e},M=()=>{v.value=!0},C=e=>{var t;v.value=!1,s("onFocus",null==(t=null==e?void 0:e.detail)?void 0:t.height)},q=t=>{var l,n;const a=null==(l=null==t?void 0:t.detail)?void 0:l.value;(()=>{var e;c.value=!(null==(e=null==d?void 0:d.value)?void 0:e.length)})(),r.isGroup&&(a.endsWith("@")||a.endsWith("@\n"))&&(null==(n=e.i)||n.hideKeyboard(),s("onAt",!0))};function T(e){const l=m.value;p.value=e,m.value=null==e?void 0:e.conversationID,l!==m.value&&(l&&t.DraftManager.setStore(l,d.value,d.value,g.value),j(),m.value&&t.DraftManager.getStore(m.value,x))}function b(e){g.value=e}return e.watch((()=>[c.value,v.value]),((e,t)=>{e!==t&&s("onTyping",c.value,v.value)}),{immediate:!0,deep:!0}),u({insertAt:e=>{(null==f?void 0:f.has(null==e?void 0:e.id))||null==f||f.set(null==e?void 0:e.id,null==e?void 0:e.label),d.value+=null==e?void 0:e.label},resetEditor:j,setEditorContent:x,getEditorContent:y}),(t,l)=>e.e({a:r.isMuted},r.isMuted?{b:e.t(r.muteText)}:{},{c:r.placeholder,d:e.o$1(h),e:e.o$1([t=>e.isRef(d)?d.value=t.detail.value:null,q]),f:e.o$1(M),g:e.o$1(C),h:e.unref(d),i:e.unref(n.isPC)?"":1})}}),u=e._export_sfc(o,[["__scopeId","data-v-4a88add0"]]);wx.createComponent(u);
