@talkjs/react-components
Version:
Provides chat UI components for TalkJS.
2 lines • 68.9 kB
JavaScript
"use client";
import e from"htm";import u,{useLayoutEffect as t,useEffect as n,useState as r,useCallback as D,useRef as o,createElement as i,forwardRef as a,createContext as c,useContext as s,useMemo as l,useReducer as F,Fragment as d}from"react";import*as f from"universal-base64";import{jsx as p,jsxs as E,Fragment as C}from"react/jsx-runtime";import m from"onecolor";import h from"wavesurfer.js";import{Decoration as g,DecorationSet as B,EditorView as v}from"prosemirror-view";import{Schema as A}from"prosemirror-model";import{PluginKey as y,Plugin as b,TextSelection as w,EditorState as x}from"prosemirror-state";import{keymap as k}from"prosemirror-keymap";import{history as M,undo as I,redo as O}from"prosemirror-history";import{baseKeymap as T}from"prosemirror-commands";import S,{EmailMatch as j,UrlMatch as _}from"autolinker";import{tracking as R,observe as L}from"@legendapp/state";import{ReplaceStep as N}from"prosemirror-transform";import{useStore as V,useChatboxController as P,useTheme as $,useEditorInternals as U}from"./globalConstants.js";import{useObservable as W,useSelector as H}from"@legendapp/state/react";import*as q from"@radix-ui/react-dropdown-menu";import{createPortal as z}from"react-dom";import{isFragment as K}from"react-is";var Y={TALK_GMK:"AIzaSyAs_WXNLlj31EHJI_Lw8siO2B3ZJLUzBH0",BASE_URL:"/",MODE:"react",DEV:!1,PROD:!0,SSR:!1};const G=function(e){return Y[e]}("TALK_GMK"),Q=/[^a-zA-Z\u00C0-\u024F\u1E00-\u1EFF\u0400-\u044f\u0300-\u036e]+/,X=e=>e.split(Q).filter((e=>e)).map((e=>e[0])).join("")||(e[Symbol.iterator]().next().value||"");function J(e){const u=function(e){let u=0;for(let t=0;t<e.length;t++)u=(u<<5)-u+e.charCodeAt(t),u|=0;return Math.abs(u)}(e)%te.length;return te[u]}function Z(e,u){const t=u.lastIndex;let n;const r=[];for(;null!==(n=u.exec(e));)r.push(n);return u.lastIndex=t,r}function ee(e,u,t){let n=0;const r=[];for(const D of u)D.offset<n||(D.offset>n&&r.push(e.substring(n,D.offset)),r.push(...t(D)),n=D.offset+D.matchedText.length);return n<e.length&&r.push(e.substring(n)),r}function ue(e){{const u=document.createElement("a");return u.href=e,u.hostname}}const te=["#996666","#9A6E61","#8D7662","#8E775E","#948771","#8A8360","#888D65","#6F8E63","#749378","#678975","#779E86","#639A8F","#6D92A1","#65869F","#697E9A","#736C9F","#8C6495","#956387","#B05D54","#B16D52","#AF8751","#AC8A56","#B7A458","#B5B35C","#83AA5D","#4F9D5D","#5FA777","#66B58F","#5FB3AC","#589AAF","#4E7F9E","#456CAC","#6456B7","#714AB2","#9771B5","#C154C1","#B05E81","#B04C6A","#B94E48","#AF593E","#C5994B","#B8C25D","#87AB39","#4FA83D","#40A860","#41AA78","#3AB09E","#3FC1AA","#56B4BE","#3EABBF","#4682B4","#7A58C1","#9966CC","#C54B8C","#B44668","#AE4560","#A3807B","#AB917A","#ACA586","#A8AF8E","#9EA587","#8BA690","#7DA98D","#7CB0A1","#8BA9A5","#7CA1A6","#859FAF","#8D90A1","#A397B4","#AE809E","#C08081","#BB8983","#B19461","#B5A27F","#B8B56A","#9AB973","#7AC488","#7CB7BB","#80B3C4","#788BBA","#7A89B8","#9678B6","#CB8FA9","#B57281","#C6726B","#C88A65","#C2955D","#C8B568","#B9C46A","#74C365","#6FD0C5","#6093D1","#7666C6","#D06DA1"];function ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function re(){}function De(){}De.resetWarningCache=re;function oe(){return!("undefined"==typeof window||!window.document||!window.document.createElement)}!function(){function e(e,u,t,n,r,D){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==D){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function u(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:u,element:e,elementType:e,instanceOf:u,node:e,objectOf:u,oneOf:u,oneOfType:u,shape:u,exact:u,checkPropTypes:De,resetWarningCache:re};t.PropTypes=t}();var ie=oe()?t:n;function ae(){var e=r(Object.create(null))[1];return D((function(){e(Object.create(null))}),[])}var ce,se=function(e){var u=e.children,t=e.type,n=void 0===t?"reach-portal":t,r=o(null),D=o(null),a=ae();return ie((function(){if(r.current){var e=r.current.ownerDocument;return D.current=null==e?void 0:e.createElement(n),e.body.appendChild(D.current),a(),function(){D.current&&D.current.ownerDocument&&D.current.ownerDocument.body.removeChild(D.current)}}}),[n,a]),D.current?z(u,D.current):i("span",{ref:r})},le=["bottom","height","left","right","top","width"],Fe=new Map,de=function e(){var u=[];Fe.forEach((function(e,t){var n,r,D=t.getBoundingClientRect();n=D,r=e.rect,void 0===n&&(n={}),void 0===r&&(r={}),le.some((function(e){return n[e]!==r[e]}))&&(e.rect=D,u.push(e))})),u.forEach((function(e){e.callbacks.forEach((function(u){return u(e.rect)}))})),ce=window.requestAnimationFrame(e)};function fe(e){return!(!e||"[object Function]"!={}.toString.call(e))}function pe(e,u,t){var n,D,i;"boolean"==typeof u?n=u:(n=null==(i=null==u?void 0:u.observe)||i,D=null==u?void 0:u.onChange);fe(t)&&(D=t);var a=r(e.current),c=a[0],s=a[1],l=o(!1),F=o(!1),d=r(null),f=d[0],p=d[1],E=o(D);return ie((function(){E.current=D,e.current!==c&&s(e.current)})),ie((function(){c&&!l.current&&(l.current=!0,p(c.getBoundingClientRect()))}),[c]),ie((function(){if(n){var u=c;if(F.current||(F.current=!0,u=e.current),u){var t,r,D=(t=u,r=function(e){null==E.current||E.current(e),p(e)},{observe:function(){var e=0===Fe.size;Fe.has(t)?Fe.get(t).callbacks.push(r):Fe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[r]}),e&&de()},unobserve:function(){var e=Fe.get(t);if(e){var u=e.callbacks.indexOf(r);u>=0&&e.callbacks.splice(u,1),e.callbacks.length||Fe.delete(t),Fe.size||cancelAnimationFrame(ce)}}});return D.observe(),function(){D.unobserve()}}}}),[n,c,e]),f}function Ee(e){return oe()?e?e.ownerDocument:document:null}function Ce(e,u){(null==u||u>e.length)&&(u=e.length);for(var t=0,n=new Array(u);t<u;t++)n[t]=e[t];return n}function me(e,u){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,u){if(e){if("string"==typeof e)return Ce(e,u);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ce(e,u):void 0}}(e))||u){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function he(e,u){if(null!=e)if(fe(e))e(u);else try{e.current=u}catch(t){throw new Error('Cannot assign value "'+u+'" to ref "'+e+'"')}}function ge(){for(var e=arguments.length,u=new Array(e),t=0;t<e;t++)u[t]=arguments[t];return D((function(e){for(var t,n=me(u);!(t=n()).done;){he(t.value,e)}}),u)}var Be=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'],ve=Be.join(","),Ae="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;function ye(e,u){u=u||{};var t,n,r,D=[],o=[],i=e.querySelectorAll(ve);for(u.includeContainer&&Ae.call(e,ve)&&(i=Array.prototype.slice.apply(i)).unshift(e),t=0;t<i.length;t++)be(n=i[t])&&(0===(r=ke(n))?D.push(n):o.push({documentOrder:t,tabIndex:r,node:n}));return o.sort(Me).map((function(e){return e.node})).concat(D)}function be(e){return!(!we(e)||function(e){return function(e){return Ie(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var u=e.ownerDocument.querySelectorAll('input[type="radio"][name="'+e.name+'"]'),t=function(e){for(var u=0;u<e.length;u++)if(e[u].checked)return e[u]}(u);return!t||t===e}(e)}(e)||ke(e)<0)}function we(e){return!(e.disabled||function(e){return Ie(e)&&"hidden"===e.type}(e)||function(e){return null===e.offsetParent||"hidden"===getComputedStyle(e).visibility}(e))}ye.isTabbable=function(e){if(!e)throw new Error("No node provided");return!1!==Ae.call(e,ve)&&be(e)},ye.isFocusable=function(e){if(!e)throw new Error("No node provided");return!1!==Ae.call(e,xe)&&we(e)};var xe=Be.concat("iframe").join(",");function ke(e){var u=parseInt(e.getAttribute("tabindex"),10);return isNaN(u)?function(e){return"true"===e.contentEditable}(e)?0:e.tabIndex:u}function Me(e,u){return e.tabIndex===u.tabIndex?e.documentOrder-u.documentOrder:e.tabIndex-u.tabIndex}function Ie(e){return"INPUT"===e.tagName}const Oe=ne(ye);function Te(){return Te=Object.assign||function(e){for(var u=1;u<arguments.length;u++){var t=arguments[u];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Te.apply(this,arguments)}var Se=["as","targetRef","position","unstable_observableRefs"],je=a((function(e,u){return i(se,null,i(_e,Te({ref:u},e)))})),_e=a((function(e,u){var t=e.as,r=void 0===t?"div":t,D=e.targetRef,a=e.position,c=void 0===a?Le:a,s=e.unstable_observableRefs,l=void 0===s?[]:s,F=function(e,u){if(null==e)return{};var t,n,r={},D=Object.keys(e);for(n=0;n<D.length;n++)t=D[n],u.indexOf(t)>=0||(r[t]=e[t]);return r}(e,Se),d=o(null),f=pe(d,{observe:!F.hidden}),p=pe(D,{observe:!F.hidden}),E=ge(d,u);return function(e,u){var t=Ee(e.current);function r(e){"Tab"===e.key&&u.current&&0===Oe(u.current).length||("Tab"===e.key&&e.shiftKey?s(e)?l(e):F(e)?d(e):p(e)&&C():"Tab"===e.key&&(o()?i(e):a()?c(e):f(e)&&C()))}function D(){var n=Oe(t),r=n&&e.current?n.indexOf(e.current):-1,D=n&&n[r+1];return(!u.current||!u.current.contains(D||null))&&D}function o(){return!!e.current&&e.current===t.activeElement}function i(e){var t=u.current&&Oe(u.current);t&&t[0]&&(e.preventDefault(),t[0].focus())}function a(){if(!!u.current&&u.current.contains(t.activeElement||null)){var e=u.current&&Oe(u.current);return Boolean(e&&e[e.length-1]===t.activeElement)}return!1}function c(e){var u=D();u&&(e.preventDefault(),u.focus())}function s(e){if(e.shiftKey){var u=D();return e.target===u}}function l(e){var t=u.current&&Oe(u.current),n=t&&t[t.length-1];n&&(e.preventDefault(),n.focus())}function F(e){var t=u.current&&Oe(u.current);return!!t&&(0!==t.length&&e.target===t[0])}function d(u){var t;u.preventDefault(),null==(t=e.current)||t.focus()}function f(e){var n=u.current?Oe(t).filter((function(e){return!u.current.contains(e)})):null;return!!n&&e.target===n[n.length-1]}function p(e){return e.target===Oe(t)[0]}n((function(){return t.addEventListener("keydown",r),function(){t.removeEventListener("keydown",r)}}),[]);var E=[];function C(){var e=u.current&&Oe(u.current);e&&(e.forEach((function(e){E.push([e,e.tabIndex]),e.tabIndex=-1})),t.addEventListener("focusin",m))}function m(){t.removeEventListener("focusin",m),E.forEach((function(e){var u=e[0],t=e[1];u.tabIndex=t}))}}(D,d),i(r,Te({"data-reach-popover":"",ref:E},F,{style:Te({position:"absolute"},Re.apply(void 0,[c,p,f].concat(l)),F.style)}))}));function Re(e,u,t){for(var n=arguments.length,r=new Array(n>3?n-3:0),D=3;D<n;D++)r[D-3]=arguments[D];return t?e.apply(void 0,[u,t].concat(r.map((function(e){return e.current})))):{visibility:"hidden"}}var Le=function(e,u){if(!e||!u)return{};var t=function(e,u,t,n){void 0===t&&(t=0);void 0===n&&(n=0);var r={top:e.top-u.height<0,right:window.innerWidth<e.left+u.width-t,bottom:window.innerHeight<e.bottom+u.height-n,left:e.left+e.width-u.width<0},D=r.right&&!r.left,o=r.left&&!r.right,i=r.bottom&&!r.top,a=r.top&&!r.bottom;return{directionRight:D,directionLeft:o,directionUp:i,directionDown:a}}(e,u),n=t.directionRight,r=t.directionUp;return Te({left:n?e.right-u.width+window.pageXOffset+"px":e.left+window.pageXOffset+"px"},function(e,u,t){return{top:t?e.top-u.height+window.pageYOffset+"px":e.top+e.height+window.pageYOffset+"px"}}(e,u,r))};var Ne=!1,Ve=0,Pe=function(){return++Ve};function $e(e,u){return c(u)}function Ue(){}function We(){return We=Object.assign||function(e){for(var u=1;u<arguments.length;u++){var t=arguments[u];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},We.apply(this,arguments)}var He=["element","index"];function qe(e,u){void 0===u&&(u={});return $e(0,We({descendants:[],registerDescendant:Ue,unregisterDescendant:Ue},u))}function ze(e){var u=e.context,t=e.children,n=e.items,r=e.set,o=D((function(e){var u=e.element,t=e.index,n=function(e,u){if(null==e)return{};var t,n,r={},D=Object.keys(e);for(n=0;n<D.length;n++)t=D[n],u.indexOf(t)>=0||(r[t]=e[t]);return r}(e,He);u&&r((function(e){var r;if(null!=t)return[].concat(e,[We({},n,{element:u,index:t})]).sort((function(e,u){return e.index-u.index}));if(0===e.length)r=[We({},n,{element:u,index:0})];else if(e.find((function(e){return e.element===u})))r=e;else{var D=e.findIndex((function(e){return!(!e.element||!u)&&Boolean(e.element.compareDocumentPosition(u)&Node.DOCUMENT_POSITION_PRECEDING)})),o=We({},n,{element:u,index:D});r=-1===D?[].concat(e,[o]):[].concat(e.slice(0,D),[o],e.slice(D))}return r.map((function(e,u){return We({},e,{index:u})}))}))}),[]),a=D((function(e){e&&r((function(u){return u.filter((function(u){return e!==u.element}))}))}),[]);return i(u.Provider,{value:l((function(){return{descendants:n,registerDescendant:o,unregisterDescendant:a}}),[n,o,a])},t)}function Ke(e){return"which"in e?3===e.which:"button"in e&&2===e.button}function Ye(e){var u=o(null);return n((function(){u.current=e}),[e]),u.current}function Ge(){for(var e=arguments.length,u=new Array(e),t=0;t<e;t++)u[t]=arguments[t];return u.filter((function(e){return null!=e})).join("--")}function Qe(e,u){return function(t){if(e&&e(t),!t.defaultPrevented)return u(t)}}function Xe(e,u){if(null==e)return{};var t,n,r={},D=Object.keys(e);for(n=0;n<D.length;n++)t=D[n],u.indexOf(t)>=0||(r[t]=e[t]);return r}function Je(){return Je=Object.assign||function(e){for(var u=1;u<arguments.length;u++){var t=arguments[u];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Je.apply(this,arguments)}var Ze=["onKeyDown","onMouseDown","id","ref"],eu=["index","isLink","onClick","onDragStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseUp","onSelect","disabled","onFocus","valueText","ref"],uu=["id","onKeyDown","ref"],tu=["onBlur","portal","position","ref"],nu="CLEAR_SELECTION_INDEX",ru="CLICK_MENU_ITEM",Du="CLOSE_MENU",ou="OPEN_MENU_AT_INDEX",iu="OPEN_MENU_CLEARED",au="SEARCH_FOR_ITEM",cu="SELECT_ITEM_AT_INDEX",su="SET_BUTTON_ID",lu=qe(),Fu=$e(0,{}),du={triggerId:null,isExpanded:!1,typeaheadQuery:"",selectionIndex:-1},fu=function(e){var u=e.id,t=e.children,D=o(null),a=o(null),c=o(null),s=r([]),l=s[0],d=s[1],f=function(e){var u=e||(Ne?Pe():null),t=r(u),D=t[0],o=t[1];return ie((function(){null===D&&o(Pe())}),[]),n((function(){!1===Ne&&(Ne=!0)}),[]),null!=D?String(D):void 0}(u),p=u||Ge("menu",f),E=Ge("menu-button",p),C=F(hu,Je({},du,{triggerId:E})),m=C[0],h=C[1],g=o(!1),B=o([]),v=o(!1),A=o({x:0,y:0}),y={dispatch:h,dropdownId:p,dropdownRef:a,mouseDownStartPosRef:A,popoverRef:c,readyToSelect:v,selectCallbacks:B,state:m,triggerClickedRef:g,triggerRef:D};return n((function(){m.isExpanded?(window.__REACH_DISABLE_TOOLTIPS=!0,window.requestAnimationFrame((function(){mu(a.current)}))):window.__REACH_DISABLE_TOOLTIPS=!1}),[m.isExpanded]),i(ze,{context:lu,items:l,set:d},i(Fu.Provider,{value:y},fe(t)?t({isExpanded:m.isExpanded,isOpen:m.isExpanded}):t))};function pu(e){var u=e.index,t=e.isLink,i=void 0!==t&&t,a=e.onClick,c=e.onDragStart,F=e.onMouseDown,d=e.onMouseEnter,f=e.onMouseLeave,p=e.onMouseMove,E=e.onMouseUp,C=e.onSelect,m=e.disabled,h=e.onFocus,g=e.valueText,B=e.ref,v=Xe(e,eu),A=gu(),y=A.dispatch,b=A.dropdownRef,w=A.mouseDownStartPosRef,x=A.readyToSelect,k=A.selectCallbacks,M=A.triggerRef,I=A.state,O=I.selectionIndex,T=I.isExpanded,S=o(null),j=r(g||""),_=j[0],R=j[1],L=D((function(e){!g&&null!=e&&e.textContent&&R(e.textContent)}),[g]),N=o(!1),V=function(e,u){var t=r(u),n=t[0],o=t[1];return[n,D((function(u){e.current=u,o(u)}),[])]}(S,null),P=V[0],$=V[1],U=function(e,u,t){var n=ae(),r=s(u),D=r.registerDescendant,o=r.unregisterDescendant,i=r.descendants,a=null!=t?t:i.findIndex((function(u){return u.element===e.element}));return ie((function(){return e.element||n(),D(We({},e,{index:a})),function(){o(e.element)}}),[e,n,a,D,o].concat(Object.values(e))),a}(l((function(){return{element:P,key:_,disabled:m,isLink:i}}),[m,P,i,_]),lu,u),W=U===O&&!m,H=ge(B,$,L);function q(){mu(M.current),C&&C(),y({type:ru})}return k.current[U]=C,n((function(){if(T){var e=window.setTimeout((function(){x.current=!0}),400);return function(){window.clearTimeout(e)}}x.current=!1}),[T,x]),n((function(){var e=Ee(S.current);return e.addEventListener("mouseup",u),function(){e.removeEventListener("mouseup",u)};function u(){N.current=!1}}),[]),{data:{disabled:m},props:Je({id:Cu(U),tabIndex:-1},v,{ref:H,"data-disabled":m?"":void 0,"data-selected":W?"":void 0,"data-valuetext":_,onClick:Qe(a,(function(e){Ke(e.nativeEvent)||i&&(m?e.preventDefault():q())})),onDragStart:Qe(c,(function(e){i&&e.preventDefault()})),onMouseDown:Qe(F,(function(e){Ke(e.nativeEvent)||(i?N.current=!0:e.preventDefault())})),onMouseEnter:Qe(d,(function(e){var u=Ee(b.current);W||null==U||m||(null!=b&&b.current&&b.current!==u.activeElement&&S.current!==u.activeElement&&b.current.focus(),y({type:cu,payload:{index:U}}))})),onMouseLeave:Qe(f,(function(e){y({type:nu})})),onMouseMove:Qe(p,(function(e){if(!x.current){var u=Math.abs(e.clientX-w.current.x),t=Math.abs(e.clientY-w.current.y);(u>8||t>8)&&(x.current=!0)}W||null==U||m||y({type:cu,payload:{index:U,dropdownRef:b}})})),onFocus:Qe(h,(function(){x.current=!0,W||null==U||m||y({type:cu,payload:{index:U}})})),onMouseUp:Qe(E,(function(e){Ke(e.nativeEvent)||(x.current?i?N.current?N.current=!1:S.current&&S.current.click():m||q():x.current=!0)}))})}}function Eu(e){e.id;var u=e.onKeyDown,t=e.ref,r=Xe(e,uu),D=gu(),o=D.dispatch,i=D.triggerRef,a=D.dropdownRef,c=D.selectCallbacks,l=D.dropdownId,F=D.state,d=F.isExpanded,f=F.triggerId,p=F.selectionIndex,E=F.typeaheadQuery,C=Bu(),m=ge(a,t);n((function(){var e=function(e,u){void 0===u&&(u="");if(!u)return null;var t=e.find((function(e){var t,n,r;return!e.disabled&&(null==(t=e.element)||null==(n=t.dataset)||null==(r=n.valuetext)?void 0:r.toLowerCase().startsWith(u))}));return t?e.indexOf(t):null}(C,E);E&&null!=e&&o({type:cu,payload:{index:e,dropdownRef:a}});var u=window.setTimeout((function(){return E&&o({type:au,payload:""})}),1e3);return function(){return window.clearTimeout(u)}}),[o,C,E,a]);var h=Ye(C.length),g=Ye(C[p]),B=Ye(p);n((function(){p>C.length-1?o({type:cu,payload:{index:C.length-1,dropdownRef:a}}):h!==C.length&&p>-1&&g&&B===p&&C[p]!==g&&o({type:cu,payload:{index:C.findIndex((function(e){return e.key===(null==g?void 0:g.key)})),dropdownRef:a}})}),[a,o,C,h,g,B,p]);var v=Qe((function(e){var u=e.key;if(d)switch(u){case"Enter":case" ":var t=C.find((function(e){return e.index===p}));t&&!t.disabled&&(e.preventDefault(),t.isLink&&t.element?t.element.click():(mu(i.current),c.current[t.index]&&c.current[t.index](),o({type:ru})));break;case"Escape":mu(i.current),o({type:Du});break;case"Tab":e.preventDefault();break;default:if("string"==typeof u&&1===u.length){var n=E+u.toLowerCase();o({type:au,payload:n})}}}),function(e,u){var t=s(e).descendants,n=u.callback,r=u.currentIndex,D=u.filter,o=u.key,i=void 0===o?"index":o,a=u.orientation,c=void 0===a?"vertical":a,l=u.rotate,F=void 0===l||l,d=u.rtl,f=void 0!==d&&d;return function(e){if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"].includes(e.key)){var u=null!=r?r:-1,o=D?t.filter(D):t;if(o.length){var a=o.findIndex((function(e){return e.index===r}));switch(e.key){case"ArrowDown":if("vertical"===c||"both"===c){e.preventDefault();var s=g();n("option"===i?s:s[i])}break;case"ArrowUp":if("vertical"===c||"both"===c){e.preventDefault();var l=B();n("option"===i?l:l[i])}break;case"ArrowLeft":if("horizontal"===c||"both"===c){e.preventDefault();var d=(f?g:B)();n("option"===i?d:d[i])}break;case"ArrowRight":if("horizontal"===c||"both"===c){e.preventDefault();var p=(f?B:g)();n("option"===i?p:p[i])}break;case"PageUp":e.preventDefault();var E=(e.ctrlKey?B:v)();n("option"===i?E:E[i]);break;case"Home":e.preventDefault();var C=v();n("option"===i?C:C[i]);break;case"PageDown":e.preventDefault();var m=(e.ctrlKey?g:A)();n("option"===i?m:m[i]);break;case"End":e.preventDefault();var h=A();n("option"===i?h:h[i])}}}function g(){return u===A().index?F?v():o[a]:o[(a+1)%o.length]}function B(){return u===v().index?F?A():o[a]:o[(a-1+o.length)%o.length]}function v(){return o[0]}function A(){return o[o.length-1]}}}(lu,{currentIndex:p,orientation:"vertical",rotate:!1,filter:function(e){return!e.disabled},callback:function(e){o({type:cu,payload:{index:e,dropdownRef:a}})},key:"index"}));return{data:{activeDescendant:Cu(p)||void 0,triggerId:f},props:Je({tabIndex:-1},r,{ref:m,id:l,onKeyDown:Qe(u,v)})}}function Cu(e){var u=s(Fu).dropdownId;return null!=e&&e>-1?Ge("option-"+e,u):void 0}function mu(e){e&&e.focus()}function hu(e,u){switch(void 0===u&&(u={}),u.type){case ru:case Du:return Je({},e,{isExpanded:!1,selectionIndex:-1});case"OPEN_MENU_AT_FIRST_ITEM":return Je({},e,{isExpanded:!0,selectionIndex:0});case ou:return Je({},e,{isExpanded:!0,selectionIndex:u.payload.index});case iu:return Je({},e,{isExpanded:!0,selectionIndex:-1});case cu:var t=u.payload.dropdownRef,n=void 0===t?{current:null}:t;if(u.payload.index>=0&&u.payload.index!==e.selectionIndex){if(n.current){var r=Ee(n.current);n.current!==(null==r?void 0:r.activeElement)&&n.current.focus()}return Je({},e,{selectionIndex:null!=u.payload.max?Math.min(Math.max(u.payload.index,0),u.payload.max):Math.max(u.payload.index,0)})}return e;case nu:return Je({},e,{selectionIndex:-1});case su:return Je({},e,{triggerId:u.payload});case au:return void 0!==u.payload?Je({},e,{typeaheadQuery:u.payload}):e;default:return e}}function gu(){return s(Fu)}function Bu(){return s(lu).descendants}function vu(){return vu=Object.assign||function(e){for(var u=1;u<arguments.length;u++){var t=arguments[u];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},vu.apply(this,arguments)}function Au(e,u){if(null==e)return{};var t,n,r={},D=Object.keys(e);for(n=0;n<D.length;n++)t=D[n],u.indexOf(t)>=0||(r[t]=e[t]);return r}var yu=["as","id","children"],bu=["as"],wu=["as"],xu=["as"],ku=["as"],Mu=["as"],Iu=a((function(e,u){var t=e.as,n=void 0===t?d:t,r=e.id,D=e.children,o=Au(e,yu),a=l((function(){try{return K(i(n,null))}catch(e){return!1}}),[n])?{}:vu({ref:u,id:r,"data-reach-menu":""},o);return i(n,a,i(fu,{id:r,children:D}))})),Ou=a((function(e,u){var t=e.as,r=void 0===t?"button":t,D=function(e){var u=e.onKeyDown,t=e.onMouseDown,r=e.id,D=e.ref,o=Xe(e,Ze),i=gu(),a=i.dispatch,c=i.dropdownId,s=i.mouseDownStartPosRef,F=i.triggerClickedRef,d=i.triggerRef,f=i.state,p=f.triggerId,E=f.isExpanded,C=ge(d,D),m=Bu(),h=l((function(){return m.findIndex((function(e){return!e.disabled}))}),[m]);return n((function(){null!=r&&r!==p&&a({type:su,payload:r})}),[p,a,r]),{data:{isExpanded:E,controls:c},props:Je({},o,{ref:C,id:p||void 0,onKeyDown:Qe(u,(function(e){switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),a({type:ou,payload:{index:h}});break;case"Enter":case" ":a({type:ou,payload:{index:h}})}})),onMouseDown:Qe(t,(function(e){Ke(e.nativeEvent)||(s.current={x:e.clientX,y:e.clientY},E||(F.current=!0),a(E?{type:Du}:{type:iu}))})),type:"button"})}}(vu({},Au(e,bu),{ref:u})),o=D.data,a=o.isExpanded,c=o.controls,s=D.props;return i(r,vu({"aria-expanded":!!a||void 0,"aria-haspopup":!0,"aria-controls":c},s,{"data-reach-menu-button":""}))})),Tu=a((function(e,u){var t=e.as,n=void 0===t?"div":t,r=pu(vu({},Au(e,wu),{ref:u})),D=r.data.disabled,o=r.props;return i(n,vu({role:"menuitem"},o,{"aria-disabled":D||void 0,"data-reach-menu-item":""}))})),Su=a((function(e,u){var t=e.as,n=void 0===t?"div":t,r=Au(e,xu);return i(Tu,vu({},r,{ref:u,as:n}))})),ju=a((function(e,u){var t=e.as,n=void 0===t?"div":t,r=Eu(vu({},Au(e,ku),{ref:u})),D=r.data,o=D.activeDescendant,a=D.triggerId,c=r.props;return i(n,vu({"aria-activedescendant":o,"aria-labelledby":a||void 0,role:"menu"},c,{"data-reach-menu-items":""}))})),_u=a((function(e,u){var t=e.as,r=void 0===t?"div":t,D=function(e){var u=e.onBlur,t=e.portal,r=void 0===t||t,D=e.position,o=e.ref,i=Xe(e,tu),a=gu(),c=a.triggerRef,s=a.triggerClickedRef,l=a.dispatch,F=a.dropdownRef,d=a.popoverRef,f=a.state.isExpanded,p=ge(d,o);return n((function(){if(f){var e=Ee(d.current);return e.addEventListener("mousedown",u),function(){e.removeEventListener("mousedown",u)}}function u(e){var u,t;s.current?s.current=!1:(u=d.current,t=e.target,u&&u.contains(t)||l({type:Du}))}}),[s,c,l,F,d,f]),{data:{portal:r,position:D,targetRef:c,isExpanded:f},props:Je({ref:p,hidden:!f,onBlur:Qe(u,(function(e){e.currentTarget.contains(e.relatedTarget)||l({type:Du})}))},i)}}(vu({},Au(e,Mu),{ref:u})),o=D.data,a=o.portal,c=o.targetRef,s=o.position,l=D.props,F={"data-reach-menu-popover":""};return a?i(je,vu({},l,F,{as:r,targetRef:c,position:s})):i(r,vu({},l,F))}));const Ru=Symbol("no_render");function Lu(e){const u=W(!1),t=o({_value:"function"==typeof e?e():e.peek(),get value(){return u.set(!0),t.current._value},set value(e){t.current._value=e}});return H((()=>{if(!u.get())return Ru;const n="function"==typeof e?e():e.get();return t.current.value=n,n})),t.current}function Nu(e){const u=$(),t=function(){const e=V(),u=P(),t=$(),n=Lu(e.state$.app.appMetadata),r=Lu(e.state$.currentUser),D=Lu(e.state$.currentConversation),o=Lu(e.t$),i=Lu(e.state$.device),a=Lu(e.state$.themeCustom),c=Lu((()=>e.state$.typing.child(e.state$.extCurrentConversationId.get()).get())),s=Lu((()=>e.state$.participants.child(e.state$.extCurrentConversationId.get()).get()));return l((()=>({store:e,chatbox:u,theme:t,get app(){return n.value},get currentUser(){return r.value},get conversation(){return D.value},get t(){return o.value},get device(){return i.value},get themeCustom(){return a.value.value},get typing(){return c.value},get participants(){return s.value}})),[n,u,D,r,i,e,o,t,a,c,s])}();return p(u.Icon,{common:t,...e})}function Vu({src:e,onError:u,filename:t,className:i=""}){const a=o(null),c=o(),s=o(),[l,F]=r(!1),[d,f]=r(0),[g,B]=r(1),v=o(),[A,y]=r(!1);n((()=>{c.current=new Audio;const n={normalize:!0,height:50,container:a.current};function r(){const e=c.current;if(!e)return;"PIPELINE_ERROR_READ: FFmpegDemuxer: demuxer seek failed"===e.error.message?(e.load(),F(!1)):(y(!0),F(!1),u?.())}const D=t.slice(t.lastIndexOf(".")+1);if(function(e){return/(?:^|\/)talkjs_audio_message_[0-9]+_([0-9]+)[.](?:mp3|webm)$/.test(e)}(t)&&"webm"===D&&!c.current.canPlayType("audio/webm;codecs=opus"))n.backend="WebAudio",s.current=new Audio("data:audio/mp3;base64,//MkxAAHiAICWABElBeKPL/RANb2w+yiT1g/gTok//lP/W/l3h8QO/OCdCqCW2Cw//MkxAQHkAIWUAhEmAQXWUOFW2dxPu//9mr60ElY5sseQ+xxesmHKtZr7bsqqX2L//MkxAgFwAYiQAhEAC2hq22d3///9FTV6tA36JdgBJoOGgc+7qvqej5Zu7/7uI9l//MkxBQHAAYi8AhEAO193vt9KGOq+6qcT7hhfN5FTInmwk8RkqKImTM55pRQHQSq//MkxBsGkgoIAABHhTACIJLf99nVI///yuW1uBqWfEu7CgNPWGpUadBmZ////4sL//MkxCMHMAH9iABEmAsKioqKigsLCwtVTEFNRTMuOTkuNVVVVVVVVVVVVVVVVVVV//MkxCkECAUYCAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"),s.current.controls=!1;else{const u=c.current;u.addEventListener("error",r),u.src=e,u.preload="auto",u.preservesPitch=!0,n.media=u}v.current=function(e){if(!e.container)return;const u=getComputedStyle(e.container);let t=m(u.color);return t||(t=m("rgb(255,255,255)")),h.create({...e,barGap:e.barGap??2,barRadius:e.barRadius??0,barWidth:e.barWidth??2,barHeight:e.barHeight,hideScrollbar:!0,cursorWidth:e.cursorWidth??0,cursorColor:e.cursorColor,height:e.height??24,progressColor:e.progressColor??t.cssa(),waveColor:e.waveColor??t.alpha(t.alpha()/2).cssa()})}(n);const o=v.current;return o.on("finish",(()=>{c.current.loop=!0,F(!1)})),o.on("ready",(e=>f(Math.trunc(e)))),o.on("timeupdate",(e=>f(Math.trunc(e)))),"WebAudio"===n.backend&&o.load(e).catch((()=>{y(!0),F(!1),u?.()})),()=>{c.current?.removeEventListener("error",r),c.current=void 0,o.destroy(),v.current=void 0}}),[e,t,u]);const b=D((()=>{if("WebAudio"===v.current.options.backend)v.current.isPlaying()||s.current.play(),v.current.playPause(),F(v.current.isPlaying()??!1);else{const e=c.current;e.paused?e.play():e.pause(),e.loop=!1,!e.paused&&e.ended&&(e.load(),e.play()),F(!e.paused)}}),[]),w=D((e=>{v.current.setPlaybackRate(e),B(e)}),[]);return A?p("div",{}):E("div",{className:`t-audio-player ${i}`,children:[p("button",{onClick:b,children:p(Nu,{className:"t-play-pause-icon",type:l?"pause":"play","aria-label":l?"pause audio":"play audio"})}),p("div",{className:"t-waveform",ref:a}),p("div",{className:"t-duration",children:An(d)}),p(Iu,{as:"div",children:({isExpanded:e})=>E(C,{children:[E(Ou,{className:"t-playback-speed","aria-label":"set playback speed",children:[g,"x",p(Nu,{type:"updown","aria-hidden":!0,className:"t-up-down-icon"})]}),e&&p(_u,{children:E(ju,{className:"t-action-menu",children:[p("div",{className:"t-playback-heading",children:"Playback Speed"}),[.25,.5,.75,1,1.25,1.5,2].map(((e,u)=>E(Su,{onSelect:()=>w(e),children:[p("span",{className:"t-playback-checkmark",children:g==e?"✓":""}),e,"x"]},u)))]})})]})})]})}const Pu=new A({nodes:{doc:{content:"paragraph+"},paragraph:{code:!0,content:"inline*",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},text:{group:"inline"},mention:{group:"inline",inline:!0,attrs:{id:{},name:{}},content:"text*",toDOM:e=>["span",{"data-mention-id":e.attrs.id},`@${e.attrs.name}`],parseDOM:[{tag:"span[data-mention-id]",getAttrs:e=>({id:e.dataset["mention-id"]})}]}},marks:{literal:{toDOM:()=>["span",{"data-literal":""}],parseDOM:[{tag:"span[data-literal]"}]},bold:{toDOM:()=>["b"],parseDOM:[{tag:"b"}]},italic:{toDOM:()=>["i"],parseDOM:[{tag:"i"}]},strikethrough:{toDOM:()=>["del"],parseDOM:[{tag:"del"}]},emoji:{attrs:{emoji:{}},toDOM:e=>["span",{"data-emoji":e.attrs.emoji},e.attrs.emoji],parseDOM:[{tag:"span[data-emoji]",getAttrs:e=>({emoji:e.dataset.emoji})}]}}}),$u=new y("placeholder"),Uu=new b({key:$u,props:{decorations(e){if(Wu(e.doc))return;const u=e.doc.firstChild,t=g.node(0,u.nodeSize,{class:"empty-node","data-placeholder":$u.getState(e)});return B.create(e.doc,[t])}},state:{init:()=>"",apply:(e,u)=>e.getMeta($u)??u}});function Wu(e){return 1!==e.childCount||0!==e.firstChild.childCount}function Hu(e,u){return e.reduce(((e,t,n)=>e.concat(u(t,n))),[])}const qu=(e,u,t=void 0)=>Hu(e,(e=>{if("string"==typeof e)return u(e,t);switch(e.type){case"bold":case"italic":case"strikethrough":case"blockquote":case"bulletlist":case"bulletList":case"bulletpoint":case"bulletPoint":return[{type:e.type,children:qu(e.children,u,e.type)}];case"link":return[{type:e.type,url:e.url,children:qu(e.children,u,e.type)}];case"actionlink":case"actionLink":case"actionbutton":case"actionButton":return[{type:e.type,action:e.action,params:e.params,children:qu(e.children,u,e.type)}];case"mention":case"autolink":case"autoLink":case"codeblock":case"codeBlock":case"codespan":case"codeSpan":case"suppressed":case"emoji":case"customemoji":case"customEmoji":return[e]}}));function zu(e,u){return t=>{const n=t;let r=0;const D=[];for(const o of Z(t,e)){o.index-r>0&&D.push(n.substring(r,o.index));const e=u(o);Array.isArray(e)?D.push(...e):D.push(e),r=o.index+o[0].length}return r<t.length&&D.push(t.substring(r)),D}}const Ku="’'()[]{}<>:,‒–—―…!.«»-‐?‘’“”;/⁄␠·&@*\\•^¤¢$€£¥₩₪†‡°¡¿¬#№%‰‱¶′§~¨_|¦⁂☞∴‽※".replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");var Yu=(e=>(e[e.italic=1]="italic",e[e.strikethrough=2]="strikethrough",e[e.bold=4]="bold",e))(Yu||{});const Gu=[0,1,2,3,4,5,6].map((e=>{const u=[];return 1&e||u.push(/_([^\s_].*?[^\s_])_|_([^\s_])_/),2&e||u.push(/~([^\s~].*?[^\s~])~|~([^\s~])~/),4&e||u.push(/\*([^\s*].*?[^\s*])\*|\*([^\s*])\*/),new RegExp(u.map((e=>e.source)).join("|"),"g")})),Qu={_:1,"*":4,"~":2};function Xu(e){return Ju(e,0)}function Ju(e,u=0){const t=Gu[u],n=t?function(e){const u=Zu.getOrCompute(e,(()=>new RegExp(`(?:^|[\\s${Ku}])(?:${e.source})(?=[\\s${Ku}]|$)`,"g"))),t=zu(u,(e=>{const u=e[0][1],t=e[1]||e[2]||e[3]||e[4]||e[5]||e[6];return[" ",{type:Yu[Qu[u]],children:[t]}]}));return e=>{const[u,...n]=t(" "+e);return u.length>1&&n.unshift(u.substring(1)),n}}(t):()=>[e];return qu(n(e),((e,t)=>"bold"===t||"italic"===t||"strikethrough"===t?Ju(e,u|Yu[t]):[e]))}const Zu=function(){const e=function(){try{return new WeakMap}catch(e){const u={has:()=>!1,get:()=>{},set:()=>u};return u}}();return{getOrCompute(u,t){if(e.has(u))return e.get(u);const n=t();return e.set(u,n),n}}}();function et(e,u=e){return{type:"autolink",url:e,text:u}}const ut=zu(/<!!mention:([^>\s]*?)\|(.*?)>/gm,(([e,u,t])=>function(e,u){return{type:"mention",id:e,text:u}}(decodeURIComponent(u),t))),tt=zu(/<!!customemoji:(.*?)>/gm,(([e,u])=>function(e){return{type:"customemoji",text:e}}(u))),nt=zu(/<((?:https?|mailto):.*?)\|(.*?)>/gi,(([e,u,t])=>function(e,u=[]){return{type:"link",url:e,children:u}}(u,[t]))),rt=zu(/<actionlink:([^|]+)[|]([^>]*)>/gi,(([e,u,t])=>{const{action:n,params:r}=ot(u);return function(e,u,t=[]){return{type:"actionlink",action:e,params:u,children:t}}(n,r,[t])})),Dt=zu(/<actionbutton:([^|]+)[|]([^>]*)>/gi,(([e,u,t])=>{const{action:n,params:r}=ot(u);return function(e,u,t=[]){return{type:"actionbutton",action:e,params:u,children:t}}(n,r,[t])}));function ot(e){const u=e.indexOf("?");if(-1===u)return{action:e,params:{}};return{action:e.slice(0,u),params:Object.fromEntries(new URLSearchParams(e.slice(u)))}}const it=zu(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g,(([e])=>function(e=[]){return{type:"bulletlist",children:e}}([e.startsWith("\n")?e.slice(1):e]))),at=zu(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm,(([e,u])=>({type:"bulletpoint",children:[u]}))),ct=e=>{const u=/(?:^|[^-:/\w])([(+]?[0-9](?:[-_+ ().]?[0-9]){5,11}[0-9])(?:[^-:/\w]|$)/g;let t=0;const n=[];for(const r of Z(e,u)){const u=r[0],D=r[1],o=u.startsWith(D)?r.index:r.index+1;o-t>0&&n.push(e.substring(t,o));const i=et("tel:"+D.replace(/[^0-9+]/g,""),D);n.push(i),t=o+D.length}return t<e.length&&n.push(e.substring(t)),n},st=e=>nt(e).flatMap((e=>"string"==typeof e?lt(e):["<",...lt(e.url),...lt("|"+e.children[0]+">")])),lt=e=>{const u=S.parse(e,{urls:!0,email:!0,phone:!1,hashtag:!1,mention:!1}),t=[];let n=0;for(const r of u){const u=r.getOffset(),D=r.getMatchedText(),o=D.length;let i=D;r instanceof j?i="mailto:"+r.getEmail():r instanceof _&&(i=r.getUrl()),u>n&&t.push(e.substring(n,u)),t.push(et(i,D)),n=u+o}return n<e.length&&t.push(e.substring(n)),t},Ft=["Codeblock","Codespan","FormattedLink","Wikitext","Autolink","Actions","Mention","Mention","BulletPoint","CustomEmoji"];function dt(e={except:[]}){const u={multilineSteps:[],singlelineSteps:[]},t=e.except??Ft.filter((u=>!e.only.includes(u)));return t.includes("BulletPoint")||u.multilineSteps.push(it,at),t.includes("Mention")||u.singlelineSteps.push(ut),t.includes("CustomEmoji")||u.singlelineSteps.push(tt),t.includes("Codespan")||u.multilineSteps.push(zu(/```([^]+?)```/g,(([e,u])=>({type:"codespan",text:u})))),t.includes("FormattedLink")||u.singlelineSteps.push(nt),t.includes("Actions")||(u.singlelineSteps.push(rt),u.singlelineSteps.push(Dt)),t.includes("Wikitext")||u.singlelineSteps.push(Xu),t.includes("Autolink")||u.singlelineSteps.push(st,ct),u}const ft=function(e){const u=RegExp(`[^${e}]+${e}?|${e}`,"g");return e=>Array.from(e.match(u)||[])}("\n");function pt(e,u={except:[]}){let t=function(e,u){let t=[e];return t=Et(t,u.multilineSteps),t=Et(t,[ft]),t=Et(t,u.singlelineSteps),t=Ct(t),t}(e,dt(u));return t=mt(t,!1),t}function Et(e,u){return u.reduce(((e,u)=>qu(e,u)),e)}function Ct(e){const u=[];let t=-1;for(const n of e)"string"==typeof n?"string"==typeof u[t]?u[t]+=n:u[++t]=n:u[++t]="children"in n?{...n,children:Ct(n.children)}:n;return u}function mt(e,u){const t=[];let n=[];for(let r=0;r<e.length;r++){const D=e[r];"string"==typeof D?n.push(D):"children"in D?(n.length>0&&(t.push(n.join("")),n=[]),D.children=mt(D.children,u||"link"===D.type||"actionbutton"===D.type||"actionlink"===D.type),t.push(D)):"autolink"===D.type&&u?n.push(D.text):(n.length>0&&(t.push(n.join("")),n=[]),t.push(D))}return n.length>0&&(t.push(n.join("")),n=[]),t}class ht extends Error{}function gt(e,u){if(!e)throw new ht(u??"Assertion failed")}const Bt=Object.assign(gt,{is:function(e,u,t){return gt(u,t)},unreachable:function(){throw new Error("Unreachable code")},keyNonNullable:function(e,u){if(!(u in e))throw new ht(`Missing key "${u}"`);const t=e[u];if(null==t)throw new ht(`Key "${u}" is null or undefined`)},insideObservingContext:function(){if(!R.current)throw new Error("You aren't inside an observing context")},never:function(e){throw new Error("Unreachable")},defined:function(e){if(null==e)throw new ht("Value is not defined")}});function vt(){let e,u=0;return t=>{const n=(n=Date.now())=>{window.clearTimeout(e),e=void 0,u=n;const r=function(e){e=e.removeMark(0,e.doc.content.size,Pu.marks.bold),e=e.removeMark(0,e.doc.content.size,Pu.marks.italic),e=e.removeMark(0,e.doc.content.size,Pu.marks.strikethrough),e.doc.firstChild;const u=function(e){const u=[];let t,n="";e.descendants(((e,r)=>(e.isText?(n+=e.text,t??=r):n&&void 0!==t&&(u.push({text:n,pos:t}),n="",t=void 0),e.type!==Pu.nodes.mention))),n&&void 0!==t&&u.push({text:n,pos:t});return u}(e.doc);for(const{text:t,pos:n}of u){const u=pt(t,{only:["Wikitext"]});[e]=At(e,n,u)}return e}(t.state.tr);t.dispatch(r)},r=Date.now();r-u<300?e||(e=window.setTimeout(n,300)):n(r)}}function At(e,u,t,n=0,r=[]){for(const D of t)if("string"==typeof D){for(const t of r)e.addMark(u+n,u+n+D.length,t.create());n+=D.length}else if("bold"===D.type||"italic"===D.type||"strikethrough"===D.type){n+=1;const t=Pu.marks[D.type],o=[...r,t];[e,n]=At(e,u,D.children,n,o),n+=1}else Bt.unreachable();return[e,n]}function yt(e){return(u,t)=>{if(!t)return!0;let n=u.tr;const r=w.between(u.selection.$from,u.selection.$to);return n=n.replaceRangeWith(r.from,r.from,Pu.text(e,n.storedMarks)),n=n.replaceRangeWith(r.to+1,r.to+1,Pu.text(e,n.storedMarks)),n=n.setSelection(w.near(n.doc.resolve(r.to+1))),t(n),!0}}function bt(e,u,t){const n=u.clipboardData;if(!n)return!1;const r=function(e){const u=e.items||[],t={"image/gif":"gif","image/png":"png","image/jpeg":"jpg","image/svg+xml":"svg"},n=Array.from(u).filter((e=>"file"===e.kind&&t[e.type]));if(0===n.length)return;if(e.types.includes("text/rtf"))return;const r=n[0];let D=r.getAsFile();if(!D.name){const e="image."+t[r.type];D=new File([D],e,{type:r.type,lastModified:Date.now()})}return D}(n);if(r)t(r);else{!function(e,u){const t=e.state.tr.insertText(u).scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste");e.dispatch(t)}(e,n.getData("text/plain"))}return!0}function wt({placeholder:e,disabled:u,className:t="",characterLimit:r,spellcheck:D}){const i=U(),a=o(),c=o(null);return n((()=>(a.current=function(e,u,t,n,r){const D=x.create({schema:Pu,plugins:[...r.filter(kt),M(),k({...T,"Mod-z":I,"Mod-y":O,"Mod-b":yt("*"),"Mod-i":yt("_"),"Mod-Enter":T.Enter,"Shift-Enter":T.Enter,Enter:t}),k({Enter:T.Enter}),Uu]}),o=vt(),i=new v(e,{handlePaste:(e,u,t)=>bt(e,u,n),clipboardTextSerializer(e){const u=[];return e.content.forEach((e=>{e&&u.push(e.textContent.replace(/<!!mention:.*?\|([^>]*)>/gim,"@$1"))})),u.join()},state:D,dispatchTransaction(e){e=(e=e.removeStoredMark(Pu.marks.literal)).removeStoredMark(Pu.marks.emoji);const t=i.state.apply(e);i.state.doc.eq(t.doc)||u(new xt(t.doc)),i.updateState(t),e.steps.some((e=>e instanceof N))&&setTimeout((()=>o(i)),0)}});return i}(c.current,(e=>i.onChange(e)),(()=>!!i.onEnter&&(i.onEnter(),!0)),(e=>i.onPasteImage(e)),[]),i.editorView=a.current,()=>{i.editorView=void 0,a.current?.destroy()})),[i]),n((()=>{a.current?.setProps({editable:()=>!u})}),[u]),n((()=>L((()=>a.current?.setProps({attributes:{spellcheck:String(i.spellcheck$.get()??D??!1),class:"t-text-input","aria-label":"Message Field",role:"textbox"}})))),[i,D]),n((()=>L((()=>{const u=a.current;u?.dispatch(u.state.tr.setMeta(Uu,i.placeholder$.get()??e))}))),[i,e]),n((()=>{r&&Number.isInteger(r)&&i.setMaxLength(r)}),[r,i]),p("div",{className:`t-editor ${t}`,ref:c})}class xt{constructor(e){this.doc=e,this.size=this.doc.content.size,this.hasContent=Wu(this.doc)}static{this.EMPTY=new xt(Pu.topNodeType.create())}asText(){return this.doc.textContent.replace(/\xa0/g," ")}}function kt(e){return null!=e}function Mt(e,u){if(!e()&&!u){u=e.toString().replace(/^function\s*\(\)\s*\{\s*return\s*(.*);\s*\}\s*$/,"`$1`")+" was not true"}}(e=>{function u(e){}function t(e,u){(function(e,u){switch(u){case"undefined":return void 0===e;case String:return"string"==typeof e||e instanceof String;case Boolean:return"boolean"==typeof e||e instanceof Boolean;case Number:return"number"==typeof e||e instanceof Number;default:return e instanceof u}})(e,u)||(u.name,String(e))}e.defined=u,e.has=function(e,u){e[u]},e.is=t,e.equals=function(e,u){},e.oneOf=function(e,u){u.includes(e)||JSON.stringify(u)},e.isArray=function(e,u){t(e,Array),e&&e.length>0&&t(e[0],u)},e.optional=function(e,u){void 0!==e&&t(e,u)},e.falsy=function(e){},e.never=function(e){}})(Mt||(Mt={}));const It=Mt,Ot=/^\/.*[^\\]\/[im]*$/;function Tt(e){if(!Ot.test(e))return!1;return!St(e).test("")}function St(e){const u=e.match(/^\/(.*[^\\])\/(.*)$/);if(!u)throw new Error(`Expected ${e} to be a (non-empty) regex`);let t=u[2]||"";return t=t.replace(/[^im]/g,"")+"g",new RegExp(u[1],t)}function jt(e){const u=e.replace(/\./g,"\\.").replace(/\*/g,".*");return new RegExp("^"+u+"$","i")}function _t(e,u){const t=ue(u),n=jt(e);return void 0!==t&&n.test(t)}const Rt=/^[]/g;function Lt(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}class Nt{constructor({mode:e,allowedHostnames:u,allowedPhoneNrs:t,allowedMatches:n,forbiddenMatches:r,suppressLinks:D,suppressEmailAddresses:o,suppressPhoneNumbers:i,replacement:a}){It.oneOf(e,["all","otherOnly","off"]),this.mode=e,this.suppressLinks=!1!==D,this.suppressEmailAddresses=!1!==o,this.suppressPhoneNumbers=!1!==i,this.allowedHostnames=u||[],this.allowedPhoneNrs=(t||[]).filter((e=>e)).map((e=>e.replace(/[^0-9]/g,""))),this.allowedMatches=(n||[]).filter(Tt).map((e=>St(e))),this.forbiddenMatches=(r||[]).filter(Tt).map((e=>St(e))),It((()=>this.allowedMatches.every((e=>e.flags.includes("g")))),"All regexes in `suppressContactInfo.allowedMatches` must be global. Check `allowedMatches`!"),It((()=>this.forbiddenMatches.every((e=>e.flags.includes("g")))),"All regexes in `suppressContactInfo.forbiddenMatches` must be global. Check `forbiddenMatches`!"),a=a?.trim(),this.replacement=a&&a.length>0?a:void 0}shouldSuppress({isContentBySender:e}){return"all"===this.mode||"otherOnly"===this.mode&&!e}}const Vt=new RegExp(":arslan:|"+/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uD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uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2