"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[7197],{37197:(t,r,e)=>{e.r(r),e.d(r,{User:()=>y,recreate_users_table:()=>u});var n,o=e(49344),s=e(76649),a=e(83798),i=e(19857),p=(n=function(t,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])},n(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),c=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return p(r,t),r.prototype.query=function(){var t=a.redux.getStore("page").get("kiosk_project_id");if(t){var r=e(26655).parse_query("collaborators_one_project");return r.collaborators_one_project[0].project_id=t,r}return"collaborators"},r.prototype.no_changefeed=function(){return null!=a.redux.getStore("page").get("kiosk_project_id")},r.prototype._change=function(t,r){var e=t.get(),n=s.h.get("user_map");if(null==n)return o.N.setState({user_map:e});t.get().map((function(t,r){return t!==n.get(r)&&(n=n.set(r,t)),!1})),o.N.setState({user_map:n})},r}(a.Table);function u(){a.redux.removeTable("users"),a.redux.createTable("users",c)}i.s&&null==a.redux.getStore("page").get("kiosk_project_id")||a.redux.createTable("users",c);var l=e(67557),_=e(38422),h=e(26131),f=e(93446),d=function(){var t=function(r,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])},t(r,e)};return function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),m=function(){return m=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t},m.apply(this,arguments)},y=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return d(r,t),r.prototype.shouldComponentUpdate=function(t){if(this.props.account_id!==t.account_id)return!0;var r=null!=t.user_map?t.user_map.get(this.props.account_id):void 0;return null==r||!r.equals(null!=this.props.user_map?this.props.user_map.get(this.props.account_id):void 0)||this.props.last_active!==t.last_active||this.props.show_original!==t.show_original||this.props.name!==t.name},r.prototype.render_last_active=function(){if(this.props.last_active)return(0,l.jsxs)("span",{children:[" ","(",(0,l.jsx)(_.TimeAgo,{date:this.props.last_active}),")"]})},r.prototype.render_original=function(t){var r;if(r=t.first_name&&t.last_name?t.first_name+" "+t.last_name:t.first_name?t.first_name:t.last_name?t.last_name:"No Name",this.props.show_original&&r!==this.props.name)return(0,l.jsx)(_.Tip,m({placement:"top",title:"User Name",tip:"The name this user has given their account."},{children:(0,l.jsxs)("span",m({style:{color:"#666"}},{children:[" (",r,")"]}))}))},r.prototype.name=function(t){return(0,h.trunc_middle)(null!=this.props.name?this.props.name:"".concat(t.first_name," ").concat(t.last_name),50).trim()||"No Name"},r.prototype.render=function(){if(null==this.props.user_map||0===this.props.user_map.size)return(0,l.jsx)("span",{children:"Loading..."});var t=null!=this.props.user_map?this.props.user_map.get(this.props.account_id):void 0;if(null==t)return(0,h.is_valid_uuid_string)(this.props.account_id)?(o.N.fetch_non_collaborator(this.props.account_id),(0,l.jsx)("span",{children:"Loading..."})):(0,l.jsxs)("span",{children:["Unknown User ",this.props.account_id]});t=t.toJS();var r=this.name(t);return(0,l.jsxs)("span",{children:[this.props.show_avatar&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.q,{account_id:this.props.account_id,first_name:r}),(0,l.jsx)(_.Space,{})]}),r,this.render_original(t),this.render_last_active()]})},r}(a.Component)}}]);