UNPKG

@cocalc/static

Version:

CoCalc's static frontend Webpack-based build system and framework

1 lines 54.2 kB
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[5],{80650:(e,t,n)=>{n.d(t,{q:()=>m});var r=n(32295),l=n(42188),a=n(85460),o=n(20812),c=n(33638),i=n(24620);function u(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 s=n(63510),d={color:"white",background:"red",padding:"5px",position:"absolute",zIndex:5,width:"50%",right:"0",borderRadius:"3px",boxShadow:"0px 0px 3px 2px rgba(87, 87, 87, 0.2)"},m=r.React.memo((function(e){var t,n,i=function(){var e;if(null!=I.current){var t=I.current.getValue();if(t===M.current)return m(),t;try{e=JSON.parse(t)}catch(e){return void O("".concat(e))}return M.current=t,y(e),m(),t}},m=function(){O("")},f=function(){null!=I.current&&i()&&k&&k()},p=function(){null!=I.current&&R&&R()},h=function(e){var t=e.toJS();return t.mode={name:"application/json"},t.indentUnit=t.tabSize=1,t.indentWithTabs=!1,t.foldGutter=!0,t.extraKeys["Ctrl-Q"]=function(e){return e.foldCodeSelectionAware()},t.extraKeys.Tab=function(e){return e.tab_as_space()},t.gutters=["CodeMirror-linenumbers","CodeMirror-foldgutter"],t},v=function(e){return a.Map.isMap(e)&&(e=e.toJS()),s(e,{space:1})},g=e.value,b=e.font_size,y=e.on_change,E=e.cm_options,k=e.undo,R=e.redo,_=e.saveDebounceMs,w=void 0===_?1e3:_,x=(0,r.usePrevious)(E),S=(0,r.usePrevious)(g),C=(t=(0,r.useState)(""),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,l,a=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){c=!0,l=e}finally{try{o||null==n.return||n.return()}finally{if(c)throw l}}return a}}(t,n)||function(e,t){if(e){if("string"==typeof e)return u(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)?u(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.")}()),j=C[0],O=C[1],I=(0,r.useRef)(null),M=(0,r.useRef)(null),A=(0,r.useRef)(null);return r.React.useEffect((function(){return function(){if(null!=A.current){var e=$(A.current).find("textarea")[0];I.current=c.fromTextArea(e,h(E)),$(I.current.getWrapperElement()).css({height:"100%"}),M.current=v(g),I.current.setValue(M.current);var t=(0,o.debounce)(i,w);I.current.on("change",(function(e,n){"setValue"!==n.origin&&t()})),I.current.undo=f,I.current.redo=p}}(),function(){null!=I.current&&(i(),null!=I.current&&($(I.current.getWrapperElement()).remove(),I.current=null))}}),[]),r.React.useEffect((function(){E.equals(x)||function(e,t){if(null!=I.current){var n=h(e);e.forEach((function(e,r){e!==(null==t?void 0:t.get(r))&&"inputStyle"!=r&&I.current.setOption(r,n[r])}))}}(E,x)}),[E]),r.React.useEffect((function(){var e;null===(e=I.current)||void 0===e||e.refresh()}),[b]),r.React.useEffect((function(){g.equals(S)||function(e){var t;if(null!=I.current){var n=I.current.getValue();if(e=v(e),n!==M.current){var r=(0,l.make_patch)(M.current,n);t=(0,l.apply_patch)(r,e)[0]}else M.current=t=e,m();I.current.setValueNoJump(t)}}(g)}),[g]),r.React.createElement("div",{ref:A,style:{width:"100%",overflow:"auto",height:"100%",position:"relative"}},function(){if(j)return r.React.createElement("div",{style:d},"ERROR: ",j)}(),r.React.createElement("textarea",null))}),(function(e,t){return(0,i.all_fields_equal)(e,t,["font_size","cm_options"])&&e.value.equals(t.value)}))},60005:(e,t,n)=>{n.d(t,{m:()=>we,J:()=>xe});var r=n(32295),l=n(19990),a=n(95604),o=(n(68785),n(84123)),c=n(33667),i=n(9067),u=n(63510),s=n.n(u),d=n(13998),m=n(51480),f=n(24620),p=n(64629),h=n(39268);function v(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 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 b(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,l,a=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){c=!0,l=e}finally{try{o||null==n.return||n.return()}finally{if(c)throw l}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(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)?v(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 y={meta:"⌘",ctrl:"⌃",alt:"⌥",shift:"⇧",return:"⏎",space:"⌴",tab:"↹",down:"⬇",up:"⬆",backspace:"⌫",delete:"␡"};function E(e){var t="";if(e.shift&&(t+=y.shift),e.ctrl&&(t+=y.ctrl),e.alt&&(t+=y.alt),e.meta&&(t+=y.meta),e.key)t+=e.key;else{var n=e.which;if(null!=n)switch(n){case 8:t+=y.backspace;break;case 13:t+=y.return;break;case 32:t+=y.space;break;case 27:t+="Esc";break;case 40:t+=y.down;break;case 38:t+=y.up;break;case 46:t+=y.delete;break;default:t+=(0,h.Cs)(n)}}return e.twice&&(t=t+","+t),t}var k=function(e){var t=e.shortcut;return r.React.createElement("span",{style:{fontFamily:"monospace"}},E(t))},R={border:"1px solid transparent",paddingRight:"10px"},_=r.React.memo((function(e){var t,n,a=function(e,t){return r.React.createElement("span",{key:e,style:{border:"1px solid #999",margin:"2px",padding:"1px"}},r.React.createElement(k,{key:e,shortcut:t}),void 0)},o=function(){x(void 0),y(""),j(void 0)},c=e.actions,i=e.name,u=e.shortcuts,d=e.taken,m=b((0,r.useState)(!1),2),f=m[0],p=m[1],v=b((0,r.useState)(""),2),g=v[0],y=v[1],_=b((0,r.useState)(void 0),2),w=_[0],x=_[1],S=b((0,r.useState)(void 0),2),C=S[0],j=S[1],O=f&&!1;return r.React.createElement("div",{style:R,onClick:function(e){e.stopPropagation()},onMouseEnter:function(){return p(!0)},onMouseLeave:function(){return p(!1)}},function(){var e=[];for(var t in u){var n=u[t];e.push(a(t,n))}return(0,l.r_join)(e,", ")}(),O?(w?(t="red",n="white"):(t="white",n="black"),r.React.createElement("input",{style:{width:"3em",backgroundColor:t,color:n},autoFocus:!0,ref:"input",type:"text",value:g,onKeyDown:function(e){if(e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||27!==e.which){var t=(0,h.UO)(e,"escape"),n=d[s()((0,h.UO)(e,"edit"))];null==n&&(n=d[s()(t)]),y(E(t)),j(t),x(n)}else o()}})):void 0,O?r.React.createElement(l.Icon,{onClick:o,name:"times",style:{color:"#888",paddingLeft:"1ex"}}):void 0,g&&!w&&O?r.React.createElement(l.Icon,{onClick:function(){c.add_keyboard_shortcut(i,C),o()},name:"check",style:{color:"#888",paddingLeft:"1ex"}}):void 0,w&&O?r.React.createElement("span",{style:{backgroundColor:"#fff"}},r.React.createElement("br",null),"Shortcut already used by '",w,"'"):void 0)})),w={cursor:"pointer",borderTop:"1px solid #ccc",padding:"5px 0 5px 10px"},x=r.React.memo((function(e){var t=e.actions,n=e.name,a=e.desc,o=e.icon,i=e.shortcuts,u=e.taken,s=(0,d.Z)(),m=b((0,r.useState)(!1),2),f=m[0],p=m[1],h=function(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}({},w,f?{backgroundColor:"#ddd"}:null);return r.React.createElement("div",{style:h,onClick:function(){!function(){var e;null===(e=s.current)||void 0===e||e.command(n),t.close_keyboard_shortcuts()}()},onMouseEnter:function(){return p(!0)},onMouseLeave:function(){return p(!1)}},r.React.createElement(c.rj,{style:{width:"100%"}},r.React.createElement(c.X2,null,r.React.createElement(c.JX,{md:1,sm:1},r.React.createElement("span",null,o?r.React.createElement(l.Icon,{name:o}):void 0)),r.React.createElement(c.JX,{md:7,sm:7},r.React.createElement("span",null,a)),r.React.createElement(c.JX,{md:4,sm:4},r.React.createElement(_,{actions:t,shortcuts:i,name:n,taken:u})))))})),S={border:"1px solid #ccc",borderRadius:"3px",overflowY:"scroll",maxHeight:"50vh"},C=r.React.memo((function(e){var t=e.actions,n=e.editor_actions,l=e.taken,a=e.search,o=(0,d.Z)();return r.React.createElement("div",{style:S},function(){var e=[],c=(0,p.C)(t,o,n);for(var i in c){var u=c[i];null!=u&&e.push({name:i,val:u})}e.sort((0,f.field_cmp)("name"));var s,d=[],m=null!=a?a.toLowerCase()||"":void 0,h=!0,v=!1,g=void 0;try{for(var b,y=e[Symbol.iterator]();!(h=(b=y.next()).done);h=!0){var E=b.value;if(null!=E.val.f){var k=null!=E.val.m?E.val.m:(s=E.name,(0,f.split)(s).map((function(e){return(0,f.capitalize)(e)})).join(" "));if(null!=k&&-1!==k.toLowerCase().indexOf(m)){var R=E.val.i,_=null!=E.val.k?E.val.k:[];d.push(r.React.createElement(x,{key:E.name,name:E.name,actions:t,desc:k,icon:R,shortcuts:_,taken:l[E.name]}))}}}}catch(e){v=!0,g=e}finally{try{h||null==y.return||y.return()}finally{if(v)throw g}}return d}())}),(function(e,t){return e.search===t.search})),j=r.React.memo((function(e){var t=function(){var e;n.close_keyboard_shortcuts(),null===(e=u.current)||void 0===e||e.focus()},n=e.actions,a=e.editor_actions,o=e.keyboard_shortcuts,u=(0,d.Z)(),h=b((0,r.useState)(""),2),v=h[0],g=h[1],E=(0,p.C)(n,u,a),k={};for(var R in E){var _=E[R];if(null!=_&&null!=_.k){var w=!0,x=!1,S=void 0;try{for(var j,O=_.k[Symbol.iterator]();!(w=(j=O.next()).done);w=!0){var I=j.value;null!=I.key&&(I=(0,f.copy_without)(I,["key"])),k[s()(I)]=_.m||R}}catch(e){x=!0,S=e}finally{try{w||null==O.return||O.return()}finally{if(x)throw S}}}}return null==o?r.React.createElement("span",null):r.React.createElement(i.Z,{visible:!0,onCancel:t,onOk:t,width:900,title:r.React.createElement(r.React.Fragment,null,r.React.createElement(l.Icon,{name:"keyboard"})," Jupyter commands and keyboard shortcuts"),footer:r.React.createElement(r.React.Fragment,null,r.React.createElement("span",{style:{float:"left",margin:"5px 0 0 25px"}},"NOTE: Shortcut customization is"," ",r.React.createElement(l.A,{href:"https://github.com/sagemathinc/cocalc/issues/3242"},"not implemented"),"; however, it is easy for us to"," ",r.React.createElement(m.H,{text:"add new shortcuts and commands."})," "),r.React.createElement(c.zx,{onClick:t},"Close"))},r.React.createElement(c.rj,{style:{width:"100%"}},r.React.createElement(c.X2,null,r.React.createElement(c.JX,{md:12},r.React.createElement(l.SearchInput,{autoFocus:!0,value:v,on_change:function(e){g(e)},placeholder:"Search commands..."}))),r.React.createElement(c.X2,null,r.React.createElement(c.JX,{md:9},r.React.createElement(c.rj,{style:{width:"100%",fontWeight:"bold",color:"#666",marginTop:"15px"}},r.React.createElement(c.X2,null,r.React.createElement(c.JX,{md:1,sm:1}),r.React.createElement(c.JX,{md:7,sm:7},"Command (click to run)"),r.React.createElement(c.JX,{md:4,sm:4},"Keyboard shortcut"))),r.React.createElement(C,{actions:n,editor_actions:a,taken:k,search:v})),r.React.createElement(c.JX,{md:3},r.React.createElement("ul",{style:{marginTop:"30px"}},Object.entries(y).map((function(e){var t=b(e,2),n=t[0],l=t[1];return r.React.createElement("li",{key:n},r.React.createElement("span",{style:{width:"20px",display:"inline-block"}},l)," ",n)})))))))})),O=n(97891),I={python:{Python:"https://docs.python.org/3/",IPython:"https://ipython.org/documentation.html",NumPy:"https://docs.scipy.org/doc/numpy/reference/",SciPy:"https://docs.scipy.org/doc/scipy/reference/",matplotlib:"https://matplotlib.org/contents.html",SymPy:"https://docs.sympy.org/latest/",pandas:"http://pandas.pydata.org/pandas-docs/stable/",SageMath:"http://doc.sagemath.org/","scikit-learn":"https://scikit-learn.org/stable/",statsmodels:"https://www.statsmodels.org/stable/",tensorflow:"https://www.tensorflow.org/learn"},r:{R:"https://www.r-project.org/","R Jupyter Kernel":"https://irkernel.github.io/faq/",Bioconductor:"https://www.bioconductor.org/",tidyverse:"https://www.tidyverse.org/",ggplot2:"https://ggplot2.tidyverse.org/",dplyr:"https://dplyr.tidyverse.org","data.table":"https://github.com/Rdatatable/data.table/wiki"},bash:{Bash:"https://tiswww.case.edu/php/chet/bash/bashtop.html","Linux Tutorial":"https://ryanstutorials.net/linuxtutorial/"},julia:{"Julia Documentation":"https://docs.julialang.org/",Plots:"https://docs.juliaplots.org/latest/",DataFrames:"https://juliadata.github.io/DataFrames.jl/stable/",JuMP:"http://www.juliaopt.org/JuMP.jl/stable/"},octave:{Octave:"https://www.gnu.org/software/octave/","Octave Documentation":"https://www.gnu.org/software/octave/doc/interpreter/","Octave Tutorial":"https://en.wikibooks.org/wiki/Octave_Programming_Tutorial","Octave FAQ":"http://wiki.octave.org/FAQ"},postgresql:{PostgreSQL:"https://www.postgresql.org/docs/","PostgreSQL Jupyter Kernel":"https://github.com/bgschiller/postgres_kernel"},scala:{"Scala Documentation":"https://docs.scala-lang.org/"},singular:{"Singular Manual":"https://www.singular.uni-kl.de/index.php/singular-manual.html"}},M={color:"#666",border:0,backgroundColor:"rgb(247,247,247)"},A={color:"#2196F3",fontWeight:"bold"},T=r.React.memo((function(e){var t,n,a,i=function(){var e;$(":focus").blur(),null===(e=g.current)||void 0===e||e.focus(!0)},u=function(e,t){var n,a;if(""===t)return{item:r.React.createElement(l.MenuDivider,{key:e}),command_name:""};if(null!=t&&null!=t.props)return{item:t,command_name:""};var o,c,i=void 0;"object"==typeof t?(t=(o=t).name,a=o.display,null!=(i=o.style)&&(i=(0,f.copy)(i))):a=void 0,null==i&&(i={}),"string"!=typeof t&&(console.warn("bug -- name must be a string at this point; working around this. name=",t),t="".concat(t)),"<"===t[0]?(c=!0,t=t.slice(1)):c=!1,">"===t[0]&&(i.marginLeft="4ex",t=t.slice(1));var u,s=null===(n=g.current)||void 0===n?void 0:n.commands[t];if(null==s)return{item:r.React.createElement(l.MenuItem,{disabled:c,key:e},r.React.createElement("span",{style:i},null!=a?a:t)),command_name:""};if(null!=s.k){var d=[],m=0,p=!0,h=!1,v=void 0;try{for(var b,y=s.k[Symbol.iterator]();!(p=(b=y.next()).done);p=!0){var E=b.value;d.push(r.React.createElement(k,{key:m,shortcut:E})),m+=1}}catch(e){h=!0,v=e}finally{try{p||null==y.return||y.return()}finally{if(h)throw v}}u=r.React.createElement("span",{className:"pull-right",style:{marginLeft:"1em"}},(0,l.r_join)(d,", "))}else u=r.React.createElement("span",null);return a||(a=s.menu),a||(a=s.m),a||(a=t),{item:r.React.createElement(l.MenuItem,{key:e,disabled:c},r.React.createElement("span",{style:i},u," ",a," ")),command_name:t}},s=function(e){var t=e.heading,n=e.names,a=e.disabled;null==a&&(a=!1);var o=function(e){var t=[],n={};for(var r in e){var l=u(r,e[r]),a=l.item,o=l.command_name;t.push(a),n[r]=o}return{items:t,command_names:n}}(n),c=o.items,s=o.command_names;return r.React.createElement(l.DropdownMenu,{title:t,key:t,id:t,disabled:e.disabled,onClick:function(e){var t=s[e];null!=t&&function(e){var t,n;null===(t=g.current)||void 0===t||t.command(e),$(":focus").blur();var r,l=null===(n=g.current)||void 0===n?void 0:n.commands[e];l&&l.m&&(0,f.endswith)(l.m,"...")?null===(r=g.current)||void 0===r||r.blur():i()}(t)}},c)},m=e.actions,p=e.cur_id,h=e.cells,v=e.name,g=(0,d.Z)(),b=(0,r.useRedux)([v,"kernels"]),y=(0,r.useRedux)([v,"kernel_state"]),E=(0,r.useRedux)([v,"has_unsaved_changes"]),R=(0,r.useRedux)([v,"kernel_info"]),_=(0,r.useRedux)([v,"backend_kernel_info"]),w=(0,r.useRedux)([v,"toolbar"]),x=(0,r.useRedux)([v,"cell_toolbar"]),S=(0,r.useRedux)([v,"read_only"]),C=(0,r.useTypedRedux)("page","fullscreen");return r.React.createElement("div",{style:{backgroundColor:"rgb(247,247,247)",border:"1px solid #e7e7e7"}},r.React.createElement(c.hE,null,function(){if(!m.studentProjectFunctionality().disableActions){var e,t=void 0;if(null!=_){var n=_.getIn(["language_info","file_extension"]);if(null!=n){var r=(0,f.capitalize)(_.getIn(["language_info","name"],""));t={name:">nbconvert script",display:"".concat(r," (").concat(n,")...")}}}void 0===t&&(t=">nbconvert script"),e=e?{name:"<trust notebook",display:"Trusted notebook"}:{name:"trust notebook",display:"Trust notebook..."};var l="save notebook";E&&!S||(l="<".concat(l));var a="rename notebook";(E||S)&&(a="<".concat(a));var o="close and halt";S&&(o="<".concat(o));var c=["new notebook","open file",o,"","duplicate notebook",a,l,"table of contents","time travel","","print preview","slideshow","nbconvert slides","<Save and Download as...",">nbconvert ipynb",">nbconvert cocalc html",">nbconvert cocalc pdf",">nbconvert latex pdf",t,">nbconvert markdown",">nbconvert rst",">nbconvert tex",">nbconvert sagews",">nbconvert asciidoc",">nbconvert classic html",">nbconvert classic pdf",">nbconvert lab html",">nbconvert lab pdf","",e];return"kiosk"!==C&&(c.push(""),c.push("switch to classical notebook")),s({heading:"File",names:c})}}(),(a=null!=h?h.getIn([p,"cell_type"]):void 0,s({heading:"Edit",disabled:S,names:["global undo","global redo","","cut cell","copy cell","paste cell above","paste cell below","paste cell and replace","delete cell","delete all blank code cells","","split cell at cursor","merge cell with previous cell","merge cell with next cell","merge cells","","move cell up","move cell down","","write protect","delete protect","","toggle hide input","toggle hide output","","find and replace","","".concat("markdown"!==a?"<":"","insert image")]})),function(){for(var e={name:"toggle toolbar",display:w?"Hide Toolbar":"Show Toolbar"},t=[],n=0,r=["none","metadata","slideshow","attachments","tags","create_assignment"];n<r.length;n++){var l=r[n],a=">cell toolbar ".concat(l);(null!=x?x:"none")===l?t.push({name:a,style:A}):t.push(a)}return s({heading:"View",disabled:S,names:["toggle header",e,"toggle all line numbers","","<Cell Toolbar..."].concat(t).concat(["","zoom in","zoom out"])})}(),s({heading:"Insert",names:["insert cell above","insert cell below"],disabled:S}),s({heading:"Cell",disabled:S,names:["run cell","run cell and select next","run cell and insert below","run all cells","run all cells above","run all cells below","","<Cell type...",">change cell to code",">change cell to markdown",">change cell to raw","","<Selected output...",">toggle cell output collapsed",">toggle cell output scrolled",">clear cell output","","<All output...",">toggle all cells output collapsed",">toggle all cells output scrolled",">clear all cells output","","<Format code...",">format cells",">format all cells"]}),(t=function(){if(null!=b)return b.toJS().map((function(e){return function(e){var t={marginLeft:"4ex"};return e.name===e&&(t.color="#2196F3",t.fontWeight="bold"),r.React.createElement(l.MenuItem,{key:e.name,onClick:function(){var t;t=e.name,m.set_kernel(t),i(),m.set_default_kernel(t),(0,o.fW)("cocal_jupyter","change kernel",t)}},r.React.createElement("span",{style:t}," ",e.display_name," "))}(e)}))}(),n=["".concat("busy"!==y?"<":"","interrupt kernel"),"confirm restart kernel","confirm halt kernel","<Restart and...",">confirm restart kernel and clear output",">confirm restart kernel and run all cells",">confirm restart kernel and run all cells without halting on error","","<Change kernel..."].concat(t||[]).concat(["","refresh kernels"]).concat(["","custom kernel"]),s({heading:"Kernel",names:n,disabled:S})),r.React.createElement(l.DropdownMenu,{key:"help",id:"menu-help",title:"Help",style:M},r.React.createElement(l.MenuItem,{key:"help-about",onClick:function(){return m.show_about()}},r.React.createElement(l.Icon,{name:"question-circle"})," About..."),r.React.createElement(l.MenuDivider,null),r.React.createElement(l.MenuItem,{key:"help-keyboard",onClick:function(e){return function(){var t,n;null===(t=g.current)||void 0===t||t.command(e),$(":focus").blur();var r,l=null===(n=g.current)||void 0===n?void 0:n.commands[e];l&&l.m&&(0,f.endswith)(l.m,"...")?null===(r=g.current)||void 0===r||r.blur():i()}}("edit keyboard shortcuts")},r.React.createElement(l.Icon,{name:"keyboard"})," Keyboard shortcuts..."),r.React.createElement(l.MenuDivider,null),P("Notebook help","http://nbviewer.jupyter.org/github/ipython/ipython/blob/3.x/examples/Notebook/Index.ipynb"),P("Jupyter in CoCalc","https://doc.cocalc.com/jupyter.html"),P("nbgrader in CoCalc","https://doc.cocalc.com/teaching-nbgrader.html"),P("Custom Jupyter kernels","https://doc.cocalc.com/howto/custom-jupyter-kernel.html"),P("Markdown","https://help.github.com/articles/basic-writing-and-formatting-syntax"),r.React.createElement(l.MenuDivider,null),function(){if(null==R)return[];var e=[],t=function(e){if("string"==typeof e)return(e=e.toLowerCase()).startsWith("scala")&&(e="scala"),I[e]}(R.get("language"));if(null==t)return e;for(var n in t){var r=t[n];e.push(P(n,r))}return e}())))}),(function(e,t){return(0,f.all_fields_equal)(e,t,["has_unsaved_changes","read_only","kernels","kernel_state","backend_kernel_info","cur_id","cells","toolbar","cell_toolbar"])}));function P(e,t){return r.React.createElement(l.MenuItem,{key:e,onClick:function(){return(0,O.open_new_tab)(t)}},r.React.createElement(l.Icon,{name:"external-link"})," ",e)}var D=n(53924),J=n(48668),F=n(91435),L=r.React.memo((function(e){var t,n=function(){var e;null===(e=E.current)||void 0===e||e.focus(!0)},a=function(e,t){return function(r){var l,a;$(":focus").blur(),null===(l=E.current)||void 0===l||l.command(e),t?n():null===(a=E.current)||void 0===a||a.blur()}},o=function(e,t){var n,o,i=void 0,u=!1,s="",d=void 0;"object"==typeof t&&(t=(o=t).name,u=o.disabled,d=o.style,s=o.label,i=o.className),null==d&&(d=void 0),null==u&&(u=!1),null==s&&(s=""),null==i&&(i=void 0),k&&(u=!0);var m=null===(n=E.current)||void 0===n?void 0:n.commands[t];if(null==m)throw Error("command ".concat(t," is not defined"));var p=!(0,f.endswith)(m.m?m.m:"","...");return r.React.createElement(c.zx,{className:i,onClick:a(t,p),disabled:u,style:d,title:m.m},m.i&&r.React.createElement(l.Icon,{name:m.i})," ",s)},i=function(e){var t=[];for(var n in e)t.push(o(0,e[n]));return t},u=function(e,t){return r.React.createElement(c.hE,{className:t?"hidden-xs":""},i(e))},s=function(e){switch(e){case"markdown":return"Text";case"multi":return"-";default:return(0,f.capitalize)(e)}},m=e.cur_id,p=e.sel_ids,h=e.cells,v=e.cell_toolbar,g=e.name,b=e.usage,y=e.project_id,E=(0,d.Z)(),k=(0,r.useRedux)([g,"read_only"]),R=(0,D.useStudentProjectFunctionality)(y);return r.React.createElement(c.l0,{inline:!0,style:{whiteSpace:"nowrap",margin:"2px 0"}},i(["insert cell below"]),r.React.createElement("span",{style:{marginLeft:"5px"}}),r.React.createElement(l.VisibleLG,null,u(["move cell up","move cell down"],!0)),r.React.createElement("span",{style:{marginLeft:"5px"}}),u([{name:"run cell and select next",label:"Run"},{name:"interrupt kernel",style:b.cpu_runtime>1?{backgroundColor:F.D[b.time_alert],color:"white"}:void 0,className:"cocalc-jupyter-btn-interrupt",label:"Stop"},{name:"tab key",label:"Tab"},"confirm restart kernel","confirm restart kernel and run all cells"]),r.React.createElement("span",{style:{marginLeft:"5px"}}),(t=s(p.size>1?"multi":h.getIn([m,"cell_type"],"code")),r.React.createElement(c.hE,null,r.React.createElement(l.DropdownMenu,{style:{height:"34px",width:"6em"},"cocalc-test":"jupyter-cell-type-dropdown",button:!0,key:"cell-type",title:t,disabled:k,onClick:function(e){var t;null===(t=E.current)||void 0===t||t.set_selected_cell_type(e),n()}},r.React.createElement(l.MenuItem,{"cocalc-test":"code",key:"code"},s("code")),r.React.createElement(l.MenuItem,{"cocalc-test":"markdown",key:"markdown"},s("markdown")),r.React.createElement(l.MenuItem,{"cocalc-test":"raw",key:"raw"},s("raw")),r.React.createElement(l.MenuItem,{"cocalc-test":"multi",key:"multi",disabled:!0},s("multi"))))),function(){if(!R.disableActions)return r.React.createElement("span",{style:{marginLeft:"5px"}},o(0,"show keyboard shortcuts")," ")}(),r.React.createElement(c.hE,{className:"hidden-xs"},r.React.createElement(c.zx,{onClick:function(){var e;return null===(e=E.current)||void 0===e?void 0:e.format()},title:"Format the syntax of selected cells. Only works, if a formatter is available."},r.React.createElement(l.Icon,{name:J.U})," ",r.React.createElement(l.VisibleMDLG,null,"Format"))),r.React.createElement(c.hE,{style:{marginLeft:"5px"}},o(0,{name:"nbgrader validate",disabled:!1,label:"Validate"}),function(){if("create_assignment"==v)return o(0,{name:"nbgrader assign",disabled:!1,label:"Generate student version..."})}()))})),z=n(38403),N=n(80719),Z=n(13435),X=r.React.memo((function(e){var t=e.name;return"edit"!==(0,r.useRedux)([t,"mode"])?r.React.createElement("span",null):r.React.createElement("div",{className:"pull-right",style:{color:Z.COLORS.GRAY,margin:"5px",paddingRight:"5px"}},r.React.createElement(l.Icon,{name:"pencil"}))})),q=n(61375),H=n.n(q),K=n(63505);function U(e){var t,n,r=e.actions,a=e.about,o=e.backend_kernel_info,c=function(){r.setState({about:!1}),r.focus(!0)};return K.createElement(i.Z,{width:900,visible:a,onCancel:c,onOk:c,title:K.createElement(K.Fragment,null,K.createElement(l.Icon,{name:"question-circle"})," About CoCalc Jupyter notebook")},K.createElement("p",null,"You are using the CoCalc Jupyter notebook."),K.createElement("div",{style:{color:"#333",margin:"0px 45px"}},"CoCalc Jupyter notebook is a complete open source rewrite by SageMath, Inc. of the classical Jupyter notebook client from the"," ",K.createElement(l.A,{href:"http://jupyter.org/"},"Jupyter project"),". CoCalc Jupyter notebook maintains full compatibility with the file format and general look and feel of the classical notebook. It improves on the classical notebook as follows:",K.createElement("ul",{style:{marginTop:"10px",padding:"10px",paddingLeft:"30px",backgroundColor:"#fafafa",fontSize:"11pt"}},K.createElement("li",null,K.createElement("b",null,"Realtime sync:")," Multiple people can simultaneously edit notebooks: multiple cursors, document-wide user-specific undo and redo, realtime synchronized ipywidgets"),K.createElement("li",null,K.createElement("b",null,"Document split:")," edit and see multiple parts of a large notebook at once"),K.createElement("li",null,K.createElement("b",null,"TimeTravel:")," see detailed history of exactly how a notebook was created"),K.createElement("li",null,K.createElement("b",null,"Text/Markdown:")," powerful graphical editor for markdown cells, so you can write nicely formatted text to explain your code without having to write markdown directly."),K.createElement("li",null,K.createElement("b",null,"Snippets:")," code samples for many kernels"),K.createElement("li",null,K.createElement("b",null,"Whiteboard:"),' create a whiteboard (documented ending in ".board") and use Jupyter cells as part of your whiteboard'),K.createElement("li",null,K.createElement("b",null,"Zoom:")," easily change font size"),K.createElement("li",null,K.createElement("b",null,"Code folding:")," see structure of input"),K.createElement("li",null,K.createElement("b",null,"Code formatting:")," click the Format button to automatically format your code and markdown."),K.createElement("li",null,K.createElement("b",null,"Modern look:")," buttons, menus and cell execution hints that better reflect state"),K.createElement("li",null,K.createElement("b",null,"Large output:")," server-side throttling, windowing, and buffering"),K.createElement("li",null,K.createElement("b",null,"Background capture of output:")," works if no user has the notebook open (",K.createElement(l.A,{href:"https://github.com/jupyterlab/jupyterlab/issues/6545#issuecomment-501259211"},"discussion"),")"),K.createElement("li",null,K.createElement("b",null,"Mobile support:")," phones and tablets"),K.createElement("li",null,K.createElement("b",null,"Cell creation:")," click blue line between cells to create new cells"),K.createElement("li",null,K.createElement("b",null,"Share:")," your work is visible publicly via our fast lightweight notebook viewer"),K.createElement("li",null,K.createElement("b",null,"LaTeX:")," export notebook to LaTeX, then edit the generated LaTeX directly in CoCalc."),K.createElement("li",null,K.createElement("b",null,"Keybindings and color schemes:")," VIM, Emacs, and Sublime keybindings, and many color schemes (in account settings)")),"Some functionality of classical extensions are not yet supported (if you need something,"," ",K.createElement(l.A,{href:"https://github.com/sagemathinc/cocalc/issues?q=is%3Aissue+is%3Aopen+label%3AA-jupyter"},"check here")," ","and create a ",K.createElement(m.H,null),"), and some of the above is also available in classical Jupyter via extensions."),K.createElement("h4",{style:{marginTop:"15px"}},"Questions"),K.createElement("span",null,"Read ",K.createElement(l.A,{href:"https://doc.cocalc.com/jupyter.html"},"documentation"),", create a ",K.createElement(m.H,null),", or check the latest"," ",K.createElement(l.A,{href:Z.JUPYTER_CLASSIC_MODERN},"status of Jupyter in CoCalc.")),K.createElement("h4",{style:{marginTop:"15px"}},"Server Information"),(n=null!=o?o.get("nodejs_version"):void 0)?K.createElement("pre",null,"Node.js Version ",n):K.createElement("div",null,"Waiting for server to be available..."),K.createElement("h4",{style:{marginTop:"15px"}},"Current Kernel Information"),null==(t=null!=o?o.get("banner"):void 0)?K.createElement("div",null,"Waiting for kernel to be available..."):K.createElement("pre",null,K.createElement(H(),null,t)))}var V=n(63505),W=n(85460),B=n(24809),G={python:{ext:"py",display:"Python",internal:!0},"cocalc-html":{ext:"html",display:"HTML",no_run_button:!0},"classic-html":{ext:"html",display:"HTML (Classic template)"},"lab-html":{ext:"html",display:"HTML (JupyterLab template)"},"classic-pdf":{ext:"pdf",display:"PDF (Classic template)"},"lab-pdf":{ext:"pdf",display:"PDF (JupyterLab template)"},markdown:{ext:"md",display:"Markdown",internal:!0},rst:{ext:"rst",display:"reST",internal:!0},asciidoc:{ext:"asciidoc",display:"AsciiDoc"},slides:{ext:"slides.html",display:"Slides"},latex:{ext:"tex",display:"LaTeX",internal:!0},sagews:{ext:"sagews",display:"Sage Worksheet",internal:!0,nolink:!0},pdf:{ext:"pdf",display:"PDF via nbconvert and LaTeX"},webpdf:{ext:"pdf",display:"PDF via nbconvert webpdf"},script:{ext:"",display:"Executable Script",internal:!0},"cocalc-pdf":{ext:"pdf",display:"PDF",no_run_button:!0}},Q=function(e){var t=function(){if(null!=a.current){var e=$(a.current);e.scrollTop(e.prop("scrollHeight"))}},n=e.actions,r=e.nbconvert,a=(0,V.useRef)(null);(0,V.useEffect)((function(){var e=setTimeout((function(){return t()}),10);return function(){clearTimeout(e)}}),[]),(0,V.useEffect)((function(){if(null!=r&&f.is_string(r.get("error"))){var e=setTimeout((function(){return t()}),10);return function(){clearTimeout(e)}}}),[null==r?void 0:r.get("error")]);var o=null==r?void 0:r.get("error");return o?f.is_string(o)?V.createElement("span",null,V.createElement("h3",null,"Error"),"Running nbconvert failed with an error ",function(){var e=null==r?void 0:r.get("time");if(null!=e)return V.createElement("b",null,V.createElement(l.TimeAgo,{date:new Date(e),minPeriod:1}))}(),"."," ",o.toLowerCase().includes("exporter")?V.createElement(V.Fragment,null,"You probably need to ",V.createElement("b",null,"restart your project")," in project settings."):V.createElement(V.Fragment,null,"Read the error log below, update your Jupyter notebook, then try again."),V.createElement("pre",{ref:a,style:{maxHeight:"40vh",margin:"5px 20px",fontSize:"10px"}},o)):(n.nbconvert_get_error(),V.createElement(l.Loading,null)):V.createElement("span",null)},Y=V.memo((function(e){var t=function(){if(null==m||m.get("error")||null==p)return{};var e,t=p.get("to"),n=G[t];if(null==n)return{};"script"===t&&null!=h?""===(e=h.getIn(["language_info","file_extension"],"").slice(1))&&(e="py"):e=n.ext;var r=f.change_filename_extension(s,e);return{targetPath:r,url:u.store.get_raw_link(r),info:n}},n=function(){u.setState({nbconvert_dialog:void 0}),u.focus(!0)},a=function(){var e,r=null==m?void 0:m.get("time");if(null!=r&&!(r<f.server_minutes_ago(5))&&(null===(e=null==m?void 0:m.get("args"))||void 0===e?void 0:e.equals(W.fromJS(o()))))return r=V.createElement("b",null,V.createElement(l.TimeAgo,{date:new Date(r),minPeriod:1})),V.createElement("div",null,function(){if(null==m?void 0:m.get("error"))return V.createElement(Q,{actions:u,nbconvert:m})}(),V.createElement("div",null,function(){var e,r=t(),a=r.targetPath,o=r.url,c=r.info;if(a&&o&&c)return V.createElement("div",null,"Successfully exported Jupyter notebook to"," ",!c.nolink&&V.createElement(V.Fragment,null,V.createElement(l.A,{href:o},a),"."),c.internal&&(e=a,V.createElement("div",null,V.createElement("br",null),V.createElement(B.Z,{onClick:function(){u.file_action("open_file",e),n()}},"Edit exported file..."))))}()))},o=function(){if(null==p)return[];var e=p.get("to");return"classic-html"==e?["--to","html","--template","classic"]:"lab-html"==e?["--to","html"]:"webpdf"==e?["--to","webpdf","--allow-chromium-download"]:["--to",e]},c=function(){var e=f.separate_file_extension(f.path_split(s).tail).name+".slides.html#/";return"https://cocalc.com/".concat(d,"/server/18080/")+e},u=e.actions,s=e.path,d=e.project_id,m=e.nbconvert,p=e.nbconvert_dialog,h=e.backend_kernel_info;(0,V.useEffect)((function(){if(null!=p){var e=null==m?void 0:m.get("state");"start"!=e&&"run"!=e&&("script"==(null==p?void 0:p.get("to"))&&u.set_backend_kernel_info(),u.nbconvert(o()))}}),[p]);var v=(0,V.useRef)(null==m?void 0:m.get("state"));(0,V.useEffect)((function(){var e=null==m?void 0:m.get("state");if("done"==e&&"done"!=v.current){var n,l=t().targetPath;l&&(null===(n=r.redux.getProjectActions(u.project_id))||void 0===n||n.download_file({path:l}))}v.current=e}),[m]);var g,b,y=null==p?void 0:p.get("to");return null==y?V.createElement("span",null):"slides"===y?V.createElement(i.Z,{visible:null!=p,onOk:n,onCancel:n,footer:null,title:V.createElement(V.Fragment,null,V.createElement(l.Icon,{name:"FundProjectionScreenOutlined"})," Jupyter Notebook Slideshow")},"Use View → Slideshow to turn your Jupyter notebook into a slideshow. One click display of slideshows is"," ",V.createElement(l.A,{href:"https://github.com/sagemathinc/cocalc/issues/2569#issuecomment-350940928"},"not yet implemented"),". However, you can start a slideshow by copying and pasting the following command in a terminal in CoCalc (+New → Terminal):",V.createElement("pre",null,"jupyter nbconvert --to slides --ServePostProcessor.port=18080 --ServePostProcessor.ip='*' --ServePostProcessor.open_in_browser=False ~/'".concat(s,"' --post serve")),"Then view your slides at",V.createElement("div",{style:{textAlign:"center"}},V.createElement(l.A,{href:c()},c()))):V.createElement(i.Z,{visible:null!=p,onOk:n,onCancel:n,title:V.createElement(V.Fragment,null,V.createElement(l.Icon,{name:"cloud-download",style:{fontSize:"20px",marginRight:"5px"}})," ","Save and Download as ",null!==(b=null===(g=G[null==p?void 0:p.get("to")])||void 0===g?void 0:g.display)&&void 0!==b?b:""),footer:null},function(){if(null!=p)switch(null==m?void 0:m.get("state")){case"start":return V.createElement("div",null,"Requesting to convert...");case"run":return V.createElement("div",null,V.createElement(l.Loading,{style:{fontSize:"20px",color:"#666"},text:"Exporting..."})," ",function(){var e=null!=m?m.get("start"):void 0;if(null!=e)return V.createElement("span",null,"(started ",V.createElement(l.TimeAgo,{date:new Date(e),minPeriod:1}),")")}());case"done":return a()}}())})),ee=n(19146),te=".smc/tmp",ne=r.React.memo((function(e){var t=function(){n.setState({insert_image:void 0})},n=e.actions,a=e.project_id,o=e.insert_image;return r.React.createElement(i.Z,{visible:null!=o,width:900,onCancel:t,onOk:t,title:r.React.createElement(r.React.Fragment,null,r.React.createElement(l.Icon,{name:"image"})," Pick image files to attach to this markdown cell")},r.React.createElement(ee.p0,{project_id:a,current_path:te,dropzone_handler:{addedfile:function(e){n.add_attachment_to_cell(o,te+"/"+e.name)}},show_header:!0}))}),(function(e,t){return t.insert_image===e.insert_image})),re=n(63505);function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(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){le(e,t,n[t])}))}return e}var oe={display:"flex",border:"1px solid #ddd",padding:"7px",borderRadius:"3px"};function ce(e){var t=e.actions,n=e.cell,r=function(){t.setState({edit_attachments:void 0}),t.focus(!0)};return re.createElement(i.Z,{visible:null!=n,onCancel:r,onOk:r,title:re.createElement(re.Fragment,null,re.createElement(l.Icon,{name:"trash"})," Delete Cell Attachments")},function(){var e=[];if(n){var r=n.get("attachments");r&&r.forEach((function(r,a){return e.length>0&&e.push(re.createElement("div",{style:{marginTop:"7px"},key:a+"space"})),e.push(re.createElement("div",{key:a,style:(o=ae({},oe),c={width:"100%"},c=null!=c?c:{},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(c)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(c)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(c,e))})),o)},re.createElement("div",{style:{flex:1}},a),re.createElement("div",null,re.createElement(B.Z,{onClick:function(){t.delete_attachment_from_cell(n.get("id"),a)},danger:!0},re.createElement(l.Icon,{name:"trash"})," Delete"))));var o,c}))}return 0===e.length?re.createElement("span",null,"There are no attachments. To attach images, use Edit → Insert Image."):e}())}var ie=n(52224),ue=n(80650),se=n(63505);function de(e){var t=e.actions,n=e.id,r=e.font_size,l=e.metadata,a=e.cm_options;return se.createElement(i.Z,{closable:!1,width:700,visible:null!=n,title:se.createElement(se.Fragment,null,se.createElement(ie.JO,{name:"edit"})," Edit Custom Cell Metadata"),footer:se.createElement(B.Z,{type:"primary",onClick:function(){t.setState({edit_cell_metadata:void 0}),t.focus_unlock()}},"Done")},se.createElement("span",{color:"#666"},"Manually edit the JSON below to manipulate the custom metadata for this cell. The JSON is saved as long as it is valid; otherwise, you'll see a big red error message."),se.createElement("div",{style:{fontSize:r,border:"1px solid #ccc",margin:"5px",borderRadius:"3px"}},se.createElement(ue.q,{value:l,font_size:r,on_change:function(e){t.set_cell_metadata({id:n,metadata:e})},cm_options:a,undo:t.undo,redo:t.redo})),se.createElement("span",{color:"#888"},'NOTE: The metadata fields "collapsed", "scrolled", "slideshow", and "tags" are not visible above, and should only be edited through their own toolbar, the UI or via \'View → Show Notebook as Raw\'.'))}function me(e,t,n){return n?new RegExp(e,t):new RegExp(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(e),t)}function fe(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 pe(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,l,a=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){c=!0,l=e}finally{try{o||null==n.return||n.return()}finally{if(c)throw l}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fe(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)?fe(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 he=r.React.memo((function(e){var t,n,a,o,u,s=function(){v.close_find_and_replace(),v.focus(!0)},d=function(){var e;null===(e=F.current)||void 0===e||e.focus()},m=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e=0===t?"No matches":"".concat(t," match").concat(1!==t?"es":""),r.React.createElement("h5",null,e)},f=function(e){var t=null!=z?z.matches:void 0;if(null!=t){var n=void 0;_||(n=null==E?void 0:E.add(y));var r=0,l=0,a=0;null!=k&&k.forEach((function(o){if(null==n||n.has(o)){if(null!=e&&a>=e)return!1;for(var c=b.get(o).get("input",""),i=l+c.length,u="",s=0;r<t.length;){if(null!=e&&a>=e){r=t.length;break}var d=t[r],m=d.start,f=d.stop;if(m>=i)break;var p=Math.max(s,m-l),h=Math.min(c.length,f-l);if(u+=c.slice(s,p),u+=D,a+=1,s=h,!(h<=i))break;r+=1}s<c.length&&(u+=c.slice(s)),c!==u&&v.set_cell_input(o,u,!1),l=i+1}})),v._sync()}},p=function(){var e,t;return null!==(t=null==z||null===(e=z.matches)||void 0===e?void 0:e.length)&&void 0!==t?t:0},h=function(){return D?"Replace":"Delete"},v=e.actions,g=e.find_and_replace,b=e.cells,y=e.cur_id,E=e.sel_ids,k=e.cell_list,R=pe((0,r.useState)(!1),2),_=R[0],w=R[1],x=pe((0,r.useState)(!1),2),S=x[0],C=x[1],j=pe((0,r.useState)(!1),2),O=j[0],I=j[1],M=pe((0,r.useState)(""),2),A=M[0],T=M[1],P=pe((0,r.useState)(""),2),D=P[0],J=P[1],F=(0,r.useRef)(null),L=(0,r.useRef)(null),z=r.React.useMemo((function(){return function(){var e,t,n=(e=[],t=void 0,_||null==E||(t=E.add(y)),null!=k&&k.forEach((function(n){if(null==t||t.has(n)){var r=b.get(n);e.push(r.get("input",""))}})),e.join("\n")),r=function(e,t){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,l="g";arguments.length>2&&void 0!==arguments[2]&&arguments[2]||(l+="i");try{e=me(e,l,n)}catch(e){return{error:"".concat(e)}}for(var a=[],o=void 0,c=0,i=!1;null!=(o=e.exec(t));){if((o={start:o.index,stop:o.index+o[0].length}).stop===o.start)return{matches:[]};if(a.push(o),++c>=r){i=!0;break}}var u={matches:a};return i&&(u.abort=i),u}(A,n,S,O);return{matches:r.matches,abort:r.abort,error:r.error,text:n}}()}),[b,E,k,O,S,_,A]);return g?r.React.createElement(i.Z,{visible:g,width:900,onCancel:s,title:r.React.createElement(r.React.Fragment,null,r.React.createElement(l.Icon,{name:"search"})," ",function(){var e="Find and Replace in ";if(!g)return e;if(_)e+="All ".concat(b.size," Cells");else if(0===(null==E?0:E.size||0))e+="the Current Cell";else{var t=E&&E.add(y).size||1;e+="".concat(t," Selected Cell").concat(t>1?"s":"")}return e}()),footer:r.React.createElement(r.React.Fragment,null,(u=p(),r.React.createElement(c.zx,{onClick:function(){return f(1)},bsStyle:"primary",disabled:0===u},h()," First Match")),function(){var e,t=p();return e=t>1?"".concat(t," Matches"):t>0?"One Match":"All",r.React.createElement(c.zx,{onClick:function(){return f()},bsStyle:"primary",disabled:0===t},h()," ",e)}(),r.React.createElement(c.zx,{onClick:s},"Close"))},r.React.createElement("form",null,r.React.createElement(c.cw,null,r.React.createElement(c.BZ,null,r.React.createElement(c.BZ.Button,null,r.React.createElement(c.zx,{onClick:function(){C(!S),d()},title:"Select to make search case sensitive",active:S},"Aa"),r.React.createElement(c.zx,{onClick:function(){I(!O),d()},title:"Use regex (JavaScript regex syntax)",active:O},".*"),r.React.createElement(c.zx,{onClick:function(){w(!_),d()},title:"Toggle searching one cell versus all cells",active:_},r.React.createElement(l.Icon,{name:"replace"})," ",_?"All Cells":"Current Cell")),function(){var e,t="Find";return S&&(t+=" case sensitive"),O&&(t+=" regular expression"),r.React.createElement(c.NI,{autoFocus:!0,inputRef:function(e){return F.current=e},type:"text",placeholder:t,value:A,onChange:function(){var t;return T(null!==(e=null===(t=F.current)||void 0===t?void 0:t.value)&&void 0!==e?e:"")}})}()),function(){var e;return r.React.createElement(c.NI,{style:{marginTop:"15px"},inputRef:function(e){return L.current=e},type:"text",placeholder:"Replace",value:D,onChange:function(){var t;return J(null!==(e=null===(t=L.current)||void 0===t?void 0:t.value)&&void 0!==e?e:"")}})}())),(t=z.matches,n=z.abort,a=z.error,o=z.text,a?function(e){return r.React.createElement(l.ErrorDisplay,{error:e,style:{margin:"1ex"}})}(a):r.React.createElement("div",null,n?function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return r.React.createElement("div",null,"Only showing first ",e," matches")}(null!=t?t.length:void 0):void 0,function(e,t){if(null==e)return m();var n=[],l=0,a=0,o=0,c=!0,i=!1,u=void 0;try{for(var s,d=t.split("\n")[Symbol.iterator]();!(c=(s=d.next()).done);c=!0){for(var f=s.value,p=a+f.length,h=[],v=0;l<e.length;){var g=e[l],b=g.start,y=g.stop;if(b>=p)break;var E=Math.max(v,b-a),k=Math.min(f.length,y-a);if(h.push(r.React.createElement("span",{key:o},f.slice(v,E))),o+=1,h.push(r.React.createElement("span",{key:o,style:{backgroundColor:"#ffa"}},f.slice(E,k))),o+=1,v=k,!(k<=p))break;l+=1}v<f.length&&(h.push(r.React.createElement("span",{key:o},f.slice(v))),o+=1),n.push(r.React.createElement("div",{key:o},h)),o+=1,a=p+1}}catch(e){i=!0,u=e}finally{try{c||null==d.return||d.return()}finally{if(i)throw u}}return r.React.createElement("div",null,m(e.length),r.React.createElement("pre",{style:{color:"#666",maxHeight:"50vh"}},n))}(t,o)))):r.React.createElement("span",null)}),(function(e,t){return!t.find_and_replace&&!e.find_and_replace})),ve=n(63505),ge=function(e){var t,n=e.actions,r=e.confirm_dialog;return ve.createElement(i.Z,{width:700,visible:null==r.get("choice"),onCancel:function(){n.close_confirm_dialog(),n.focus(!0)},title:ve.createElement(ve.Fragment,null,function(){var e=r.get("icon");if(null!=e)return ve.createElement(l.Icon,{name:e})}()," ",r.get("title")),footer:(t=r.get("choices"),null!=t?t.map((function(e){return function(e){return ve.createElement(c.zx,{key:e.title,bsStyle:e.style,autoFocus:e.default,onClick:function(){return n.close_confirm_dialog(e.title)}},e.title)}(e.toJS())})):[])},ve.createElement(l.Markdown,{value:r.get("body")}))},be=n(83772);function ye(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 Ee(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,l,a=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){c=!0,l=e}finally{try{o||null==n.return||n.return()}finally{if(c)throw l}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ye(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)?ye(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 ke=n(67060),Re=n(91205).SnippetsDialog,_e={float:"right",paddingLeft:"5px",backgroundColor:"#eee",display:"block",overflow:"hidden",borderLeft:"1px solid rgb(231,231,231)",borderBottom:"1px solid rgb(231,231,231)",whiteSpace:"nowrap",margin:"5px"},we={whiteSpace:"pre",fontFamily:"monospace",maxHeight:"30vh",overflow:"auto"},xe=r.React.memo((function(e){var t=e.actions,n=e.editor_actions,o=e.name,c=e.is_focused,i=e.is_fullscreen,u=e.font_size,s=e.mode,d=e.cur_id,m=e.sel_ids,f=e.md_edit_ids,p=e.scroll,h=e.scrollTop,v=e.hook_offset,g=(0,r.useRedux)([o,"complete"]),b=(0,r.useRedux)([o,"more_output"]),y=(0,r.useRedux)([o,"find_and_replace"]),E=(0,r.useRedux)([o,"show_kernel_selector"]),k=(0,r.useRedux)([o,"kernels"]),R=(0,r.useRedux)([o,"kernel_info"]),_=(0,r.useRedux)([o,"error"]),w=(0,r.useRedux)([o,"cm_options"]),x=(0,r.useRedux)([o,"fatal"]),S=(0,r.useRedux)([o,"toolbar"]),C=(0,r.useRedux)([o,"cell_list"]),O=(0,r.useRedux)([o,"cells"]),I=(0,r.useRedux)([o,"project_id"]),M=(0,r.useRedux)([o,"directory"]),A=(0,r.useRedux)([o,"about"]),P=(0,r.useRedux)([o,"backend_kernel_info"]),D=(0,r.useRedux)([o,"confirm_dialog"]),J=(0,r.useRedux)([o,"keyboard_shortcuts"]),Z=(0,r.useRedux)([o,"nbconvert"]),q=(0,r.useRedux)([o,"nbconvert_dialog"]),H=(0,r.useRedux)([o,"path"]),$=(0,r.useRedux)([o,"cell_toolbar"]),K=(0,r.useRedux)([o,"insert_image"]),W=(0,r.useRedux)([o,"edit_attachments"]),B=(0,r.useRedux)([o,"edit_cell_metadata"]),G=(0,r.useRedux)([o,"trust"]),Q=(0,r.useRedux)([o,"check_select_kernel_init"]),ee=(0,r.useRedux)([o,"kernel_error"]),te=(0,r.useRef)(!r.redux.getStore("account").getIn(["editor_settings","disable_jupyter_virtualization"])),re=function(e){var t=(0,r.useRedux)([e,"kernel_state"]),n=(0,r.useRedux)([e,"kernel_usage"]),l=(0,r.useRedux)([e,"backend_state"]),a=(0,r.useRedux)([e,"cells"]),o=(0,V.useMemo)((function(){return function(e){return null==e?[]:e.toList().map((function(e){var t=e.get("start"),n=e.get("end");return null!=t&&null!=n?(n-t)/1e3:null})).filter((function(e){return null!=e})).sort().toJS()}(a)}),[a]),c=(0,V.useMemo)((function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.75;if(0==e.length)return t;var r=e.length-1,l=Math.floor(n*r),a=Math.min(r,l);return Math.max(t,e[a])}(o)}),[o]),i=Ee((0,V.useState)(),2),u=i[0],s=i[1],d=Ee((0,V.useState)(0),2),m=d[0],f=d[1],p=(0,V.useRef)();return(0,V.useEffect)((function(){"busy"==t?s(Date.now()):null!=u&&s(void 0)}),[t]),(0,V.useEffect)((function(){return null!=u?p.current=setInterval((function(){f("busy"==t?(Date.now()-u)/1e3:0)}),100):null!=p.current&&(f(0),clearInterval(p.current)),function(){null!=p.current&&clearInterval(p.current)}}),[u,t]),{usage:(0,V.useMemo)((function(){return(0,F.a)({kernel_usage:n,backend_state:l,cpu_runtime:m,expected_cell_runtime:c})