"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[560],{43682:(e,r,t)=>{t.d(r,{Z:()=>u});var n=t(89526),o=function(e,r,t){return e[r]?e[r][0]?e[r][0][t]:e[r][t]:"contentBoxSize"===r?e.contentRect["inlineSize"===t?"width":"height"]:void 0};function u(e){void 0===e&&(e={});var r=e.onResize,t=(0,n.useRef)(void 0);t.current=r;var u=e.round||Math.round,c=(0,n.useRef)(),i=(0,n.useState)({width:void 0,height:void 0}),l=i[0],a=i[1],s=(0,n.useRef)(!1);(0,n.useEffect)((function(){return function(){s.current=!0}}),[]);var f,h,d,v,g,y,x=(0,n.useRef)({width:void 0,height:void 0}),b=(f=(0,n.useCallback)((function(r){return c.current&&c.current.box===e.box&&c.current.round===u||(c.current={box:e.box,round:u,instance:new ResizeObserver((function(r){var n=r[0],c="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",i=o(n,c,"inlineSize"),l=o(n,c,"blockSize"),f=i?u(i):void 0,h=l?u(l):void 0;if(x.current.width!==f||x.current.height!==h){var d={width:f,height:h};x.current.width=f,x.current.height=h,t.current?t.current(d):s.current||a(d)}}))}),c.current.instance.observe(r,{box:e.box}),function(){c.current&&c.current.instance.unobserve(r)}}),[e.box,u]),h=e.ref,d=(0,n.useRef)(null),v=(0,n.useRef)(null),g=(0,n.useRef)(),y=(0,n.useCallback)((function(){var e=null;d.current?e=d.current:h&&(e=h instanceof HTMLElement?h:h.current),v.current&&v.current.element===e&&v.current.reporter===y||(g.current&&(g.current(),g.current=null),v.current={reporter:y,element:e},e&&(g.current=f(e)))}),[h,f]),(0,n.useEffect)((function(){y()}),[y]),(0,n.useCallback)((function(e){d.current=e,y()}),[y]));return(0,n.useMemo)((function(){return{ref:b,width:l.width,height:l.height}}),[b,l?l.width:null,l?l.height:null])}},56178:(e,r,t)=>{t.d(r,{Z:()=>g});var n=t(67557),o=t(89526),u=(t(20978),t(67442)),c=t(62150),i=t(91588),l=t(3416),a=t(31214),s=t(12841),f=t.n(s),h=function(){return(h=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},d=function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,u=t.call(e),c=[];try{for(;(void 0===r||r-- >0)&&!(n=u.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=u.return)&&t.call(u)}finally{if(o)throw o.error}}return c},v=function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};function g(e){var r,t,u=e.value,l=e.style,a=e.onChange,s=e.selectedHashtags,f=e.toggleHashtag,g=e.searchWords,b=(0,o.useRef)({}),p=(0,o.useRef)(u),w=d((0,o.useState)((0,c.markdown_to_slate)(u,!1,b.current)),2),m=w[0],S=w[1],R=(0,o.useMemo)((function(){if(null!=a)return function(e,r){var t=function(e,r,t){if(t||2===arguments.length)for(var n,o=0,u=r.length;o<u;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}([],d(m),!1);x(t,e,r)&&(a((0,i.l)(t,{cache:b.current})),S(t))}}),[m,a]);(0,o.useEffect)((function(){u!=p.current&&(p.current=u,S((0,c.markdown_to_slate)(u,!1,b.current)))}),[u]);var k=[],C=0;null!=g&&null==g.filter&&(g=Array.from(g));try{for(var j=v(m),H=j.next();!H.done;H=j.next()){var z=H.value;k.push((0,n.jsx)(y,{element:z,handleChange:R,selectedHashtags:s,toggleHashtag:f,searchWords:g},C)),C+=1}}catch(e){r={error:e}}finally{try{H&&!H.done&&(t=j.return)&&t.call(j)}finally{if(r)throw r.error}}return(0,n.jsx)("div",h({style:h({width:"100%"},l)},{children:k}))}function y(e){var r,t,o=e.element,c=e.handleChange,i=e.selectedHashtags,s=e.toggleHashtag,d=e.searchWords,g=[];if(o.children){var x=0;try{for(var b=v(o.children),p=b.next();!p.done;p=b.next()){var w=p.value;g.push((0,n.jsx)(y,{element:w,handleChange:c,selectedHashtags:i,toggleHashtag:s,searchWords:d},x)),x+=1}}catch(e){r={error:e}}finally{try{p&&!p.done&&(t=b.return)&&t.call(b)}finally{if(r)throw r.error}}}var m=o.type;if(m){if(null!=i&&"hashtag"==m)return(0,n.jsx)(a.Z,{value:o.content,selected:i.has(o.content),onClick:null!=s?function(){s(o.content)}:void 0});var S=(0,u.getStaticRender)(o.type);return(0,n.jsx)(S,{children:g,element:o,attributes:{},setElement:null==c?void 0:function(e){return c(o,e)}})}return(0,n.jsx)(l.default,h({leaf:o,text:{},attributes:{}},{children:null!=d?(0,n.jsx)(f(),{highlightStyle:{padding:0,backgroundColor:"#feff03"},searchWords:d,autoEscape:!0,textToHighlight:o.text}):o.text}))}function x(e,r,t){var n,o;try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var i=c.value;if(i===r){for(var l in t)i[l]=t[l];return!0}if(null!=i.children&&x(i.children,r,t))return!0}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}return!1}}}]);