@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 246 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[8064],{88791:(e,t,n)=>{n.d(t,{Z:()=>o});var r=n(75025),i=n.n(r)()((function(e){return e[1]}));i.push([e.id,".Codemirror-lean-messages{padding:0 2px 0 4px;min-width:15px;text-align:right;white-space:nowrap}",""]);const o=i},47869:(e,t,n)=>{n.r(t),n.d(t,{default:()=>a});var r=n(75701),i=n.n(r),o=n(88791);i()(o.Z,{insert:"head",singleton:!1});const a=o.Z.locals||{}},39926:(e,t,n)=>{n.d(t,{Z:()=>O,r:()=>P});var r=n(63505),i=n(32295),o=n(52224),a=n(92675),c=n.n(a),s=n(60799),l=n(24809),u=n(9572),f=n(9067),d=n(29180),h=n(82044),_=n(2902),m=n(46390),p=n(86931),v=n(34662),y=n(97299),g=n(85755),b=n(17867),w=n(97636),x=n(429),E=n(71308),k=n(63505);function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){S(e,t,n[t])}))}return e}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e){throw new Error("Unexpected object: "+e)}function O(e){var t=function(){return k.createElement(s.Z,{title:"Start the ".concat(null!=e.countdown?"countdown timer":"stopwatch")},k.createElement(l.Z,{icon:k.createElement(_.Z,null),onClick:function(){return e.clickButton("start")},style:e.compact?void 0:{width:"8em"}},e.compact?void 0:"Start"))},n=function(){return k.createElement(s.Z,{title:k.createElement(k.Fragment,null,"Reset the"," ",null!=e.countdown?"countdown timer":"stopwatch"," to"," ",null!=e.countdown?k.createElement(E.J,{compact:!0,amount:1e3*e.countdown}):"0")},k.createElement(l.Z,{icon:k.createElement(m.Z,null),onClick:function(){return e.clickButton("reset")}},e.compact?void 0:"Reset"))},a=function(){var t=e.setCountdown;if(null!=t)return k.createElement("div",null,k.createElement(s.Z,{title:"Edit countdown timer"},k.createElement(l.Z,{icon:k.createElement(p.Z,null),onClick:function(){return T(!0)}},e.compact?void 0:"Edit")),A&&k.createElement(u.Z,{open:!0,defaultValue:P(e.countdown),onChange:function(n){null!=n&&(t(n.second()+60*n.minute()+60*n.hour()*60),setTimeout((function(){return e.clickButton("reset")}),0))},showNow:!1,onOpenChange:function(e){e||T(!1)}}))},c=function(){var t=function(){var t=0;switch(e.state){case"stopped":break;case"paused":t=e.total||0;break;case"running":t=(e.total||0)+(w.webapp_client.server_time()-e.time);break;default:j(e.state)}return null!=e.countdown&&(t=Math.max(0,1e3*e.countdown-t)),t}();return k.createElement(k.Fragment,null,k.createElement(E.J,{key:"time",amount:t,compact:e.compact,showIcon:e.compact,countdown:e.countdown,style:z({},e.timeStyle,e.countdown&&0==t?{background:"#b71c1c",borderRadius:"3px",marginRight:"15px",color:"white"}:void 0)}),e.countdown&&0==t&&!e.readOnly&&k.createElement(f.Z,{title:k.createElement(k.Fragment,null,k.createElement(o.JO,{name:"hourglass-half"}),' A Countdown Timer in "',L.path,'" is Finished'),visible:!0,onOk:function(){var t;e.clickButton("reset"),null===(t=i.redux.getProjectActions(L.project_id))||void 0===t||t.open_file({path:L.path})},onCancel:function(){e.clickButton("reset")}},e.label&&k.createElement(g.Z,{value:e.label})))},R=function(){return k.createElement("div",{key:"buttons"},function(){switch(e.state){case"stopped":return k.createElement(l.Z.Group,null,t(),a());case"paused":return k.createElement(l.Z.Group,null,t(),n(),a());case"running":return k.createElement(l.Z.Group,null,k.createElement(s.Z,{title:"Pause the stopwatch"},k.createElement(l.Z,{icon:k.createElement(y.Z,null),onClick:function(){return e.clickButton("pause")},style:e.compact?void 0:{width:"8em"}},e.compact?void 0:"Pause")),n());default:return j(e.state),k.createElement("div",null)}}(),k.createElement("div",{style:{float:"right"}},function(){if(!e.compact&&!e.noDelete)return k.createElement(s.Z,{title:"Delete this ".concat(null!=e.countdown?"countdown timer":"stopwatch")},k.createElement(l.Z,{icon:k.createElement(v.Z,null),onClick:function(){return e.clickButton("delete")}},e.compact?void 0:"Delete"))}()))},S=C((0,r.useState)(!1),2),O=S[0],M=S[1],I=C((0,r.useState)(!1),2),A=I[0],T=I[1],D=(0,i.useForceUpdate)(),L=(0,x.s8)();return(0,r.useEffect)((function(){var e=setInterval(D,1e3);return function(){return clearInterval(e)}}),[]),e.compact?k.createElement("div",{style:{display:"flex"}},c(),!e.noButtons&&!e.readOnly&&k.createElement("div",{style:{marginTop:"3px",marginLeft:"5px"}},R())):e.noLabel?k.createElement("div",{style:z({borderBottom:"1px solid #666",background:"#efefef",padding:"15px"},e.style)},k.createElement("div",null,c()),k.createElement("div",null,R())):k.createElement("div",{style:{borderBottom:"1px solid #666",background:"#efefef",padding:"15px"}},k.createElement("div",{style:{float:"right",fontSize:"24px",color:"#666"}},null!=e.countdown?k.createElement(s.Z,{title:"Countdown Timer"},k.createElement(o.JO,{name:"hourglass-half"})):k.createElement(s.Z,{title:"Stopwatch"},k.createElement(o.JO,{name:"stopwatch"}))),k.createElement(d.Z,null,k.createElement(h.Z,{sm:12,md:12},c()),k.createElement(h.Z,{sm:12,md:12},O?k.createElement("div",{key:"edit-label",style:{fontSize:"25px",marginTop:"25px",width:"100%"}},k.createElement(b.Z,{autoFocus:!0,height:"150px",value:e.label?e.label:"",onChange:function(t){var n;null===(n=e.setLabel)||void 0===n||n.call(e,t)},onShiftEnter:function(){return M(!1)},onBlur:function(){return M(!1)}})):k.createElement("div",{key:"show-label",style:{fontSize:"16px",marginTop:"25px",width:"100%",color:e.label?"#444":"#999",borderBottom:"1px solid #999",marginBottom:"10px"},onClick:function(){return M(!0)}},e.label?k.createElement(g.Z,{value:e.label}):"Label"))),!e.noButtons&&!e.readOnly&&k.createElement(d.Z,{style:{marginTop:"5px"}},k.createElement(h.Z,{md:24},R())))}function P(e){var t=Math.round(null!=e?e:0),n=c()();return n.second(t%60),t=(t-t%60)/60,n.minute(t%60),t=(t-t%60)/60,n.hour(t),n}},71308:(e,t,n)=>{n.d(t,{A:()=>l,J:()=>s});var r=n(52224),i=n(63505);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){o(e,t,n[t])}))}return e}function c(e){var t="".concat(e);return 1===t.length&&(t="0".concat(t)),t}function s(e){var t=Math.round(e.amount/1e3),n=Math.floor(t/3600);t-=3600*n;var r=Math.floor(t/60),o=t-=60*r;return i.createElement("span",{style:a({fontSize:e.compact?void 0:"50pt",fontFamily:"courier"},e.style)},e.showIcon&&i.createElement(l,{countdown:e.countdown,style:{marginRight:"5px"}}),c(n),":",c(r),":",c(o))}function l(e){var t=e.countdown,n=e.style;return i.createElement(r.JO,{name:t?"hourglass-half":"stopwatch",style:n})}},33258:(e,t,n)=>{n.d(t,{w:()=>B});var r=n(85166),i=n(65753),o=n(33638),a=n(32295),c=n(20812),s=n(45919),l=n(11359),u=n(8407),f=n(95788);function d(e,t,n,r,i,o,a){try{var c=e[o](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,i)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){d(o,r,i,a,c,"next",e)}function c(e){d(o,r,i,a,c,"throw",e)}a(void 0)}))}}var _=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}};function m(e){var t=e.getDoc(),n=e.getScrollInfo();if(!(n.height<=0)){var r=e.coordsChar(n,"local");return{pos:{line:r.line,ch:r.ch},sel:t.listSelections(),ver:2}}}function p(e,t){return v.apply(this,arguments)}function v(){return(v=h((function(e,t){var n;return _(this,(function(r){switch(r.label){case 0:return t.ver<2?[2]:(n=$(e.getWrapperElement()).find(".CodeMirror-scroll"),t.pos?(n.css("opacity",0),[4,(0,f.delay)(0)]):[3,5]);case 1:r.sent(),r.label=2;case 2:return 0!=n.height()?[3,4]:document.body.contains(n[0])?[4,(0,f.delay)(250)]:[2];case 3:return r.sent(),[3,2];case 4:n.css("opacity",1),e.scrollTo(0,e.cursorCoords(t.pos,"local").top),e.refresh(),r.label=5;case 5:return t.sel&&e.getDoc().setSelections(t.sel),[2]}}))}))).apply(this,arguments)}var y=n(58573),g=n(24620),b=n(63505);function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function E(e,t){return!t||"object"!==R(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function k(e,t){return k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},k(e,t)}var R=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var S=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&k(e,t)}(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=x(t);if(n){var i=x(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return E(this,e)});function i(){return w(this,i),r.apply(this,arguments)}var o=i.prototype;return o.shouldComponentUpdate=function(e){return(0,g.is_different)(this.props,e,["line","gutter_id"])},o.componentDidMount=function(){this.init_gutter()},o.init_gutter=function(){this._elt=document.createElement("div"),a.ReactDOM.render(b.createElement("div",null,this.props.children),this._elt),this._handle=this.props.codemirror.setGutterMarker(this.props.line,this.props.gutter_id,this._elt),this.props.set_handle(this._handle)},o.componentWillUnmount=function(){void 0!==this._elt&&(a.ReactDOM.unmountComponentAtNode(this._elt),this._elt.remove(),delete this._elt),void 0!==this._handle&&(this.props.codemirror.setGutterMarker(this._handle,this.props.gutter_id,null),delete this._handle)},o.render=function(){return b.createElement("span",null)},i}(a.Component),z=n(63505);function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j(e){return j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},j(e)}function O(e,t){return!t||"object"!==M(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function P(e,t){return P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},P(e,t)}var M=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var I=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&P(e,t)}(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=j(t);if(n){var i=j(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return O(this,e)});function i(){return C(this,i),r.apply(this,arguments)}var o=i.prototype;return o.shouldComponentUpdate=function(e){return this.props.gutter_markers!==e.gutter_markers},o.render_gutter=function(e,t){var n,r=this,i=t.handle;if(null!=i){var o=this.props.codemirror.lineInfo(i);if(null!=o&&(n=o.line),void 0===n)return}return void 0===n&&(n=t.line),z.createElement(S,{key:e,codemirror:this.props.codemirror,line:n,gutter_id:t.gutter_id,set_handle:function(t){return r.props.set_handle(e,t)}},t.component)},o.render_gutters=function(){var e=this,t=[];return this.props.gutter_markers.forEach((function(n,r){t.push(e.render_gutter(r,n.toJS()))})),t},o.render=function(){return z.createElement("span",null,this.render_gutters())},i}(a.Component),A=n(30909);function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e,t,n,r,i,o,a){try{var c=e[o](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,i)}function L(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){D(o,r,i,a,c,"next",e)}function c(e){D(o,r,i,a,c,"throw",e)}a(void 0)}))}}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){G(e,t,n[t])}))}return e}var F=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},N={width:"100%",overflow:"auto",marginbottom:"1ex",minheight:"2em",border:"0px",background:"#fff"},B=a.React.memo((function(e){var t,n,f=function(){if(e.is_subframe&&null!=e.actions){var t,n=null===(t=e.actions.get_code_editor(e.id))||void 0===t?void 0:t.get_actions();if(null==n)return;if(n.path!=e.path)return;return n}return e.actions},d=function(){null!=O.current&&O.current.refresh()},h=function(){var t=e.misspelled_words;if(null!=O.current)return"browser"==t?(O.current.setOption("spellcheck",!0),void O.current.spellcheck_highlight([])):"disabled"==t?(O.current.setOption("spellcheck",!1),void O.current.spellcheck_highlight([])):void("string"!=typeof t?(O.current.setOption("spellcheck",!1),O.current.spellcheck_highlight(t.toJS())):console.warn("unsupported words option",t))},_=function(){var t;null===(t=f())||void 0===t||t.undo(e.id)},v=function(){var t;null===(t=f())||void 0===t||t.redo(e.id)},g=function(){null!=O.current&&($(O.current.getWrapperElement()).remove(),O.current=void 0)},b=function(){if(null!=O.current){var t=m(O.current);null!=t&&e.actions.save_editor_state(e.id,t)}},w=function(){var t,n;e.is_public||(null===(t=f())||void 0===t||t.set_syncstring_to_codemirror(void 0,!0),null===(n=f())||void 0===n||n.syncstring_commit())},x=function(){(0,i.OQ)()&&$(a.ReactDOM.findDOMNode(G.current)).make_height_defined()},E=function(){var t,n=O.current;if(null!=n){n._actions=f(),e.is_public?void 0!==e.value&&n.setValue(e.value):(0,y.WP)(e.project_id,e.path)?n.swapDoc((0,y.wr)(e.project_id,e.path)):(0,y.T4)(e.project_id,e.path,n);var i=(0,c.throttle)(b,150);if(n.on("scroll",i),(0,u.L)(n),null===(t=f())||void 0===t||t.set_cm(e.id,n),!e.is_public){var a=(0,c.debounce)(w,r.SAVE_DEBOUNCE_MS);n.on("beforeChange",(function(e,t){"paste"==t.origin&&w()})),n.on("change",(function(e,t){var n;a(),null!=t.origin&&"setValue"!==t.origin&&(null===(n=f())||void 0===n||n.exit_undo_mode())})),n.on("focus",(function(){B.current&&(e.actions.set_active_id(e.id),M.current&&n&&n.setOption("styleActiveLine",!0))})),n.on("blur",(function(){var e;M.current&&n&&n.setOption("styleActiveLine",!1),null!=(null==n?void 0:n.state.vim)&&(null===(e=o.Vim)||void 0===e||e.exitInsertMode(n)),w()})),n.on("cursorActivity",(function(e){if(P.current.is_current&&!e._setValueNoJump){var t=e.getDoc().listSelections().map((function(e){return{x:e.anchor.ch,y:e.anchor.line}})),n=f();null==n||n.set_cursor_locs(t),i()}})),n.undo=_,n.redo=v}}},k=function(t){if(null!=O.current){t||(t=(0,l.C)(e.path,e.editor_settings,e.gutters,f(),e.actions,e.id));var n=O.current;for(var r in t){var i=t[r];(0,c.isEqual)(n.options[r],i)||null!=i&&n.setOption(r,i)}}},R=function(){null!=O.current&&(O.current.somethingSelected()?o.commands.defaultTab(O.current):function(){if(null!=O.current){var e=O.current.getDoc().getCursor();0===e.ch||/\s/.test(O.current.getDoc().getLine(e.line)[e.ch-1])?O.current.options.indentWithTabs?o.commands.defaultTab(O.current):O.current.tab_as_space():S()}}())},S=function(){null!=O.current&&O.current.execCommand("autocomplete")},z=(t=(0,a.useState)(!1),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return o}}(t,n)||function(e,t){if(e){if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),C=z[0],j=z[1],O=(0,a.useRef)(void 0),P=(0,a.useRef)(e);P.current=e;var M=(0,a.useRef)(!1),D=(0,a.useRef)(null),G=(0,a.useRef)(null),B=(0,a.useIsMountedRef)();(0,a.useEffect)((function(){return g(),function(e){W.apply(this,arguments)}(e),function(){var t,n;null==O.current||e.is_public||(b(),null!=f()&&(null===(t=f())||void 0===t||t.set_value(O.current.getValue()),null===(n=f())||void 0===n||n.syncstring_commit()),g())}}),[e.path]),(0,a.useEffect)((function(){if(J.current)J.current=!1;else if(null!=O.current){var e=m(O.current);null!=e&&p(O.current,e)}}),[e.font_size]),(0,a.useEffect)((function(){null!=O.current&&O.current.setOption("readOnly",e.read_only)}),[e.read_only]),(0,a.useEffect)((function(){e.is_public&&null!=O.current&&null!=e.value&&O.current.setValueNoJump(e.value)}),[e.value]),(0,a.useEffect)(h,[e.misspelled_words]),(0,a.useEffect)(d,[e.resize]),(0,a.useEffect)(k,[e.editor_settings]);var U,V,J=(0,a.useRef)(!0);function W(){return W=L((function(e){var t,n,r;return F(this,(function(i){if(null==(t=a.ReactDOM.findDOMNode(D.current)))return[2];if(x(),null==(n=(0,l.C)(e.path,e.editor_settings,e.gutters,f(),e.actions,e.id)))throw Error("bug");if(M.current=n.styleActiveLine,n.styleActiveLine=!1,(e.is_public||e.read_only)&&(n.readOnly=!0),null==n.extraKeys&&(n.extraKeys={}),n.extraKeys.Tab=R,n.extraKeys["Cmd-/"]="toggleComment",n.extraKeys["Ctrl-/"]="toggleComment",null!=(r=f()._cm[e.id])){if(!O.current){if(O.current=r,!t.parentNode)return[2];t.parentNode.insertBefore(r.getWrapperElement(),t.nextSibling),k(n)}}else O.current=o.fromTextArea(t,n),E();return null!=e.editor_state&&p(O.current,e.editor_state.toJS()),e.is_public||h(),j(!0),e.is_current&&O.current.focus(),O.current.setOption("readOnly",e.read_only),d(),[2]}))})),W.apply(this,arguments)}return a.React.createElement("div",{className:"smc-vfill cocalc-editor-div",ref:G},a.React.createElement(A.y,{project_id:e.project_id,path:e.path,is_current:e.is_current}),a.React.createElement("div",{style:(U=Z({},N),V={fontSize:"".concat(e.font_size,"px")},V=null!=V?V:{},Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(V)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(V)).forEach((function(e){Object.defineProperty(U,e,Object.getOwnPropertyDescriptor(V,e))})),U),className:"smc-vfill"},function(){if(null!=e.cursors&&null!=O.current&&C)return a.React.createElement(s.Vx,{cursors:e.cursors,codemirror:O.current})}(),function(){if(C&&null!=e.gutter_markers&&null!=O.current)return a.React.createElement(I,{gutter_markers:e.gutter_markers,codemirror:O.current,set_handle:function(t,n){return e.actions._set_gutter_handle(t,n)}})}(),a.React.createElement("textarea",{ref:D,style:{display:"none"},placeholder:e.placeholder})))}));B.defaultProps={value:""},null==o.commands.save&&(o.commands.save=function(e){var t;null===(t=e.cocalc_actions)||void 0===t||t.explicit_save()})},28459:(e,t,n)=>{n.d(t,{J:()=>xe});var r=n(32295),i=n(19990),o=n(33667),a=n(50455),c=n(79574),s=n(39632),l=n(59274),u=r.React.memo((function(e){var t=function(e,t,a,c){if(!(null==f?void 0:f[e]))return null==a&&(0,i.isIconName)(e)?a=r.React.createElement(i.Icon,{name:e}):"string"==typeof a&&(0,i.isIconName)(a)&&(a=r.React.createElement(i.Icon,{name:a})),r.React.createElement(o.zx,{key:e,title:t,onClick:function(){return n.format_action(e)},style:{maxHeight:"30px",fontSize:c}},a)},n=e.actions,u=e.extension,f=e.exclude;return r.React.createElement("div",{style:{background:"#f8f8f8",margin:"0 1px"}},function(){if(!(null==f?void 0:f.font_dropdowns))return r.React.createElement(o.hE,{key:"font-dropdowns",style:{float:"right",marginRight:"1px"}},r.React.createElement(c.Z,{onClick:function(e){return n.format_action("font_family",e)}}),r.React.createElement(s.Z,{onClick:function(e){return n.format_action("font_size_new",e)}}),r.React.createElement(l.Z,{onClick:function(e){return n.format_action("format_heading_".concat(e))}}),r.React.createElement(a.E,{onChange:function(e){return n.format_action("color",e)}}))}(),r.React.createElement("div",{className:"cc-frame-tree-format-bar"},r.React.createElement(o.hE,{key:"text-style"},t("bold","Make selected text bold"),t("italic","Make selected text italics"),t("underline","Underline selected text"),t("strikethrough","Strike through selected text"),t("code","Format selected text as code"),t("sub","Make selected text a subscript","subscript"),t("sup","Make selected text a superscript","superscript"),t("comment","Comment out selected text")),r.React.createElement(i.Space,null),r.React.createElement(o.hE,{key:"insert"},t("format_code","Insert block of source code","CodeOutlined"),t("insertunorderedlist","Insert unordered list","list"),t("insertorderedlist","Insert ordered list","list-ol"),t("equation","Insert inline LaTeX math",r.React.createElement("span",null,"$")),t("display_equation","Insert displayed LaTeX math",r.React.createElement("span",null,"$$")),t("quote","Make selected text into a quotation","quote-left"),t("table","Insert table","table"),t("horizontalRule","Insert horizontal rule",r.React.createElement("span",null,"—"))),r.React.createElement(i.Space,null),r.React.createElement(o.hE,{key:"insert-dialog"},t("link","Insert link","link"),t("image","Insert image","image","12pt"),"tex"!==u?t("SpecialChar","Insert special character...",r.React.createElement("span",{style:{fontSize:"larger"}},"Ω")):void 0),function(){if(!(null==f?void 0:f.format_buttons))return r.React.createElement(r.React.Fragment,null,r.React.createElement(i.Space,null),r.React.createElement(o.hE,{key:"format"},t("format_code","Format selected text as code","code"),t("justifyleft","Left justify current text","align-left"),t("justifycenter","Center current text","align-center"),t("justifyright","Right justify current text","align-right"),t("justifyfull","Fully justify current text","align-justify")),r.React.createElement(i.Space,null),r.React.createElement(o.hE,{key:"format2"},t("unformat","Remove all formatting from selected text","remove")))}(),r.React.createElement(i.Space,null)))}),(function(){return!0})),f=n(63505),d={opacity:.85,position:"fixed",bottom:"0px",right:"0px",minWidth:"30%",zIndex:100,border:"0.5px solid lightgray",borderRadius:"3px",color:"#666",padding:"0 5px",fontSize:"9pt",background:"#fff",boxShadow:"-2px -2px 2px #ccc"};function h(e){var t=e.status,n=e.onClear;return f.createElement("div",{style:d},f.createElement(i.Icon,{name:"times",onClick:n,style:{float:"right",marginTop:"2.5px"}}),t,f.createElement(i.Space,null))}var _=n(24620),m=n(95788),p=n(63505),v=n(44651),y=n(65753),g=n(20831),b=n(429),w=n(97891),x=n(13435),E=n(67941),k=n(62403),R=n.n(k);function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){z(e,t,n[t])}))}return e}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var O=E.IS_TOUCH?5:2,P={padding:"".concat(O,"px"),background:x.COLORS.GRAY_LL,cursor:"ew-resize"},M={background:x.COLORS.GRAY,opacity:.8,zIndex:100},I=C({},P,M),A=C({},P,{cursor:"ns-resize"}),T=C({},A,M),D=p.memo((function(e){var t=e.dir,n=e.frame_tree,i=e.actions,o=e.safari_hack,a=e.containerRef,c=p.useRef(null),s=j((0,r.useState)(!1),2),l=s[0],u=s[1],f=j((0,r.useState)(!1),2),d=f[0],h=f[1],_="col"===t?"x":"y";return p.createElement(R(),{ref:c,axis:_,onStop:function(e,s){u(!1),(0,w.drag_stop_iframe_enable)(),function(e,o){var s=("col"===t?o.node.offsetLeft:o.node.offsetTop)+o[_]+O,l=r.ReactDOM.findDOMNode(a.current),u="col"===t?(s-l.offsetLeft)/l.offsetWidth:(s-l.offsetTop)/l.offsetHeight;null!=c.current&&(c.current.state[_]=0,$(r.ReactDOM.findDOMNode(c.current)).css("transform","")),i.set_frame_tree({id:n.get("id"),pos:u}),i.set_resize(),i.focus()}(0,s),o()},onStart:function(){u(!0),(0,w.drag_start_iframe_disable)()}},p.createElement("div",{style:function(){var e=d||l;switch(t){case"row":return e?T:A;case"col":return e?I:P}}(),onMouseEnter:function(){return h(!0)},onMouseLeave:function(){return h(!1)}}))})),L=n(85460),G=n(97636),Z=n(32687);function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var N={maxWidth:"100%",maxHeight:"30%",fontFamily:"monospace",fontSize:"85%",whiteSpace:"pre-wrap"},B=r.React.memo((function(e){var t=e.actions,n=e.active_id,o=e.available_features,a=e.derived_file_types,c=e.desc,s=e.editor_actions,l=e.editor_settings,u=e.editor_state,f=e.font_size,d=e.is_fullscreen,h=e.is_public,_=e.is_subframe,m=e.is_visible,p=e.local_view_state,v=e.path,y=e.project_id,g=e.reload,b=e.resize,w=e.settings,x=e.spec,E=e.status,k=e.tab_is_visible,R=e.terminal,S=e.placeholder;if(null==s)throw Error("bug -- editor_actions must not be null");if(null==s.name)throw Error("bug -- editor_actions.name must not be null");var z,C,j=s.name,O=e.component,P=(0,r.useRedux)(j,"read_only"),M=(0,r.useRedux)(j,"cursors"),I=(0,r.useRedux)(j,"value"),A=(0,r.useRedux)(j,"misspelled_words"),T=(0,r.useRedux)(j,"complete"),D=(0,r.useRedux)(j,"is_loaded"),B=(0,r.useRedux)(j,"error"),U=(0,r.useRedux)(j,"gutter_markers"),V=(z=(0,r.useState)(!1),C=2,function(e){if(Array.isArray(e))return e}(z)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return o}}(z,C)||function(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(e,t):void 0}}(z,C)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),J=V[0],W=V[1];return(0,r.useEffect)((function(){var e=c.get("path");null!=e&&G.webapp_client.file_client.is_deleted(e,y)&&W(!0)}),[c.get("path")]),J?r.React.createElement(Z.Z,{project_id:y,path:v,onOpen:function(){W(!1)}}):r.React.createElement("div",{id:"frame-".concat(c.get("id")),className:"smc-vfill",style:{background:"white",zIndex:1}},function(){if(_&&B&&c.get("id")===n)return r.React.createElement(i.ErrorDisplay,{banner:!0,error:B,onClose:function(){return s.set_error("")},body_style:N})}(),function(){if(!D)return r.React.createElement(i.Loading,{theme:"medium"});if(null==O)throw Error("component must not be null");return r.React.createElement(O,{id:c.get("id"),name:e.name,actions:t,editor_actions:s,mode:x.mode,read_only:c.get("read_only",P||h),is_public:h,font_size:c.get("font_size",f),path:v,fullscreen_style:x.fullscreen_style,project_id:y,editor_state:u.get(c.get("id"),(0,L.Map)()),is_current:c.get("id")===n,cursors:M,value:I,misspelled_words:A,is_fullscreen:d,reload:g,resize:b,reload_images:!!x.reload_images,gutters:null!=x.gutters?x.gutters:[],gutter_markers:U,editor_settings:l,terminal:R,settings:w,status:E,complete:T&&T.get(c.get("id")),derived_file_types:a,local_view_state:p,desc:c,available_features:o,is_subframe:_,is_visible:m,tab_is_visible:k,placeholder:S,onFocus:function(){return t.set_active_id(c.get("id"),!0)}})}())})),U=n(98410),V=n(53924),J=n(6407),W=n(81671),H=n(14761),Y=n(4668),q=n(20812),K=n(48668),X=n(94873),Q=n(68724);function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function te(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ne(){return ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ne.apply(this,arguments)}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){te(e,t,n[t])}))}return e}var ie="#f8f8f8",oe="#ddd",ae={background:oe,border:"1px solid ".concat("rgb(204,204,204)"),padding:"1px",flexDirection:"row",flexWrap:"nowrap",flex:"0 0 auto",display:"flex",minHeight:"34px"},ce={background:oe,padding:"5px 5px 0 5px",color:"#333",fontSize:"10pt",whiteSpace:"nowrap",flex:"1 1 auto",display:"inline-block"},se={padding:"5px 5px 0 5px",fontSize:"10pt",float:"right"};function le(e){switch(e){case"disconnected":return"rgb(255, 0, 0)";case"connecting":default:return"rgb(255, 165, 0)";case"connected":return"#666"}}var ue={width:"20px",display:"inline-block"},fe=E.IS_TOUCH?void 0:{background:"transparent",borderColor:"transparent"},de=function(e){var t,n=function(){return e.is_only||e.is_full?"34px":"30px"},a=function(e){return re({},e,{height:n(),marginBottom:"5px"})},c=function(e){return r.React.createElement(o.zx,ne({},e,{style:a(e.style)}),e.children)},s=function(e){return r.React.createElement(c,ne({},e),e.children)},l=function(t,n){var r;if(null==e.editor_actions[t])return!1;if(null==b.current){if(!n)return!0;var i,o=null!==(i=e.spec.buttons)&&void 0!==i?i:{};b.current="function"==typeof o?o(e.path):o}return!!(null===(r=b.current)||void 0===r?void 0:r[t])},u=function(){e.actions.close_frame(e.id)},f=function(){return e.is_only||e.is_full?void 0:"small"},d=function(t){e.actions.set_frame_type(e.id,t)},h=function(){return!(!e.is_only&&!e.is_full)},m=function(t,n){if(h()){var r=e.editor_spec[e.type].customize_buttons;if(null!=r){var i=r[t];if(null!=i&&null!=i.text)return i.text}return null!=n?n:(0,_.capitalize)(t)}},p=function(t,n){var r=e.editor_spec[e.type].customize_buttons;if(null!=r){var i=r[t];if(null!=i&&null!=i.title)return i.title}if(null!=n)return n},v=function(t){var n="",o=void 0;if(void 0!==e.title&&(n=e.title),null!=e.editor_spec){var a=e.editor_spec[e.type];null!=a&&(o=a.icon,n||(a.name?n=a.name:a.short&&(n=a.short)))}var c=t?Object.assign({},ce,{background:ie}):ce;return r.React.createElement("div",{style:c},o?r.React.createElement(i.Icon,{name:o}):null,r.React.createElement(i.Space,null),(0,_.trunc_middle)(n,25))},g=function(t){if(null!=e.page&&null!=e.pages){var n;if("number"==typeof e.pages){if(e.pages<=1)return;n=t?r.React.createElement(r.React.Fragment,null,r.React.createElement(H.Z,{style:{width:"9ex",top:"-4px",height:e.is_only||e.is_full?void 0:"30px"},step:-1,value:e.page,onChange:function(t){t&&(t<=1&&(t=1),"number"==typeof e.pages&&t>=e.pages&&(t=e.pages),e.actions.setPage(e.id,t))}})," ","/ ",e.pages):r.React.createElement(r.React.Fragment,null,e.page," / ",e.pages)}else{if(e.pages.size<=1)return;var i=e.pages.indexOf("".concat(e.page));n=-1==i?t?r.React.createElement(r.React.Fragment,null,r.React.createElement(Y.Z,{style:{width:"9ex",height:"30px"},value:e.page,onChange:function(t){t.target.value&&e.actions.setPage(e.id,t.target.value)}})," ","/ ",e.pages.size):r.React.createElement(r.React.Fragment,null,e.page," / ",e.pages.size):t?r.React.createElement(r.React.Fragment,null,r.React.createElement(Y.Z,{style:{width:"9ex",height:"30px"},value:e.page,onChange:function(t){return e.actions.setPage(e.id,t.target.value)}})," ","(",i+1," of ",e.pages.size,")"):r.React.createElement(r.React.Fragment,null,e.page," (",i+1," of ",e.pages.size,")")}return r.React.createElement("span",{key:"page",style:re({height:"30px",lineHeight:"30px",textAlign:"center"},t?void 0:{borderRight:"1px solid grey",paddingRight:"5px"})},n)}},b=(0,r.useRef)(null),w=(0,r.useForceUpdate)();(0,r.useEffect)((function(){b.current=null,w()}),[e.type]);var x,k,R=(x=(0,r.useState)(!1),k=2,function(e){if(Array.isArray(e))return e}(x)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return o}}(x,k)||function(e,t){if(e){if("string"==typeof e)return ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ee(e,t):void 0}}(x,k)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),S=R[0],z=R[1],C=(0,V.useStudentProjectFunctionality)(e.project_id);if(null==(null===(t=e.editor_actions)||void 0===t?void 0:t.name))throw Error("editor_actions must have name attribute");if(null==e.actions.name)throw Error("actions must have name attribute");var j,O=(0,r.useRedux)([e.editor_actions.name,"read_only"]),P=(0,r.useRedux)([e.editor_actions.name,"has_unsaved_changes"]),M=(0,r.useRedux)([e.editor_actions.name,"has_uncommitted_changes"]),I=(0,r.useRedux)([e.editor_actions.name,"show_uncommitted_changes"]),A=(0,r.useRedux)([e.editor_actions.name,"is_saving"]),T=(0,r.useRedux)([e.editor_actions.name,"is_public"]),D=(0,r.useRedux)("page","fullscreen"),L=(0,r.useRedux)([e.actions.name,"switch_to_files"]),G=e.id===e.active_id;return G?((j=(0,_.copy)(ae)).background=ie,e.is_only||e.is_full||(j.maxHeight="34px"),j.position="relative"):j=ae,(0,y.OQ)()&&(G||(j=(0,_.copy)(j)),e.is_only||e.is_full?j.minHeight="36px":j.minHeight="32px"),r.React.createElement(r.React.Fragment,null,r.React.createElement("div",{style:j,id:"titlebar-".concat(e.id),className:"cc-frame-tree-title-bar"},!G&&g(!1),G?r.React.createElement("div",{style:{flexFlow:"row nowrap",display:"flex"}},T?void 0:function(){if("kiosk"!=D&&!C.disableActions){var t=!(e.is_only||e.is_full),i=e.editor_spec[e.type];if(null==i||!i.hide_file_menu)return r.React.createElement(J.k,{key:"info",filename:e.path,project_id:e.project_id,is_public:!1,label:t?"":"File",style:t?{height:n()}:void 0})}}(),function(){var t;t=e.is_only||e.is_full?{maxHeight:"34px",marginLeft:"2px"}:{maxHeight:"30px"};var u=h(),d=[];d.push(g(!0)),d.push(function(){var t,n=h(),c=[];if((t=function(t){if(l("save",!0))return r.React.createElement(Q.k,{key:"save",has_unsaved_changes:P,has_uncommitted_changes:M,show_uncommitted_changes:I,set_show_uncommitted_changes:e.editor_actions.set_show_uncommitted_changes,read_only:O,is_public:T,is_saving:A,no_labels:!t,size:f(),style:a(),onClick:function(){e.editor_actions.save(!0),e.actions.explicit_save(),e.actions.focus(e.id)}})}(n))&&c.push(t),T||(t=function(t){if(l("time_travel"))return r.React.createElement(s,{key:"timetravel",title:"Show complete edit history",bsStyle:"info",style:a(),bsSize:f(),onClick:function(t){if(e.actions.name==e.editor_actions.name){var n=!t.shiftKey&&null!=e.editor_spec.time_travel;e.actions.time_travel({frame:n})}else e.editor_actions.time_travel({frame:!1})}},r.React.createElement(i.Icon,{name:"history"})," ",r.React.createElement(i.VisibleMDLG,null,t?"TimeTravel":void 0))}(n))&&c.push(t),(t=function(t){if(l("reload",!0))return r.React.createElement(s,{key:"reload",title:"Reload this file",bsSize:f(),onClick:function(){return e.actions.reload(e.id)}},r.React.createElement(i.Icon,{name:"reload"}),r.React.createElement(i.VisibleMDLG,null,t?" Reload":void 0))}(n))&&c.push(t),c.length>0)return r.React.createElement(o.hE,{key:"save-group"},c)}()),d.push(function(){if(l("build",!0))return r.React.createElement(s,{key:"build",disabled:!!e.status,bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).build)||void 0===n?void 0:n.call(t,e.id,!1)},title:"Build (disable automatic builds in Account → Editor → 'Build on save')"},r.React.createElement(i.Icon,{name:"play-circle"})," ",r.React.createElement(i.VisibleMDLG,null,"Build"))}()),d.push(function(){if(l("force_build",!0))return r.React.createElement(s,{key:"force-build",disabled:!!e.status,bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).force_build)||void 0===n?void 0:n.call(t,e.id)},title:"Force rebuild entire project"},r.React.createElement(i.Icon,{name:"play"})," ",r.React.createElement(i.VisibleMDLG,null,"Force Rebuild"))}()),d.push(function(){if(l("edit")&&!T)return r.React.createElement(s,{key:"edit",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).edit)||void 0===n?void 0:n.call(t,e.id)},title:p("shell","Click to edit file directly here")},r.React.createElement(i.Icon,{name:"lock"})," ",r.React.createElement(i.VisibleMDLG,null,"Locked"))}()),d.push(function(){if(l("readonly_view")&&!T)return r.React.createElement(s,{key:"readonly-view",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).readonly_view)||void 0===n?void 0:n.call(t,e.id)},title:p("shell","Click to switch to readonly view")},r.React.createElement(i.Icon,{name:"pencil"})," ",r.React.createElement(i.VisibleMDLG,null,"Editable"))}()),d.push(function(){if(l("sync")&&null!=e.actions.sync){var t=h();return r.React.createElement(c,{key:"sync",title:"Synchronize views (".concat(E.IS_MACOS?"⌘":"Alt"," + Enter)"),bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).sync)||void 0===n?void 0:n.call(t,e.id,e.editor_actions)}},r.React.createElement(i.Icon,{name:"sync"})," ",t?r.React.createElement(i.VisibleMDLG,null,"Sync"):void 0)}}()),d.push(function(){if(l("switch_to_file")&&null!=e.actions.switch_to_file&&null!=L&&!(L.size<=1))return r.React.createElement(i.DropdownMenu,{key:"switch-to-file",button:!0,style:{height:n()},title:(0,_.path_split)(e.path).tail,onClick:function(t){e.actions.switch_to_file(t,e.id)}},L.toJS().map((function(t){return r.React.createElement(i.MenuItem,{key:t},e.path==t?r.React.createElement("b",null,t):t,e.actions.path==t?" (main)":"")})))}()),d.push(function(){if(l("clean",!0))return r.React.createElement(s,{key:"clean",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).clean)||void 0===n?void 0:n.call(t,e.id)},title:"Clean auxiliary build files"},r.React.createElement(i.Icon,{name:"trash"})," ",r.React.createElement(i.VisibleMDLG,null,h()?"Clean":void 0))}()),d.push(r.React.createElement(o.hE,{key:"zoom"},function(){if(l("set_zoom",!0)){var t=[50,85,100,115,125,150,200].map((function(e){return r.React.createElement(i.MenuItem,{key:e},"".concat(e,"%"))})),o=null==e.font_size?"Zoom":"".concat(Math.round(100*e.font_size/(0,X.I2)()),"%");return r.React.createElement(i.DropdownMenu,{key:"zoom-levels",button:!0,title:o,style:{height:n()},onClick:function(t){e.actions.set_zoom(parseInt(t)/100,e.id)}},t)}}(),function(){if(l("decrease_font_size",!0))return r.React.createElement(c,{key:"font-increase",title:"Decrease font size (control + <)",bsSize:f(),onClick:function(){return e.actions.decrease_font_size(e.id)}},r.React.createElement(i.Icon,{name:"search-minus"}))}(),function(){if(l("increase_font_size",!0))return r.React.createElement(c,{key:"font-decrease",title:"Increase font size (control + >)",onClick:function(){return e.actions.increase_font_size(e.id)},bsSize:f()},r.React.createElement(i.Icon,{name:"search-plus"}))}())),d.push(function(){if(l("rescan_latex_directive",!0))return r.React.createElement(s,{key:"rescan-latex-directive",disabled:!!e.status,bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.editor_actions).rescan_latex_directive)||void 0===n?void 0:n.call(t)},title:"Rescan document for build directive"},r.React.createElement(i.Icon,{name:"reload"})," ",r.React.createElement(i.VisibleMDLG,null,"Directive"))}()),T||d.push(function(){var t,n=[];if((t=function(){if(l("undo"))return r.React.createElement(s,{key:"undo",title:"Undo last thing you did",onClick:function(){return e.editor_actions.undo(e.id)},disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"undo"}))}())&&n.push(t),(t=function(){if(l("redo"))return r.React.createElement(s,{key:"redo",title:"Redo last thing you undid",onClick:function(){return e.editor_actions.redo(e.id)},disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"repeat"}))}())&&n.push(t),n.length>0)return r.React.createElement(o.hE,{key:"undo-group"},n)}()),d.push(function(){if(l("restart",!0)){var t=h();return r.React.createElement(s,{key:"restart",title:"Restart service",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.editor_actions).restart)||void 0===n?void 0:n.call(t)}},r.React.createElement(i.Icon,{name:"sync"})," ",t?r.React.createElement(i.VisibleMDLG,null,"Restart"):void 0)}}()),d.push(function(e){if(l("close_and_halt"))return r.React.createElement(s,{key:"close_and_halt",disabled:S,bsSize:f(),onClick:function(){return z(!0)},title:"Close and halt server"},r.React.createElement(i.Icon,{name:"PoweroffOutlined"})," ",r.React.createElement(i.VisibleMDLG,null,e?"Halt":void 0))}(u)),d.push(function(){var t=[];return l("zoom_page_height")&&null!=e.actions.zoom_page_height&&t.push(r.React.createElement(c,{key:"text-height",title:"Zoom to page height",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).zoom_page_height)||void 0===n?void 0:n.call(t,e.id)}},r.React.createElement(i.Icon,{name:"ColumnHeightOutlined"}))),l("zoom_page_width")&&null!=e.actions.zoom_page_width&&t.push(r.React.createElement(c,{key:"text-width",title:"Zoom to page width",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.actions).zoom_page_width)||void 0===n?void 0:n.call(t,e.id)}},r.React.createElement(i.Icon,{name:"ColumnWidthOutlined"}))),2==t.length?r.React.createElement(o.hE,{key:"height-width"},t):1==t.length?r.React.createElement("span",{key:"height-width"},t):void 0}()),d.push(function(){if(l("download")&&null!=e.editor_actions.download&&!C.disableActions){var t=h();return r.React.createElement(c,{key:"download",title:"Download this file",bsSize:f(),onClick:function(){var t,n;return null===(n=(t=e.editor_actions).download)||void 0===n?void 0:n.call(t,e.id)}},r.React.createElement(i.Icon,{name:"cloud-download"})," ",t?r.React.createElement(i.VisibleMDLG,null,"Download"):void 0)}}()),d.push(function(t){var n,o,a;if(l("pause"))return e.is_paused?(n="play",o="Play",a="success"):(n="pause",o="Pause"),r.React.createElement(s,{key:"pause",bsSize:f(),bsStyle:a,onClick:function(){e.is_paused?e.actions.unpause(e.id):e.actions.pause(e.id)},title:o},r.React.createElement(i.Icon,{name:n}),r.React.createElement(i.VisibleMDLG,null,t?" "+o:void 0))}(u)),d.push(function(){var t,n=[];if(T||(t=function(){if(l("cut"))return r.React.createElement(c,{key:"cut",title:"Cut selected",onClick:function(){return e.editor_actions.cut(e.id)},disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"scissors"}))}())&&n.push(t),l("copy")&&n.push(function(){if(l("copy"))return r.React.createElement(c,{key:"copy",title:"Copy selected",onClick:function(){return e.editor_actions.copy(e.id)},bsSize:f()},r.React.createElement(i.Icon,{name:"copy"}))}()),T||(t=function(){if(l("paste"))return r.React.createElement(c,{key:"paste",title:"Paste buffer",onClick:(0,q.debounce)((function(){return e.editor_actions.paste(e.id,!0)}),200,{leading:!0,trailing:!1}),disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"paste"}))}())&&n.push(t),n.length>0)return r.React.createElement(o.hE,{key:"copy"},n)}()),d.push(function(){var t,n=[];if((t=function(){if(l("find"))return r.React.createElement(c,{key:"find",title:"Find text",onClick:function(){return e.editor_actions.find(e.id)},bsSize:f()},r.React.createElement(i.Icon,{name:"search"}))}())&&n.push(t),T||(t=function(){if(l("replace"))return r.React.createElement(c,{key:"replace",title:"Replace text",onClick:function(){return e.editor_actions.replace(e.id)},disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"replace"}))}())&&n.push(t),(t=function(){if(l("goto_line"))return r.React.createElement(c,{key:"goto-line",title:"Jump to line",onClick:function(){return e.editor_actions.goto_line(e.id)},bsSize:f()},r.React.createElement(i.Icon,{name:"bolt"}))}())&&n.push(t),n.length>0)return r.React.createElement(o.hE,{key:"find-group"},n)}()),T||d.push(function(){if(l("auto_indent"))return r.React.createElement(s,{key:"auto-indent",title:"Automatically format selected code",onClick:function(){return e.editor_actions.auto_indent(e.id)},disabled:O,bsSize:f()},r.React.createElement(i.Icon,{name:"indent"}))}()),d.push(function(){if(l("halt_jupyter"))return r.React.createElement(s,{key:"halt_jupyter",bsSize:f(),onClick:function