(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{403:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return c}));var o=n(136),r=n(124),a=n(128);function i(e){r.a.dispatch({action:a.a.EditEvent,event:null,timelineRenderingType:e.timelineRenderingType}),r.a.dispatch({action:a.a.FocusSendMessageComposer,context:e.timelineRenderingType})}function c(e,t){const n=t.getEvent().replacingEvent();!n||n.status!==o.EventStatus.QUEUED&&n.status!==o.EventStatus.NOT_SENT||e.cancelPendingEvent(n)}},926:function(e,t,n){"use strict";n.r(t),n.d(t,"sendMessage",(function(){return T})),n.d(t,"editMessage",(function(){return w}));var o=n(132),r=n.n(o),a=n(170),i=n(189),c=n(125),s=n(452),l=n(270),d=n(247),m=n(308),u=n(124),p=n(377),g=n(403),y=n(13),b=n.n(y),f=n(643),v=n(136),O=n(227);function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){b()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function h(e,t,n){let{relation:o,replyToEvent:r,permalinkCreator:a,includeReplyLegacyFallback:i=!0,editedEvent:s}=n;const l=Boolean(s),d=l?Boolean(null==s?void 0:s.replyEventId):Boolean(r),m=l&&d,u=t?await Object(f.richToPlain)(e):e,p=m&&function(e){const t=e.getContent().body;if("string"!=typeof t)return"";const n=t.split("\n").map((e=>e.trim()));return n.length>2&&n[0].startsWith("> ")&&0===n[1].length?`${n[0]}\n\n`:""}(s)||"",g=m&&function(e){const t=e.getContent().formatted_body;if(!t)return"";const n=(new DOMParser).parseFromString(t,"text/html").body.querySelector("mx-reply");return n&&n.outerHTML||""}(s)||"",y={msgtype:v.MsgType.Text,body:l?`${p} * ${u}`:u},b=c.b.getValue("MessageComposerInput.useMarkdown"),E=t?e:b?await Object(f.plainToRich)(e):null;E&&(y.format="org.matrix.custom.html",y.formatted_body=l?`${g} * ${E}`:E),l&&(y["m.new_content"]={msgtype:y.msgtype,body:u},E&&(y["m.new_content"].format="org.matrix.custom.html",y["m.new_content"].formatted_body=E));return function(e,t){t&&(e["m.relates_to"]=_(_({},e["m.relates_to"]||{}),t))}(y,l?_(_({},o),{},{rel_type:"m.replace",event_id:s.getId()}):o),!l&&r&&a&&Object(O.a)(y,r,{permalinkCreator:a,includeLegacyFallback:i}),y}const j=["roomContext","mxClient"];async function T(e,t,n){let{roomContext:o,mxClient:p}=n,g=r()(n,j);const{relation:y,replyToEvent:b}=g,{room:f}=o,v=null==f?void 0:f.roomId;if(!v)return;const O={eventName:"Composer",isEditing:!1,isReply:Boolean(b),inThread:(null==y?void 0:y.rel_type)===a.d.name};i.a.instance.trackEvent(O);const E=await h(e,t,g);if(!E.body.trim())return;c.b.getValue("Performance.addSendMessageTimingMetadata")&&Object(s.a)(E);const _=null!=y&&y.event_id&&(null==y?void 0:y.rel_type)===a.d.name?y.event_id:null,T=Object(l.a)(v,(e=>p.sendMessage(e,_,E)),p);return b&&u.a.dispatch({action:"reply_to_event",event:null,context:o.timelineRenderingType}),u.a.dispatch({action:"message_sent"}),d.CHAT_EFFECTS.forEach((e=>{if(Object(m.containsEmoji)(E,e.emojis)){(null==y?void 0:y.rel_type)!==a.d.name&&u.a.dispatch({action:`effects.${e.command}`})}})),c.b.getValue("Performance.addSendMessageTimingMetadata")&&T.then((e=>{Object(s.b)(p,v,e.event_id)})),c.b.getValue("scrollToBottomOnMessageSent")&&u.a.dispatch({action:"scroll_to_bottom",timelineRenderingType:o.timelineRenderingType}),T}async function w(e,t){let{roomContext:n,mxClient:o,editorStateTransfer:r}=t;const a=r.getEvent();i.a.instance.trackEvent({eventName:"Composer",isEditing:!0,inThread:Boolean(null==a?void 0:a.getThread()),isReply:Boolean(a.replyEventId)});const c=await h(e,!0,{editedEvent:a}),s=c["m.new_content"];if(""===(null==s?void 0:s.body))return Object(g.a)(o,r),void Object(p.a)({mxEvent:a,onCloseDialog:()=>{Object(g.b)(n)}});let l;const d=a.getRoomId();if(function(e,t){const n=t.getEvent().getContent();return n.msgtype!==e.msgtype||n.body!==e.body||n.format!==e.format||n.formatted_body!==e.formatted_body}(s,r)&&d){Object(g.a)(o,r);const e=r.getEvent().threadRootId||null;l=o.sendMessage(d,e,c),u.a.dispatch({action:"message_sent"})}return Object(g.b)(n),l}}}]);
//# sourceMappingURL=36.js.map