Files
owncast/static/web/_next/static/chunks/4977-d9d119ca1d55fe08.js
2023-01-16 07:16:19 +00:00

2 lines
14 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4977],{94977:function(e,t,a){"use strict";a.r(t),a.d(t,{ChatContainer:function(){return ep}});var s,n,r,o,i,l=a(85893),c=a(26246),d=a(67294),h=a(5152),u=a.n(h),m=a(91951),p=a(59760),g=a.n(p),x=a(94184),_=a.n(x),C=a(94199),f=a(4480),j=a(27722),v=a(50085),y=a.n(v),b=a(77278);function N(e){let t=new Date(e);if(Number.isNaN(t))return"";let a=(0,b.Xb)(e);if(a>=1){let s=t.toLocaleDateString("en-US",{dateStyle:"medium"});return"".concat(s," at ").concat(t.toLocaleTimeString())}return"".concat(t.toLocaleTimeString())}var M=a(48976),w=a.n(M);let T=e=>{let{badge:t,userColor:a}=e,s="var(--theme-user-colors-".concat(a,")");return(0,l.jsx)("span",{style:{color:s,borderColor:s},className:w().badge,children:t})};var S=a(77466);let E=u()(()=>Promise.all([a.e(2074),a.e(8864)]).then(a.t.bind(a,38864,23)),{loadableGenerated:{webpack:()=>[38864]},ssr:!1}),k=u()(()=>Promise.all([a.e(173),a.e(164),a.e(4931),a.e(5402),a.e(7118),a.e(6386),a.e(3698),a.e(3013),a.e(4398),a.e(8091),a.e(8270),a.e(4860)]).then(a.bind(a,94860)).then(e=>e.ChatModerationActionMenu),{loadableGenerated:{webpack:()=>[94860]},ssr:!1}),O=u()(()=>Promise.resolve().then(a.bind(a,47049)).then(e=>e.Highlight),{loadableGenerated:{webpack:()=>[47049]},ssr:!1}),D=e=>{let{children:t,user:a}=e,{displayName:s,createdAt:n}=a,r="".concat(s," first joined ").concat(N(n));return(0,l.jsx)(C.Z,{title:r,placement:"topLeft",mouseEnterDelay:1,children:t})},A=e=>{let{message:t,highlightString:a,showModeratorMenu:s,sentBySelf:n,sameUserAsLast:r,isAuthorModerator:o,isAuthorAuthenticated:i}=e,{id:c,body:h,user:u,timestamp:m}=t,{id:p,displayName:g,displayColor:x}=u,v=(0,f.sJ)(S.FI),b="var(--theme-color-users-".concat(x,")"),M="Sent ".concat(N(m)),[w,A]=(0,d.useState)(h),B=[];return o&&B.push((0,l.jsx)(T,{badge:"mod",userColor:x},"mod")),i&&B.push((0,l.jsx)(T,{badge:(0,l.jsx)(E,{title:"authenticated"}),userColor:x},"auth")),(0,d.useEffect)(()=>{A((0,j.p1)(h))},[t]),(0,l.jsx)("div",{className:_()(y().messagePadding,r&&y().messagePaddingCollapsed,"chat-message_user"),children:(0,l.jsxs)("div",{className:_()(y().root,{[y().ownMessage]:n}),style:{borderColor:b},children:[!r&&(0,l.jsx)(D,{user:u,children:(0,l.jsxs)("div",{className:y().user,style:{color:b},children:[(0,l.jsx)("span",{className:y().userName,children:g}),(0,l.jsx)("span",{children:B})]})}),(0,l.jsx)(C.Z,{title:M,mouseEnterDelay:1,children:(0,l.jsx)(O,{search:a,children:(0,l.jsx)("div",{className:y().message,dangerouslySetInnerHTML:{__html:w}})})}),s&&(0,l.jsx)("div",{className:y().modMenuWrapper,children:(0,l.jsx)(k,{messageID:c,accessToken:v,userID:p,userDisplayName:g})}),(0,l.jsx)("div",{className:y().background,style:{color:b}})]})})};var B=a(55241),P=a(77493),U=a(96391),F=a(26912),G=a.n(F);let L=u()(()=>Promise.all([a.e(7741),a.e(1559)]).then(a.bind(a,51559)).then(e=>e.EmojiPicker),{loadableGenerated:{webpack:()=>[51559]},ssr:!1}),R=u()(()=>Promise.all([a.e(2074),a.e(3366)]).then(a.t.bind(a,73366,23)),{loadableGenerated:{webpack:()=>[73366]},ssr:!1}),I=u()(()=>Promise.all([a.e(2074),a.e(2348)]).then(a.t.bind(a,92348,23)),{loadableGenerated:{webpack:()=>[92348]},ssr:!1}),H=e=>{let{attributes:t,element:a,children:s}=e,n=(0,U.vt)(),r=(0,U.UE)();return(0,l.jsxs)("span",{...t,contentEditable:!1,children:[(0,l.jsx)("img",{alt:a.alt,src:a.src,title:a.name,style:{display:"inline",maxWidth:"50px",maxHeight:"20px",boxShadow:"".concat(n&&r?"0 0 0 3px #B4D5FF":"none")}}),s]})},W=e=>{let{isVoid:t}=e;return e.isVoid=e=>"image"===e.type||t(e),e.isInline=e=>"image"===e.type,e},V=e=>{let t;if(P.xv.isText(e)){let a=e.text;return a}if(0===e.children.length)t=[{text:""}];else{var s;t=null===(s=e.children)||void 0===s?void 0:s.map(e=>V(e)).join("")}switch(e.type){case"paragraph":return"<p>".concat(t,"</p>");case"image":return'<img src="'.concat(e.src,'" alt="').concat(e.alt,'" title="').concat(e.name,'" class="emoji"/>');default:return t}},Y=e=>{if(P.xv.isText(e))return e.text.length;if("image"===e.type)return 5;let t=0;return e.children.forEach(e=>{t+=Y(e)}),t},J=e=>{let{defaultText:t}=e,[a,s]=(0,d.useState)(!1),[n,r]=(0,d.useState)(null==t?void 0:t.length),o=(0,f.sJ)(S.Gt),i=(0,d.useMemo)(()=>(0,U.BU)(W((0,P.Jh)())),[]),c=()=>{if(!o){console.log("websocketService is not defined");return}let e=V(i);o.send({type:m.C.CHAT,body:e}),P.YR.delete(i,{at:{anchor:P.ML.start(i,[]),focus:P.ML.end(i,[])}}),r(0)},h=(e,t,a)=>({type:"image",alt:e,src:t,name:a,children:[{text:""}]}),u=(e,t)=>{if(!e)return;let{selection:a}=i,s=h(t,e,t);if(P.YR.insertNodes(i,s,{select:!0}),a){var n;let[r,o]=P.ML.parent(i,null===(n=a.focus)||void 0===n?void 0:n.path);i.isVoid(r)||P.NB.string(r).length?P.YR.insertNodes(i,s,{at:P.y$.next(o),select:!0}):(P.YR.insertNodes(i,s,{at:o,select:!0}),P.ML.normalize(i,{force:!0}))}else P.YR.insertNodes(i,s,{select:!0})},p=e=>{U.F3.focus(i),P.YR.insertText(i,e)},g=(e,t)=>{U.F3.focus(i),u(t,e)},x=e=>{let t=Y(i)+1;if("Enter"===e.key){e.preventDefault(),c();return}if("Backspace"===e.key){r(t-1);return}t+1>300&&e.preventDefault(),r(t+1)},C=e=>{let t=e.clipboardData.getData("text/plain"),{length:a}=t;n+a>300&&e.preventDefault()},j=e=>"image"===e.element.type?(0,l.jsx)(H,{...e}):(0,l.jsx)("p",{...e});return(0,l.jsx)("div",{className:G().root,children:(0,l.jsxs)("div",{className:_()(G().inputWrap,n>=300&&G().maxCharacters),children:[(0,l.jsxs)(U.mH,{editor:i,value:[{type:"paragraph",children:[{text:t||""}]}],children:[(0,l.jsx)(U.CX,{className:"chat-text-input",onKeyDown:x,onPaste:C,renderElement:j,placeholder:"Send a message to chat",style:{width:"100%"},role:"textbox","aria-label":"Chat text input",autoFocus:!0}),(0,l.jsx)(B.Z,{content:(0,l.jsx)(L,{onEmojiSelect:p,onCustomEmojiSelect:g}),trigger:"click",placement:"topRight",onOpenChange:e=>s(e),open:a})]}),(0,l.jsxs)("div",{style:{display:"flex",paddingLeft:"5px"},children:[(0,l.jsx)("button",{type:"button",className:G().emojiButton,title:"Emoji picker button",onClick:()=>s(!a),children:(0,l.jsx)(I,{})}),(0,l.jsx)("button",{type:"button",className:G().sendButton,title:"Send message Button",onClick:c,children:(0,l.jsx)(R,{})})]})]})})};var X=a(93107),z=a.n(X);function Z(){return(Z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e}).apply(this,arguments)}var q=function(e){return d.createElement("svg",Z({height:500,viewBox:"0 0 132.292 132.292",width:500,xmlns:"http://www.w3.org/2000/svg"},e),s||(s=d.createElement("linearGradient",{id:"moderator_svg__a",gradientUnits:"userSpaceOnUse",x1:432.851,x2:464.644,y1:49.977,y2:49.977},d.createElement("stop",{offset:0,stopColor:"#2087e2"}),d.createElement("stop",{offset:1,stopColor:"#b63fff"}))),n||(n=d.createElement("path",{d:"M438.672 34.08h20.151a5.82 5.82 45 0 1 5.82 5.821v20.151a5.82 5.82 135 0 1-5.82 5.821h-20.15a5.82 5.82 45 0 1-5.822-5.82V39.9a5.82 5.82 135 0 1 5.821-5.82z",fill:"url(#moderator_svg__a)",transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})),r||(r=d.createElement("path",{d:"M121.11 29.551c-6.93 47.444-30.074 104.618-77.642 79.674l25.83 23.067h38.772c13.377 0 24.22-10.845 24.22-24.222V40.864z",fill:"#1d1535",fillOpacity:.335})),o||(o=d.createElement("path",{d:"M66.775 13.257s-7.129 57.999-.63 99.312c6.565 41.724-81.568-74.394-49.619-79.203 31.949-4.809 50.249-20.11 50.249-20.11z",fill:"#e2e8f0",fillOpacity:.306})),i||(i=d.createElement("path",{d:"M435.995 42.072c6.797.447 12.753-4.806 12.753-4.806s5.955 5.253 12.752 4.806c-.581 12.745-7.495 20.586-12.752 20.628-5.188.042-12.172-7.883-12.753-20.628z",fill:"none",stroke:"#fff",strokeLinejoin:"round",strokeWidth:2,transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})))};let K=()=>(0,l.jsxs)("div",{className:z().chatModerationNotification,children:[(0,l.jsx)(q,{className:z().icon}),"You are now a moderator."]});var $=a(47049),Q=a(23421),ee=a.n(Q);let et=e=>{let{message:{body:t,user:{displayName:a}},highlightString:s}=e;return(0,l.jsxs)("div",{className:_()([ee().chatSystemMessage,"chat-message_system"]),children:[(0,l.jsx)("div",{className:ee().user,children:(0,l.jsx)("span",{className:ee().userName,children:a})}),(0,l.jsx)($.Highlight,{search:s,children:(0,l.jsx)("div",{className:ee().message,dangerouslySetInnerHTML:{__html:t}})})]})};var ea=a(91044),es=a.n(ea);let en=u()(()=>Promise.all([a.e(2074),a.e(8725)]).then(a.t.bind(a,8725,23)),{loadableGenerated:{webpack:()=>[8725]},ssr:!1}),er=e=>{let{isAuthorModerator:t,userColor:a,displayName:s}=e;return(0,l.jsxs)("div",{className:es().root,children:[(0,l.jsxs)("span",{style:{color:"var(--theme-color-users-".concat(a,")")},children:[(0,l.jsx)("span",{style:{padding:"0 10px"},children:(0,l.jsx)(en,{})}),(0,l.jsx)("span",{style:{fontWeight:"bold"},children:s}),t&&(0,l.jsx)("span",{children:(0,l.jsx)(T,{badge:"mod",userColor:a})})]})," ","joined the chat."]})};var eo=a(71577);let ei=u()(()=>Promise.all([a.e(2074),a.e(437)]).then(a.t.bind(a,20437,23)),{loadableGenerated:{webpack:()=>[20437]},ssr:!1}),el=e=>{let{chatContainerRef:t,messages:a}=e;return(0,l.jsx)("div",{className:g().toBottomWrap,children:(0,l.jsx)(eo.Z,{type:"default",style:{color:"currentColor"},icon:(0,l.jsx)(ei,{}),onClick:()=>t.current.scrollToIndex({index:a.length-1,behavior:"auto"}),children:"Go to last message"})})};var ec=a(65302),ed=a.n(ec);let eh=e=>{let{body:t}=e;return(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:t},className:ed().chatAction})},eu=u()(()=>Promise.all([a.e(2074),a.e(1668)]).then(a.t.bind(a,51668,23)),{loadableGenerated:{webpack:()=>[51668]},ssr:!1});function em(e){let{user:{scopes:t}}=e;return!!t&&0!==t.length&&t.includes("MODERATOR")}let ep=e=>{let{messages:t,usernameToHighlight:a,chatUserId:s,isModerator:n,showInput:r,height:o}=e,[i,h]=(0,d.useState)(!1),u=(0,d.useRef)(null),p=e=>{let{oldName:t,user:a}=e,{displayName:s,displayColor:n}=a,r="var(--theme-color-users-".concat(n,")");return(0,l.jsxs)("div",{className:g().nameChangeView,children:[(0,l.jsx)("div",{style:{marginRight:5,height:"max-content",margin:"auto 5px auto 0"},children:(0,l.jsx)(eu,{})}),(0,l.jsxs)("div",{className:g().nameChangeText,children:[(0,l.jsx)("span",{style:{color:r},children:t}),(0,l.jsx)("span",{className:g().plain,children:" is now known as "}),(0,l.jsx)("span",{style:{color:r},children:s})]})]})},x=e=>{let{user:{displayName:t,displayColor:a}}=e,s=em(e);return(0,l.jsx)(er,{displayName:t,userColor:a,isAuthorModerator:s})},_=e=>{let{body:t}=e;return(0,l.jsx)(eh,{body:t})},C=e=>{let t=em(e);return t?(0,l.jsx)(K,{}):(0,l.jsx)("div",{style:{width:"1px",height:"1px"}})},f=(e,r)=>{switch(r.type){case m.C.CHAT:var o,i,c;return(0,l.jsx)(A,{message:r,showModeratorMenu:n,highlightString:a,sentBySelf:(null===(o=r.user)||void 0===o?void 0:o.id)===s,sameUserAsLast:function(e,t){if(e.length<2)return!1;let a=e[t];if(!a||!a.user)return!1;let{user:{id:s}}=a,n=e[t-1];if((null==n?void 0:n.type)!==m.C.CHAT||!(null==n?void 0:n.timestamp)||!a.timestamp)return!1;let r=new Date(null==n?void 0:n.timestamp).getTime(),o=new Date(a.timestamp).getTime();return!(o-r>12e4)&&s===(null==n?void 0:n.user.id)}(t,e),isAuthorModerator:null===(i=r.user.scopes)||void 0===i?void 0:i.includes("MODERATOR"),isAuthorAuthenticated:null===(c=r.user)||void 0===c?void 0:c.authenticated},r.id);case m.C.NAME_CHANGE:return p(r);case m.C.CONNECTED_USER_INFO:return C(r);case m.C.USER_JOINED:return x(r);case m.C.CHAT_ACTION:return _(r);case m.C.SYSTEM:return(0,l.jsx)(et,{message:r,highlightString:a},r.id);default:return null}},j=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"smooth";setTimeout(()=>{var s;null===(s=e.current)||void 0===s||s.scrollToIndex({index:t.length-1,behavior:a})},100),h(!0)};(0,d.useEffect)(()=>{setTimeout(()=>{j(u,"auto")},500)},[]);let v=(0,d.useMemo)(()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.OO,{id:"virtuoso",style:{height:o},className:g().virtuoso,ref:u,data:t,itemContent:(e,t)=>f(e,t),followOutput:e=>(e&&j(u,"smooth"),!1),alignToBottom:!0,atBottomThreshold:70,atBottomStateChange:e=>{h(e)}}),!i&&(0,l.jsx)(el,{chatContainerRef:u,messages:t})]}),[t,a,s,n,i]);return(0,l.jsxs)("div",{id:"chat-container",className:g().chatContainer,children:[v,r&&(0,l.jsx)("div",{className:g().chatTextField,children:(0,l.jsx)(J,{})})]})};ep.defaultProps={showInput:!0,height:"auto"}},65302:function(e){e.exports={chatAction:"ChatActionMessage_chatAction__x9Xsg"}},59760:function(e){e.exports={toBottomWrap:"ChatContainer_toBottomWrap__3V5wa",nameChangeView:"ChatContainer_nameChangeView__ziyXN",nameChangeText:"ChatContainer_nameChangeText__yXG__",plain:"ChatContainer_plain__IPS19",chatContainer:"ChatContainer_chatContainer__O2lYN",virtuoso:"ChatContainer_virtuoso__OS9Kz",chatTextField:"ChatContainer_chatTextField__OqCGL"}},91044:function(e){e.exports={root:"ChatJoinMessage_root__vuVXa"}},93107:function(e){e.exports={chatModerationNotification:"ChatModeratorNotification_chatModerationNotification__kgFWe",icon:"ChatModeratorNotification_icon__7FdGg"}},23421:function(e){e.exports={chatSystemMessage:"ChatSystemMessage_chatSystemMessage__c6XEN",user:"ChatSystemMessage_user__6yHSJ",message:"ChatSystemMessage_message__ySq5g"}},26912:function(e){e.exports={root:"ChatTextField_root__4oUkJ",inputWrap:"ChatTextField_inputWrap__1mAjD",maxCharacters:"ChatTextField_maxCharacters__yGT4s",emojiButton:"ChatTextField_emojiButton__ON_Cu",sendButton:"ChatTextField_sendButton__MOmD4"}},48976:function(e){e.exports={badge:"ChatUserBadge_badge__1EdUp"}},50085:function(e){e.exports={root:"ChatUserMessage_root__79heB",user:"ChatUserMessage_user__xUEp9",message:"ChatUserMessage_message__MJ9LD",ownMessage:"ChatUserMessage_ownMessage__d28A3",background:"ChatUserMessage_background__Tfghp",modMenuWrapper:"ChatUserMessage_modMenuWrapper__7fblv",messagePadding:"ChatUserMessage_messagePadding__Xp1F6",messagePaddingCollapsed:"ChatUserMessage_messagePaddingCollapsed__qxN0E"}}}]);
//# sourceMappingURL=4977-d9d119ca1d55fe08.js.map