@deephaven/code-studio 0.59.1-beta.4 → 0.59.1-deferred-api.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/build/assets/{AppRoot-bc9433b4.js → AppRoot-15c43d14.js} +3 -3
  2. package/build/assets/AppRoot-15c43d14.js.map +1 -0
  3. package/build/assets/ControlType-ccb39f97.js +21 -0
  4. package/build/assets/ControlType-ccb39f97.js.map +1 -0
  5. package/build/assets/{FontBootstrap-5b595a14.js → FontBootstrap-f9c22091.js} +2 -2
  6. package/build/assets/{FontBootstrap-5b595a14.js.map → FontBootstrap-f9c22091.js.map} +1 -1
  7. package/build/assets/{IrisGrid-49222932.js → IrisGrid-194f7355.js} +2 -2
  8. package/build/assets/{IrisGrid-49222932.js.map → IrisGrid-194f7355.js.map} +1 -1
  9. package/build/assets/{IrisGridModelFactory-aa9601b0.js → IrisGridModelFactory-4d892db6.js} +2 -2
  10. package/build/assets/IrisGridModelFactory-4d892db6.js.map +1 -0
  11. package/build/assets/{StyleGuideRoot-42cc11d1.js → StyleGuideRoot-57022f58.js} +2 -2
  12. package/build/assets/{StyleGuideRoot-42cc11d1.js.map → StyleGuideRoot-57022f58.js.map} +1 -1
  13. package/build/assets/index-6bb07a89.js +8 -0
  14. package/build/assets/index-6bb07a89.js.map +1 -0
  15. package/build/assets/{index-c8c58d11.js → index-cb785e94.js} +2 -2
  16. package/build/assets/{index-c8c58d11.js.map → index-cb785e94.js.map} +1 -1
  17. package/build/assets/index-d2c4f360.js +2 -0
  18. package/build/assets/index-d2c4f360.js.map +1 -0
  19. package/build/assets/{usePlugins-660df156.js → usePlugins-50716f7f.js} +3 -3
  20. package/build/assets/usePlugins-50716f7f.js.map +1 -0
  21. package/build/assets/{useUser-84d4eed4.js → useUser-d7f27325.js} +2 -2
  22. package/build/assets/{useUser-84d4eed4.js.map → useUser-d7f27325.js.map} +1 -1
  23. package/build/index.html +1 -1
  24. package/package.json +31 -31
  25. package/build/assets/AppRoot-bc9433b4.js.map +0 -1
  26. package/build/assets/ControlType-b475cfe6.js +0 -21
  27. package/build/assets/ControlType-b475cfe6.js.map +0 -1
  28. package/build/assets/IrisGridModelFactory-aa9601b0.js.map +0 -1
  29. package/build/assets/index-e89a2b92.js +0 -2
  30. package/build/assets/index-e89a2b92.js.map +0 -1
  31. package/build/assets/index-fb867b42.js +0 -8
  32. package/build/assets/index-fb867b42.js.map +0 -1
  33. package/build/assets/usePlugins-660df156.js.map +0 -1
@@ -0,0 +1,21 @@
1
+ import{C as l,G as re,r as c,ap as Hr,M as Me,F as ee,H as ae,Q as _e,aq as Pt,S as Hi,K as Lt,L as Ur,ar as On,as as $r,at as Br,au as Vr,av as Wr,R as Ui,am as _n,J as Mt,a1 as $i,an as Kr,aw as Gr,ao as zr}from"./vendor-a758141f.js";import{x as Yr,aq as qr,an as Bi,ao as Vi,G as Wi,j as Zr,e as D,d as St,ar as Xr,L as Q,as as kn,at as Qr,au as Jr,av as ea,aw as ta,f as Ki,ag as Gi,ax as zi,ay as Ot,H as wn,am as na,az as ia,aA as ra,aB as Hn,aC as qt,aD as Un,aE as Yi,aF as aa,D as sa,aG as oa,aH as la,aI as da,aJ as ha,aK as ua,M as ca,b as va,c as ma,aL as pa,aM as ga,ai as fa,aN as ba,aO as Ca,aP as Sa}from"./index-cb785e94.js";import{u as Ea,a8 as ya,d as qi,B as K,f as Ce,a3 as q,K as Y,bb as Ta,N as Oe,P as ce,G as Zt,w as k,b8 as Pa,D as Zi,S as Oa,C as wa,l as wt,m as Xi,b9 as gt,E as Na,g as lt,ba as xa,b7 as Da,_ as bn,a6 as La,ay as Ra,X as Ia,R as Ma,aw as Fa,r as Nn,v as Aa,aC as se,t as xe,o as ke,n as dt,b4 as $n,aY as ja,aF as _a,bc as Nt,Z as Bn,x as Rt,a4 as ka,a1 as Ha,bd as Ua,p as $a,aD as Ct,aE as Le,aL as Ba}from"./usePlugins-50716f7f.js";import{e as xn,l as Ut,K as xt,a as Qi}from"./monaco-1410cbed.js";function Va(i){var{type:e}=i,t=Ea();switch(e){case t.VariableType.TABLE:case t.VariableType.TABLEMAP:case t.VariableType.TREETABLE:case t.VariableType.HIERARCHICALTABLE:case t.VariableType.PARTITIONEDTABLE:return l.jsx(re,{icon:Vi});case t.VariableType.FIGURE:return l.jsx(re,{icon:Bi});case t.VariableType.PANDAS:return l.jsx(re,{icon:qr});default:return l.jsx(re,{icon:Yr})}}function Vn(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Wa(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Vn(a,n,r,s,o,"next",d)}function o(d){Vn(a,n,r,s,o,"throw",d)}s(void 0)})}}function Dn(i){var{children:e,language:t}=i,[n,r]=c.useState(null),{activeThemes:a}=ya();return c.useEffect(()=>{var s=!1;function o(){return d.apply(this,arguments)}function d(){return d=Wa(function*(){if(e!=null&&a!=null){var h=yield xn.colorize(e.toString(),t,{});s||r(h)}}),d.apply(this,arguments)}return o(),()=>{s=!0}},[a,e,t]),l.jsx("div",{style:{pointerEvents:"none"},dangerouslySetInnerHTML:n!=null?{__html:n}:void 0})}class Ka{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const Ji=Ka;class Xt{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:Hr.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:"".concat(t))}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;var t="".concat(e.getHours()).padStart(2,"0"),n="".concat(e.getMinutes()).padStart(2,"0"),r="".concat(e.getSeconds()).padStart(2,"0"),a="".concat(e.getMilliseconds()).padStart(3,"0");return"".concat(t,":").concat(n,":").concat(r,".").concat(a)}static isTableType(e,t){return t===e.VariableType.TABLE||t===e.VariableType.TREETABLE||t===e.VariableType.HIERARCHICALTABLE||t===e.VariableType.PARTITIONEDTABLE}static isWidgetType(e,t){return t===e.VariableType.FIGURE||t===e.VariableType.OTHERWIDGET||t===e.VariableType.PANDAS}static isOpenableType(e,t){return Xt.isTableType(e,t)||Xt.isWidgetType(e,t)}static isFigureType(e,t){return t===e.VariableType.FIGURE}static isPandas(e,t){return t===e.VariableType.PANDAS}}const Cn=Xt;function er(i){var{children:e}=i;return l.jsxs("div",{className:"console-history-item-result",children:[l.jsx("div",{className:"console-history-gutter",children:"-"}),l.jsx("div",{className:"console-history-content",children:e})]})}er.propTypes={children:Me.node.isRequired};function Sn(i,e,t){return e=Ga(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ga(i){var e=za(i,"string");return typeof e=="symbol"?e:String(e)}function za(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class tr extends c.Component{constructor(e){super(e),Sn(this,"timer",void 0),Sn(this,"startTime",void 0),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){var{disabled:e,onCancelClick:t}=this.props,{elapsed:n}=this.state;return l.jsx("div",{className:ee("console-history-result-in-progress",{disabled:e}),children:l.jsxs("span",{className:"badge",children:[l.jsx(Wi,{className:"ml-2"}),"Running... ",qi.formatElapsedTime(n)," ",l.jsx(K,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:Zr,tooltip:"Cancel",onClick:t,disabled:e})]})})}}Sn(tr,"defaultProps",{disabled:!1});const Ya=tr;function Dt(i,e,t){return e=qa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function qa(i){var e=Za(i,"string");return typeof e=="symbol"?e:String(e)}function Za(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class vt extends c.PureComponent{constructor(e){super(e),Dt(this,"mouseX",void 0),Dt(this,"mouseY",void 0),Dt(this,"isClicking",void 0),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}handleKeyPress(e){switch(e.key){case"Enter":case" ":this.handleToggleError(),e.stopPropagation(),e.preventDefault();break}}handleMouseDown(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isClicking=!0}handleMouseMove(e){this.mouseX!=null&&this.mouseY!=null?(Math.abs(e.clientX-this.mouseX)>=vt.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=vt.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(e){this.isClicking&&!e.shiftKey&&!e.metaKey&&!e.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(e=>({isExpanded:!e.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){var{isExpanded:e,isTriggerHovered:t}=this.state,{message:n}=this.props;D(n);var r=n.indexOf(`
2
+ `),a=r>-1,s=n;a&&(s=n.slice(0,r));var o=n.slice(r),d=t?"error-btn-link error-btn-link--active":"error-btn-link";return l.jsxs("div",{className:ee("error-message",{expanded:e}),children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"error-gutter",children:l.jsx("button",{type:"button",onClick:this.handleToggleError,className:d,tabIndex:-1,children:l.jsx(re,{icon:e?St:Xr,transform:"left-3"})})}),l.jsxs("div",{className:"error-content",children:[l.jsx("div",{className:"console-error-text-trigger",role:"button",tabIndex:0,onKeyPress:this.handleKeyPress,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseUp:this.handleMouseUp,children:s}),e?o:""]})]}),!a&&l.jsx("div",{className:"error-content",children:l.jsx("div",{className:"console-error-text",children:s})})]},"error")}}Dt(vt,"defaultProps",{message:""});Dt(vt,"mouseDragThreshold",5);const Xa=vt;function Qa(i,e,t){return e=Ja(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ja(i){var e=es(i,"string");return typeof e=="symbol"?e:String(e)}function es(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Wn=Q.module("ConsoleHistoryItem");class nr extends c.PureComponent{constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){Wn.debug("handleObjectClick",e);var{openObject:t}=this.props;t(e)}handleCancelClick(){var{item:e}=this.props;e!=null&&e.cancelResult&&(Wn.debug("Cancelling command: ".concat(e.command)),e.cancelResult())}render(){var{disabled:e,item:t,language:n,iconForType:r}=this.props,{disabledObjects:a,result:s}=t,o=t.command!=null&&t.command!=="",d=null;o&&(d=l.jsxs("div",{className:"console-history-item-command",children:[l.jsx("div",{className:"console-history-gutter",children:">"}),l.jsx("div",{className:"console-history-content",children:l.jsx(Dn,{language:n,children:t.command})})]}));var h=[],u=!1;if(s){var{error:v,message:m,changes:p}=s;if(p){var{created:E,updated:S}=p;[...E,...S].forEach(Z=>{u=!0;var{title:A}=Z,z="".concat(A),G=e===void 0||e||(a??[]).indexOf(z)>=0,X=l.jsx(K,{kind:"primary",onClick:()=>this.handleObjectClick(Z),className:"btn-console-object",disabled:G,icon:r(Z.type),children:A},z);h.push(X)})}if(v!=null&&!o){var g,y="".concat((g=v.message)!==null&&g!==void 0?g:v);y||(y=v);var P=l.jsx(Xa,{message:y},"result-error");h.push(P)}if(m!==void 0&&m!==""){var O=l.jsx("div",{className:"log-message",children:m},"log-message");h.push(O)}}else{u=!0;var L=l.jsx(Ya,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");h.push(L)}var V=null;return h.length>0&&(V=l.jsx(er,{children:h})),l.jsxs("div",{className:ee("console-command-result",{"console-result-buttons":u}),children:[d,V]})}}Qa(nr,"defaultProps",{disabled:!1});const ts=nr;function ns(i,e){return"".concat(i,".").concat(e.command,".").concat(e.result&&e.result.message,".").concat(e.result&&e.result.error)}function is(i){for(var{disabled:e=!1,items:t,language:n,openObject:r,supportsType:a,iconForType:s}=i,o=[],d=0;d<t.length;d+=1){var h=t[d],u=l.jsx(ts,{disabled:e,item:h,openObject:r,language:n,supportsType:a,iconForType:s},ns(d,h));o.push(u)}return l.jsx("div",{className:"container-fluid console-history",children:o})}var rs={name:"Console",CLEAR:Ce.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[q.CTRL,Y.L],macShortcut:[q.CTRL,Y.C]}),FOCUS_HISTORY:Ce.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]})},as={name:"Command History",FOCUS_HISTORY:Ce.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]}),SEND_TO_CONSOLE:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]}),SEND_TO_NOTEBOOK:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[q.CTRL,Y.ENTER],macShortcut:[q.CMD,Y.ENTER]}),RUN:Ce.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]})},ss={name:"Notebook",RUN:Ce.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]}),RUN_SELECTED:Ce.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[q.ALT,q.SHIFT,Y.R],macShortcut:[q.OPTION,q.SHIFT,Y.R]}),FIND:Ce.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[q.CTRL,Y.F],macShortcut:[q.CMD,Y.F],isEditable:!1}),MINIMAP:Ce.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[q.ALT,Y.M],macShortcut:[q.OPTION,Y.M]}),WORDWRAP:Ce.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[q.ALT,Y.Z],macShortcut:[q.OPTION,Y.Z]})},os={CONSOLE:rs,COMMAND_HISTORY:as,NOTEBOOK:ss};const be=os,de=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"});function hn(i,e,t){return e=ls(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ls(i){var e=ds(i,"string");return typeof e=="symbol"?e:String(e)}function ds(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Be=Q.module("MonacoCompletionProvider");class at extends c.PureComponent{static lspToMonacoKind(e){var t=Ut.CompletionItemKind;switch(e){case 1:return t.Text;case 2:return t.Method;case 3:return t.Function;case 4:return t.Constructor;case 5:return t.Field;case 6:return t.Variable;case 7:return t.Class;case 8:return t.Interface;case 9:return t.Module;case 10:return t.Property;case 11:return t.Unit;case 12:return t.Value;case 13:return t.Enum;case 14:return t.Keyword;case 15:return t.Snippet;case 16:return t.Color;case 17:return t.File;case 18:return t.Reference;case 19:return t.Folder;case 20:return t.EnumMember;case 21:return t.Constant;case 22:return t.Struct;case 23:return t.Event;case 24:return t.Operator;case 25:return t.TypeParameter;default:return t.Variable}}static lspToMonacoRange(e){var{start:t,end:n}=e;return{startLineNumber:t.line+1,startColumn:t.character+1,endLineNumber:n.line+1,endColumn:n.character+1}}static monacoToLspPosition(e){return{line:e.lineNumber-1,character:e.column-1}}constructor(e){super(e),hn(this,"registeredCompletionProvider",void 0),hn(this,"registeredSignatureProvider",void 0),hn(this,"registeredHoverProvider",void 0),this.handleCompletionRequest=this.handleCompletionRequest.bind(this),this.handleSignatureRequest=this.handleSignatureRequest.bind(this),this.handleHoverRequest=this.handleHoverRequest.bind(this)}componentDidMount(){var{language:e,session:t}=this.props;this.registeredCompletionProvider=Ut.registerCompletionItemProvider(e,{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:[".",'"',"'"]}),t.getSignatureHelp&&(this.registeredSignatureProvider=Ut.registerSignatureHelpProvider(e,{provideSignatureHelp:this.handleSignatureRequest,signatureHelpTriggerCharacters:["(",","]})),t.getHover&&(this.registeredHoverProvider=Ut.registerHoverProvider(e,{provideHover:this.handleHoverRequest}))}componentWillUnmount(){var e,t,n;(e=this.registeredCompletionProvider)===null||e===void 0||e.dispose(),(t=this.registeredSignatureProvider)===null||t===void 0||t.dispose(),(n=this.registeredHoverProvider)===null||n===void 0||n.dispose()}handleCompletionRequest(e,t,n){var{model:r,session:a}=this.props;if(e!==r)return null;var s={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:at.monacoToLspPosition(t),context:n},o=a.getCompletionItems(s);Be.debug("Requested completion items",s);var d=o.then(h=>{Be.debug("Completion items received: ",s,h);var u=h.map(v=>{var{label:m,kind:p,detail:E,documentation:S,sortText:g,filterText:y,textEdit:P,insertTextFormat:O}=v;return{label:m,kind:at.lspToMonacoKind(p),detail:E,documentation:S?.kind==="markdown"?S:S?.value,sortText:g,filterText:y,insertText:P.text,insertTextRules:O===2?4:O,range:at.lspToMonacoRange(P.range)}});return{incomplete:!0,suggestions:u}}).catch(h=>(Be.error("There was an error retrieving completion items",h),{suggestions:[]}));return d}handleSignatureRequest(e,t,n,r){var a={value:{signatures:[],activeSignature:0,activeParameter:0},dispose:()=>{}},{model:s,session:o}=this.props;if(e!==s||!o.getSignatureHelp)return null;var d={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:at.monacoToLspPosition(t),context:r},h=o.getSignatureHelp(d);Be.debug("Requested signature help",d);var u=h.then(v=>{Be.debug("Signatures received: ",d,h);var m=v.map(E=>{var{label:S,documentation:g,parameters:y}=E;return{documentation:g?.kind==="markdown"?g:g?.value,label:S,parameters:y??[]}});if(m.length===0)return a;var p=0;return{value:{signatures:m,activeSignature:p,activeParameter:v[p].activeParameter},dispose:()=>{}}}).catch(v=>(Be.error("There was an error retrieving completion items",v),a));return u}handleHoverRequest(e,t){var{model:n,session:r}=this.props;if(e!==n||!r.getHover)return null;var a={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:at.monacoToLspPosition(t)},s=r.getHover(a);Be.debug("Requested hover",a);var o=s.then(d=>{Be.debug("Hover received: ",a,d);var{contents:h}=d;return{contents:h?[h]:[]}}).catch(d=>(Be.error("There was an error retrieving hover",d),{contents:[]}));return o}render(){return null}}const ir=at;function Kn(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function hs(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Kn(a,n,r,s,o,"next",d)}function o(d){Kn(a,n,r,s,o,"throw",d)}s(void 0)})}}function Te(i,e,t){return e=us(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function us(i){var e=cs(i,"string");return typeof e=="symbol"?e:String(e)}function cs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var un=Q.module("ConsoleInput"),Qt=parseInt(Ta["line-height"],10),rr=6,ar=6,vs=Qt+rr+ar,cn=100;class Ft extends c.PureComponent{constructor(e){super(e),Te(this,"cancelListener",void 0),Te(this,"commandContainer",void 0),Te(this,"commandEditor",void 0),Te(this,"commandHistoryIndex",void 0),Te(this,"commandSuggestionContainer",void 0),Te(this,"loadingPromise",void 0),Te(this,"timestamp",void 0),Te(this,"bufferIndex",void 0),Te(this,"history",void 0),Te(this,"modifiedCommands",void 0),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=ae.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:Qt,isFocused:!1,model:null}}componentDidMount(){this.initCommandEditor(),window.addEventListener("resize",this.handleWindowResize),this.loadMoreHistory()}componentDidUpdate(){this.layoutEditor()}componentWillUnmount(){window.removeEventListener("resize",this.handleWindowResize),this.loadingPromise!=null&&this.loadingPromise.cancel(),this.destroyCommandEditor()}setConsoleText(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e){if(un.debug("Command received: ",e),!n){var r;this.commandHistoryIndex=null,(r=this.commandEditor)===null||r===void 0||r.setValue(e)}t&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(e)}}initCommandEditor(){var{language:e,session:t}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:e,lineHeight:Qt,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:rr,bottom:ar},value:"",wordWrap:"on"},r=this.commandContainer.current;D(r),this.commandEditor=xn.create(r,n),Oe.setEOL(this.commandEditor),Oe.openDocument(this.commandEditor,t),this.commandEditor.onDidChangeModelContent(()=>{var a,s=(a=this.commandEditor)===null||a===void 0?void 0:a.getValue();this.modifiedCommands.set(this.commandHistoryIndex,s??null),this.updateDimensions()}),this.commandEditor.onDidFocusEditorText(()=>{this.setState({isFocused:!0})}),this.commandEditor.onDidBlurEditorText(()=>{this.setState({isFocused:!1})}),this.commandEditor.onKeyDown(a=>{var{commandEditor:s,commandHistoryIndex:o}=this,d=s?.getPosition();D(d);var{lineNumber:h}=d,u=s?.getModel();if(a.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&h===1){o!=null?this.loadCommand(o+1):this.loadCommand(0),this.focusStart(),a.stopPropagation(),a.preventDefault();return}if(a.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&h===u?.getLineCount()){o!=null&&o>0?this.loadCommand(o-1):this.loadCommand(null),this.focusEnd(),a.stopPropagation(),a.preventDefault();return}if(!a.altKey&&!a.shiftKey&&!a.metaKey&&a.keyCode===xt.Enter&&!this.isSuggestionMenuPopulated()){var v;a.stopPropagation(),a.preventDefault();var m=(v=this.commandEditor)===null||v===void 0?void 0:v.getValue().trim();if(m!==void 0){var p;this.processCommand(m),(p=this.commandEditor)===null||p===void 0||p.setValue("")}}}),Oe.disableKeyBindings(this.commandEditor,[Qi.CtrlCmd|xt.KeyF]),Oe.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){var{session:e}=this.props;this.commandEditor&&(Oe.closeDocument(this.commandEditor,e),this.commandEditor.dispose(),this.commandEditor=void 0)}handleWindowResize(){this.updateDimensions()}isSuggestionMenuActive(){var e;if(!this.commandSuggestionContainer){var t,n;this.commandSuggestionContainer=(t=this.commandEditor)===null||t===void 0||(n=t.getDomNode())===null||n===void 0?void 0:n.querySelector(".suggest-widget")}return(e=this.commandSuggestionContainer&&this.commandSuggestionContainer.classList.contains("visible"))!==null&&e!==void 0?e:!1}isSuggestionMenuPopulated(){var e,t,n;return this.isSuggestionMenuActive()&&((e=(t=this.commandSuggestionContainer)===null||t===void 0||(n=t.querySelector(".monaco-list-rows"))===null||n===void 0?void 0:n.childElementCount)!==null&&e!==void 0?e:0)>0}focus(){var e;(e=this.commandEditor)===null||e===void 0||e.focus()}focusStart(){var e,t,n,r,a,s=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();D(s);var o=s.getLineLength(1)+1,d=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(1,o);D(d),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:1,column:o}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(d),(a=this.commandEditor)===null||a===void 0||a.focus()}focusEnd(){var e,t,n,r,a,s=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();D(s);var o=s.getLineCount(),d=s.getLineLength(o)+1,h=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(o,d);D(h),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:o,column:d}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(h),(a=this.commandEditor)===null||a===void 0||a.focus()}clear(){var e,t,n;(e=this.commandEditor)===null||e===void 0||e.focus(),(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(""),this.commandHistoryIndex=null}layoutEditor(){this.commandEditor&&this.commandEditor.layout()}loadCommand(e){var t,n;if(!(e!==null&&e>=this.history.length)){var r=this.modifiedCommands.get(e),a=e===null?"":this.history[this.history.length-e-1];this.commandHistoryIndex=e,(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(r??a),e!==null&&e>this.history.length-cn&&this.loadMoreHistory()}}loadMoreHistory(){var e=this;return hs(function*(){try{if(e.loadingPromise!=null||e.bufferIndex==null)return;var{commandHistoryStorage:t,language:n,scope:r}=e.props;e.loadingPromise=ce.makeCancelable(t.getTable(n,r??"",e.timestamp),o=>o.close());var a=yield e.loadingPromise;a.setReversed(!0),a.setViewport({top:e.bufferIndex,bottom:e.bufferIndex+cn-1}),e.loadingPromise=ce.makeCancelable(a.getViewportData(),()=>a.close());var s=yield e.loadingPromise;e.bufferIndex+=cn,e.bufferIndex>=a.size&&(e.bufferIndex=null),e.history=[...s.items.filter((o,d,h)=>{var{name:u}=o;return d===0||u!==h[d-1].name}).map(o=>{var{name:d}=o;return d}).reverse(),...e.history],e.loadingPromise=void 0,a.close()}catch(o){if(e.loadingPromise=void 0,ce.isCanceled(o)){un.debug2("Promise canceled, not loading history");return}un.error("Error fetching history",o)}})()}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),D(e),e!==""&&(this.history.length===0||e!==this.history[this.history.length-1])&&this.history.push(e),this.updateDimensions();var{onSubmit:t}=this.props;t(e)}updateDimensions(){if(this.commandEditor){var{maxHeight:e}=this.props;D(e);var t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),vs),r=t>n,a={overviewRulerLanes:r?void 0:0};this.setState({commandEditorHeight:n},()=>{var s,o;(s=this.commandEditor)===null||s===void 0||s.updateOptions(a),(o=this.commandEditor)===null||o===void 0||o.layout()})}}render(){var{disabled:e,language:t,session:n}=this.props,{commandEditorHeight:r,isFocused:a,model:s}=this.state;return l.jsx("div",{className:ee("console-input-wrapper",{disabled:e}),children:l.jsxs("div",{className:ee("console-input-inner-wrapper",{focus:a}),children:[l.jsx("div",{className:Ft.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:r}}),s&&l.jsx(ir,{model:s,language:t,session:n})]})})}}Te(Ft,"defaultProps",{maxHeight:Qt*10,scope:null,disabled:!1});Te(Ft,"INPUT_CLASS_NAME","console-input");const Gn=Ft;function Ze(i,e,t){return e=ms(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ms(i){var e=ps(i,"string");return typeof e=="symbol"?e:String(e)}function ps(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var zn="pasted values",gs=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],vn=[".csv",".tsv",".tab",".psv",".dsv",".txt"],Yn=[".zip"];class je extends c.Component{static isValidDropItem(e){return e!=null&&e.kind==="file"&&!gs.find(t=>t.test(e.type))}static isValidExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return vn.some(n=>e.endsWith(n))||t&&Yn.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===zn?kn:e.endsWith(".csv")?Qr:e.endsWith(".zip")?Jr:ea}constructor(e){super(e),Ze(this,"fileElem",void 0),Ze(this,"divElem",void 0),Ze(this,"getValidExtensions",_e(t=>t?[...vn,...Yn]:[...vn])),Ze(this,"getAcceptString",_e(t=>this.getValidExtensions(t).join(", "))),Ze(this,"getFileTypeErrorString",_e(t=>Pa.join(this.getValidExtensions(t),"or"))),this.handleSelectFile=this.handleSelectFile.bind(this),this.handleFiles=this.handleFiles.bind(this),this.handleDrop=this.handleDrop.bind(this),this.unstageFile=this.unstageFile.bind(this),this.handleMenuPaste=this.handleMenuPaste.bind(this),this.handlePasteEvent=this.handlePasteEvent.bind(this),this.fileElem=ae.createRef(),this.divElem=ae.createRef(),this.state={selectedFileName:""}}componentDidMount(){var e,t;(e=this.divElem.current)===null||e===void 0||e.addEventListener("paste",this.handlePasteEvent),(t=this.divElem.current)===null||t===void 0||t.focus()}componentWillUnmount(){var e;(e=this.divElem.current)===null||e===void 0||e.removeEventListener("paste",this.handlePasteEvent)}handleSelectFile(){if(this.fileElem.current){var e;this.fileElem.current.value="",(e=this.fileElem.current)===null||e===void 0||e.click()}}handleFiles(e){e.stopPropagation(),e.preventDefault();var{files:t}=e.target;t!=null&&this.handleFile(t[0])}handleDrop(e){var{allowZip:t,clearDragError:n,dragError:r}=this.props;if(e.preventDefault(),e.stopPropagation(),r!=null){n();return}if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0)){var a=e.dataTransfer.items[0].getAsFile();D(a),je.isValidExtension(a.name,t)?this.handleFile(a):this.setState({dropError:je.FILE_TYPE_ERROR})}}unstageFile(e){var{onCancel:t}=this.props;e.stopPropagation(),e.preventDefault(),t(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(e){var{onFileOpened:t}=this.props;t(e),this.setState({selectedFileName:e.name,dropError:void 0})}handleMenuPaste(){var{onPaste:e,onError:t,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(r=>{e(r),this.setState({selectedFileName:zn,dropError:void 0})}).catch(r=>t(r))}handlePasteEvent(e){e.stopPropagation(),e.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){var{uploadInProgress:e}=this.props;return[{title:"Paste",icon:kn,action:this.handleMenuPaste,shortcut:Zt.PASTE,disabled:e}]}render(){var{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:r,dropError:a}=this.state,s=t??a,o=this.makeContextMenuItems();return l.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:je.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(k,{actions:o}),l.jsx("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(e),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!r&&(s===void 0||s==="")&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:ta})}),l.jsx("label",{children:"Drop file (or paste values) here to import"}),l.jsx("div",{className:"message-small",children:l.jsx("label",{children:"or"})}),l.jsx(K,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),r&&(s===void 0||s==="")&&l.jsxs("div",{className:"selected-content",children:[l.jsx("div",{className:"selected-icon",children:l.jsx(re,{icon:je.getIcon(r)})}),l.jsxs("div",{className:"selected-text",children:[l.jsx("label",{children:"Selected File"}),l.jsxs("label",{className:"selected-name",children:[r,!n&&l.jsx(K,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Ki,tooltip:"Remove"})]})]})]}),!!s&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:Gi})}),l.jsx("label",{children:s}),s===je.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}Ze(je,"defaultProps",{allowZip:!1,dragError:null});Ze(je,"MULTIPLE_FILE_ERROR","Please select only one file");Ze(je,"FILE_TYPE_ERROR","Filetype not supported.");const ct=je;function ht(i,e,t){return e=fs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function fs(i){var e=bs(i,"string");return typeof e=="symbol"?e:String(e)}function bs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Qe{}ht(Qe,"INTEGER","int");ht(Qe,"LONG","long");ht(Qe,"DOUBLE","double");ht(Qe,"BOOLEAN","bool");ht(Qe,"STRING","string");ht(Qe,"DATE_TIME","datetime");ht(Qe,"LOCAL_TIME","localtime");const U=Qe;function sr(i,e){var t=i.internalStream("string");return t.readable=!0,t.read=()=>!1,t.removeListener=()=>!1,t.on("data",(n,r)=>e(r)),t}function qn(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Zn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qn(Object(t),!0).forEach(function(n){ge(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):qn(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ge(i,e,t){return e=Cs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Cs(i){var e=Ss(i,"string");return typeof e=="symbol"?e:String(e)}function Ss(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Xn="unknown",Es=2147483647,ys=-2147483648,Qn=/^[0-9]{4}-[0-1][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-6][0-9](?:\.[0-9]{1,9})?(?: [a-zA-Z]+)?$/,Jn=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class he{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case U.STRING:return U.STRING;case U.INTEGER:return he.checkInteger(e);case U.LONG:return he.checkLong(e);case U.DOUBLE:return he.checkDouble(e);case U.BOOLEAN:return he.checkBoolean(e);case U.DATE_TIME:return he.checkDateTime(e);case U.LOCAL_TIME:return he.checkLocalTime(e);default:return he.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:he.getNumberType(t)}static checkLong(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:t.includes(".")?U.DOUBLE:U.LONG}static checkDouble(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:U.DOUBLE}static checkBoolean(e){var t=e.toLowerCase();return t==="true"||t==="false"?U.BOOLEAN:U.STRING}static checkDateTime(e){return Qn.test(e)?U.DATE_TIME:U.STRING}static checkLocalTime(e){return Jn.test(e)?U.LOCAL_TIME:U.STRING}static getTypeFromUnknown(e){var t=e.replace(/,/g,"");if(he.isNotParsableNumber(t)){var n=e.toLowerCase();return n==="true"||n==="false"?U.BOOLEAN:Qn.test(e)&&e.includes(":")?U.DATE_TIME:Jn.test(e)?U.LOCAL_TIME:U.STRING}return he.getNumberType(t)}static getNumberType(e){if(e.includes("."))return U.DOUBLE;var t=e.startsWith("-")?11:10;if(e.length>t)return U.LONG;var n=parseInt(e,10);return n>Es||n<ys?U.LONG:U.INTEGER}constructor(e,t,n,r,a,s,o,d,h,u){ge(this,"onFileCompleted",void 0),ge(this,"file",void 0),ge(this,"readHeaders",void 0),ge(this,"nullString",void 0),ge(this,"onProgress",void 0),ge(this,"onError",void 0),ge(this,"types",void 0),ge(this,"chunks",void 0),ge(this,"totalChunks",void 0),ge(this,"rowCount",void 0),ge(this,"isZip",void 0),ge(this,"shouldTrim",void 0),ge(this,"zipProgress",void 0),ge(this,"config",void 0),this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=a,this.onProgress=s,this.onError=o,this.chunks=0,this.totalChunks=d,this.rowCount=0,this.isZip=h,this.shouldTrim=u,this.zipProgress=0,this.handleChunk=this.handleChunk.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleError=this.handleError.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.config=Zn(Zn({},r),{},{error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete})}parse(){if(this.file instanceof File||this.file instanceof Blob)Pt.parse(this.file,this.config);else{var e=sr(this.file,this.handleNodeUpdate);Pt.parse(e,this.config),e.resume()}}handleChunk(e,t){var{data:n}=e;if(!this.types){if(n==null||n.length===0){t.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(n[0].length).fill(Xn),this.readHeaders&&(n=n.slice(1))}this.rowCount+=n.length,D(this.types);var r=[...this.types];n.forEach(o=>{if(o.length>=r.length){for(var d=0;d<r.length;d+=1)r[d]=he.determineType(this.shouldTrim?o[d].trim():o[d],r[d],this.nullString);this.types=r}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
3
+ Expected length `.concat(r.length," but found ").concat(o.length,`.
4
+ Row = `).concat(o))}),this.chunks+=1;var a=0;this.totalChunks>0?a=Math.round(this.chunks/this.totalChunks*50):a=Math.round(this.zipProgress/2);var s=this.onProgress(a);s&&t.abort()}handleComplete(e){var{types:t,onFileCompleted:n}=this;D(t),(e==null||!e.meta.aborted)&&n(t.map(r=>r===Xn||r===U.LOCAL_TIME?U.STRING:r),this.rowCount)}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const Ts=he;function J(i,e,t){return e=Ps(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ps(i){var e=Os(i,"string");return typeof e=="symbol"?e:String(e)}function Os(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var $t=Q.module("CsvParser"),ws=650;class mt{static generateHeaderRecursive(e){var t="",n=e;return e>=26&&(t=t.concat(mt.generateHeaderRecursive(Math.floor(e/26)-1)),n=e%26),t.concat(String.fromCharCode(65+n))}constructor(e){var{onFileCompleted:t,session:n,file:r,type:a,readHeaders:s=!0,onProgress:o,onError:d,timeZone:h,isZip:u}=e;J(this,"onFileCompleted",void 0),J(this,"session",void 0),J(this,"file",void 0),J(this,"isZip",void 0),J(this,"type",void 0),J(this,"readHeaders",void 0),J(this,"timeZone",void 0),J(this,"onProgress",void 0),J(this,"onError",void 0),J(this,"tables",void 0),J(this,"headers",void 0),J(this,"types",void 0),J(this,"rowCount",void 0),J(this,"rowsProcessed",void 0),J(this,"chunks",void 0),J(this,"totalChunks",void 0),J(this,"isComplete",void 0),J(this,"zipProgress",void 0),J(this,"consolidatedChunks",void 0),J(this,"numConsolidated",void 0),J(this,"isCancelled",void 0),J(this,"config",void 0),this.onFileCompleted=t,this.session=n,this.file=r,this.isZip=u,this.type=a,this.readHeaders=s,this.timeZone=h,this.onProgress=o,this.onError=d,this.tables=[],this.rowCount=0,this.rowsProcessed=0,this.chunks=0,this.totalChunks=u?0:Math.ceil(r.size/Pt.LocalChunkSize),this.isComplete=!1,this.zipProgress=0,this.numConsolidated=0,this.isCancelled=!1,this.handleChunk=this.handleChunk.bind(this),this.handleError=this.handleError.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.handleCreateTable=this.handleCreateTable.bind(this),this.config={delimiter:a.delimiter,newline:a.newline,escapeChar:a.escapeChar,dynamicTyping:!1,error:this.handleError,skipEmptyLines:a.skipEmptyLines,chunk:this.handleChunk,complete:this.handleComplete,fastMode:!1}}cancel(){this.isCancelled=!0}transpose(e,t){for(var n=t.length,r=new Array(e).fill(null).map(()=>new Array(n)),a=0;a<n;a+=1){var s=t[a];if(s.length<e)throw new Error("Insufficient columns. Expected ".concat(e," but found ").concat(s.length,`
5
+ `).concat(s));for(var o=0;o<e;o+=1){var d=this.type.shouldTrim?t[a][o].trim():t[a][o];r[o][a]=this.nullCheck(d)}}return r}nullCheck(e){return e===this.type.nullString?"":e}parse(){var e=(n,r)=>{if(this.types=n,this.rowCount=r,this.file instanceof File||this.file instanceof Blob)Pt.parse(this.file,this.config);else{var a=sr(this.file,this.handleNodeUpdate);Pt.parse(a,this.config),a.resume()}},t=new Ts(e,this.file,this.readHeaders,this.config,this.type.nullString,this.onProgress,this.onError,this.totalChunks,this.isZip,this.type.shouldTrim);t.parse()}handleChunk(e,t){var{readHeaders:n,onError:r,handleCreateTable:a,isZip:s,tables:o}=this;if(this.isCancelled){$t.debug2("CSV parser cancelled."),t.abort(),o.forEach(v=>v.close());return}var{data:d}=e;this.headers||(n?(this.headers=Zi.legalizeColumnNames(d[0]),d=d.slice(1)):this.headers=mt.generateHeaders(d[0].length));var h=[];try{if(h=this.transpose(this.headers.length,d),s)this.consolidateChunks(h,t);else{var u=this.chunks;this.chunks+=1,a(u,h,t)}}catch(v){r(v)}}consolidateChunks(e,t){if(!this.consolidatedChunks)this.consolidatedChunks=e.slice();else for(var n=0;n<e.length;n+=1)this.consolidatedChunks[n]=this.consolidatedChunks[n].concat(e[n]);this.numConsolidated+=1,(this.numConsolidated>=ws||this.isComplete)&&this.uploadConsolidatedChunks(t)}uploadConsolidatedChunks(e){var t,{handleCreateTable:n}=this,r=this.chunks;this.chunks+=1;var a=(t=this.consolidatedChunks)===null||t===void 0?void 0:t.slice();this.consolidatedChunks=void 0,this.numConsolidated=0,D(a),n(r,a,e)}handleCreateTable(e,t,n){var{session:r,tables:a,onFileCompleted:s,totalChunks:o,types:d,onProgress:h,onError:u}=this;n&&n.pause(),D(this.headers),D(d),this.rowsProcessed+=t[0].length,r.newTable(this.headers,d,t,this.timeZone).then(v=>{if(this.isCancelled){$t.debug2("CSV parser cancelled."),n&&n.abort(),a.forEach(p=>p.close());return}n&&n.resume(),a[e]=v;var m=0;o>0?m=Math.round(a.length/o*50)+50:m=Math.round(this.rowsProcessed/this.rowCount*50)+50,$t.debug2("CSV parser progress ".concat(m)),h(m),this.isComplete&&a.length===this.chunks&&($t.debug2("CSV parser complete."),s(a))}).catch(v=>{!this.isComplete&&n&&n.abort(),u(v)})}handleComplete(e){(e==null||e.meta.aborted==null)&&(this.isComplete=!0,this.consolidatedChunks&&this.uploadConsolidatedChunks(null))}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}J(mt,"generateHeaders",i=>{for(var e=[],t=0;t<i;t+=1)e.push(mt.generateHeaderRecursive(t));return e});const Ns=mt;function Ln(i,e,t){return e=xs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xs(i){var e=Ds(i,"string");return typeof e=="symbol"?e:String(e)}function Ds(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class nn{static fromExtension(e){return e.endsWith(".csv")?"DEFAULT_CSV":e.endsWith(".tsv")||e.endsWith(".tab")?"TSV":e.endsWith(".psv")?"PIPE_SV":"AUTODETECT"}}Ln(nn,"DEFAULT_TYPE","DEFAULT_CSV");Ln(nn,"AUTO","AUTODETECT");Ln(nn,"TYPES",Object.freeze({DEFAULT_CSV:{name:"Default csv (trimmed)",delimiter:",",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},TSV:{name:"Tab seperated (tsv)",delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},APACHE_COMMON_CSV:{name:"Apache Common csv",delimiter:",",newline:`\r
6
+ `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:null},EXCEL_CSV:{name:"Excel csv (strict)",delimiter:",",newline:`\r
7
+ `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},MY_SQL_CSV:{name:"MySQL csv",delimiter:" ",newline:`
8
+ `,escapeChar:"\\",shouldTrim:!0,skipEmptyLines:!1,nullString:"\\N"},RFC4180_CSV:{name:"RFC4180 csv",delimiter:",",newline:`\r
9
+ `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},COLON_SV:{name:": colon sv",delimiter:":",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SEMI_COLON_SV:{name:"; semi-colon sv",delimiter:";",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},PIPE_SV:{name:"| pipe separated (psv)",delimiter:"|",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SPACE_SV:{name:'" " space sv',delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},AUTODETECT:{name:"autodetect",delimiter:void 0,newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"}}));const Et=nn;function or(i,e,t){return e=Ls(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ls(i){var e=Rs(i,"string");return typeof e=="symbol"?e:String(e)}function Rs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ei=Q.module("CsvInputBar"),Is=Object.entries(Et.TYPES).map(i=>{var[e,t]=i;return l.jsx("option",{value:e,children:t.name},e)});class lr extends c.Component{constructor(e){super(e),or(this,"inputRef",void 0),this.handleUpload=this.handleUpload.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleError=this.handleError.bind(this),this.handleTableName=this.handleTableName.bind(this),this.toggleFirstRowHeaders=this.toggleFirstRowHeaders.bind(this),this.handleProgress=this.handleProgress.bind(this),this.handleCancelInProgress=this.handleCancelInProgress.bind(this),this.handleQueryTypeChange=this.handleQueryTypeChange.bind(this),this.inputRef=ae.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:Et.DEFAULT_TYPE,parser:null}}componentDidUpdate(e){var{file:t,paste:n}=this.props,{tableName:r,tableNameSet:a}=this.state;if(!a&&t!=null&&!r){var s,o=t.name.lastIndexOf("."),d=Zi.legalizeTableName(t.name.substring(0,o));this.setState({tableName:d,tableNameSet:!0}),(s=this.inputRef.current)===null||s===void 0||s.focus()}else(t==null&&e.file!=null||n==null&&e.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});n!=null&&n!==""&&!r&&this.inputRef.current&&this.inputRef.current.focus(),t!=null&&t!==e.file?this.setState({type:Et.fromExtension(t.name)}):n!=null&&n!==""&&(e.paste===void 0||e.paste==="")&&this.setState({type:Et.AUTO})}componentWillUnmount(){var{parser:e}=this.state;e&&e.cancel()}handleCancel(){var{onClose:e}=this.props;e()}handleError(e){var{onClose:t,onError:n}=this.props;ei.error(e),n(e),t()}handleTableName(e){this.setState({tableName:e.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){var{isFirstRowHeaders:e}=this.state;this.setState({isFirstRowHeaders:!e})}handleUpload(e){e.stopPropagation(),e.preventDefault();var{file:t,paste:n}=this.props;t!=null?t.name.endsWith(".zip")?this.handleZipFile(t):this.handleFile(t):n!==void 0&&n!==""&&this.handleFile(new Blob([n],{type:"text/plain"}))}handleFile(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;ei.info("Starting CSV parser for ".concat(e instanceof File?e.name:"pasted values"," ").concat(t?"":e.size," bytes"));var{session:n,timeZone:r,onInProgress:a}=this.props,{tableName:s,isFirstRowHeaders:o,type:d}=this.state,h=v=>{v.length===1?n.bindTableToVariable(v[0],s).then(()=>this.openTable()).catch(m=>this.handleError(m)):n.mergeTables(v).then(m=>{n.bindTableToVariable(m,s).then(()=>this.openTable()).catch(p=>this.handleError(p)),v.forEach(p=>p.close())}).catch(m=>this.handleError(m))},u=new Ns({onFileCompleted:h,session:n,file:e,type:Et.TYPES[d],readHeaders:o,onProgress:this.handleProgress,onError:this.handleError,timeZone:r,isZip:t});u.parse(),this.setState({showProgress:!0,parser:u}),a(!0)}handleZipFile(e){var{onUpdate:t,unzip:n}=this.props;if(n==null){this.handleError(new Error("No support for zip files available."));return}n(e).then(r=>{for(var a=!1,s=0;s<r.length;s+=1){var o=r[s];if(ct.isValidExtension(o.name)){t("Loading ".concat(o.name," as csv from ").concat(e.name)),a=!0,this.handleFile(o,!0);break}}if(!a)throw new Error("No csv file found in ".concat(e.name))}).catch(r=>this.handleError(r))}handleProgress(e){var{showProgress:t}=this.state;return t&&this.setState({progressValue:e}),!t}handleCancelInProgress(){var{onInProgress:e}=this.props,{parser:t}=this.state;t&&t.cancel(),this.setState({showProgress:!1,progressValue:0}),e(!1)}openTable(){var{onOpenTable:e,onClose:t}=this.props,{tableName:n}=this.state;e(n),t()}handleQueryTypeChange(e){this.setState({type:e})}render(){var{file:e,paste:t}=this.props,{tableName:n,isFirstRowHeaders:r,showProgress:a,progressValue:s,type:o}=this.state,d=!!t&&!n;return l.jsxs("div",{className:"csv-input-bar",children:[!a&&l.jsxs("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"tableNameInput",children:"Table name"}),l.jsx("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:ee("form-control",{"is-invalid":d}),value:n,onChange:this.handleTableName})]}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"formatSelect",children:"File format"}),l.jsx(Oa,{id:"formatSelect",className:"custom-select",value:o,onChange:this.handleQueryTypeChange,children:Is})]}),l.jsx(wa,{className:"firstRowHeaders",checked:r,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),l.jsxs("div",{className:"csv-input-buttons form-group",children:[l.jsx(K,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",disabled:!(e!==null||t!==void 0&&t!=="")||!n,children:"Upload"})]})]}),a&&l.jsxs("div",{className:"csv-progress-container",children:[l.jsx("label",{children:"Uploading Table"}),l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-primary",style:{width:"".concat(s,"%")},"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100})}),l.jsxs("label",{children:[s,"%"]}),l.jsx(K,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}or(lr,"defaultProps",{file:null,paste:null,unzip:null});const Ms=lr;function Bt(i,e,t){return e=Fs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Fs(i){var e=As(i,"string");return typeof e=="symbol"?e:String(e)}function As(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ti=Q.module("ConsoleMenu");class Jt extends c.PureComponent{static makeItemActions(e,t,n,r,a){if(e.length===0)return[];var s={menuElement:l.jsx(Xi,{value:t,onChange:r,className:"console-menu",ref:n})},o=e;t&&(o=o.filter(h=>{var{title:u}=h;return u!=null&&u.toLowerCase().indexOf(t.toLowerCase())>=0}));var d=o.map(h=>({title:h.title,action:()=>{a(h)}}));return[s,...d]}constructor(e){super(e),Bt(this,"tableSearchField",void 0),Bt(this,"widgetSearchField",void 0),Bt(this,"makeTableActions",_e((t,n,r)=>{var{dh:a}=this.props,s=t.filter(o=>Cn.isTableType(a,o.type));return Jt.makeItemActions(s,n,o=>{this.tableSearchField=o},this.handleTableFilterChange,r)})),Bt(this,"makeWidgetActions",_e((t,n,r)=>{var{dh:a}=this.props,s=t.filter(o=>Cn.isWidgetType(a,o.type));return Jt.makeItemActions(s,n,o=>{this.widgetSearchField=o},this.handleWidgetFilterChange,r)})),this.handleTableFilterChange=this.handleTableFilterChange.bind(this),this.handleTableMenuClosed=this.handleTableMenuClosed.bind(this),this.handleTableMenuOpened=this.handleTableMenuOpened.bind(this),this.handleWidgetFilterChange=this.handleWidgetFilterChange.bind(this),this.handleWidgetMenuClosed=this.handleWidgetMenuClosed.bind(this),this.handleWidgetMenuOpened=this.handleWidgetMenuOpened.bind(this),this.state={tableFilterText:"",widgetFilterText:""}}handleTableFilterChange(e){ti.debug("filtering tables..."),this.setState({tableFilterText:e.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){var e;(e=this.tableSearchField)===null||e===void 0||e.focus()}handleWidgetFilterChange(e){ti.debug("filtering widgets..."),this.setState({widgetFilterText:e.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){var e;(e=this.widgetSearchField)===null||e===void 0||e.focus()}render(){var{overflowActions:e,objects:t,openObject:n}=this.props,{tableFilterText:r,widgetFilterText:a}=this.state,s=this.makeTableActions(t,r,n),o=this.makeWidgetActions(t,a,n),d={placement:"bottom-end"},h=s.length===0,u=o.length===0;return l.jsxs(l.Fragment,{children:[l.jsx(K,{kind:"ghost",disabled:h,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:Vi,icon:St,transform:"right-5 down-5"}),l.jsx(re,{icon:St,transform:"right-8 down-6"})]}),tooltip:h?"No tables available":"Tables",children:l.jsx(wt,{actions:s,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions ")}),l.jsx(K,{kind:"ghost",disabled:o.length===0,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:Bi,icon:St,transform:"right-5 down-5"}),l.jsx(re,{icon:St,transform:"right-8 down-6"})]}),tooltip:u?"No widgets available":"Widgets",children:l.jsx(wt,{actions:o,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions")}),l.jsx(K,{kind:"ghost",icon:zi,tooltip:"More Actions...","aria-label":"More Actions...",onClick:()=>{},children:l.jsx(wt,{actions:e,popperOptions:d})})]})}}const js=Jt;function dr(i,e,t){return e=_s(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _s(i){var e=ks(i,"string");return typeof e=="symbol"?e:String(e)}function ks(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class hr extends c.PureComponent{constructor(e){super(e),dr(this,"pending",void 0),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new gt,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}startListening(){var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(e){var{result:t}=e.detail;this.pending.add(t).then(()=>this.handleCommandCompleted(null)).catch(n=>this.handleCommandCompleted(n)),this.setState({isCommandRunning:!0})}handleCommandCompleted(e){e instanceof Na||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){var{children:e,dh:t,openObject:n,overflowActions:r,objects:a}=this.props,{isDisconnected:s,isCommandRunning:o}=this.state,d=null,h=null;return s?(d="console-status-icon-disconnected",h="Worker is disconnected"):o?(d="console-status-icon-pending",h="Worker is busy"):(d="console-status-icon-idle",h="Worker is idle"),l.jsxs("div",{className:"console-pane-status-bar",children:[l.jsxs("div",{children:[l.jsx("div",{className:ee("console-status-icon",d)}),l.jsx(lt,{children:h})]}),e,l.jsx(js,{dh:t,overflowActions:r,openObject:n,objects:a})]})}}dr(hr,"defaultProps",{children:null});const Hs=hr;function ni(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ne(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ni(Object(t),!0).forEach(function(n){Pe(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ni(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Pe(i,e,t){return e=Us(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Us(i){var e=$s(i,"string");return typeof e=="symbol"?e:String(e)}function $s(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Re=Q.module("Console"),ii={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0};function Bs(){return!0}function Vs(i){return l.jsx(l.Fragment,{})}class Xe extends c.PureComponent{static isErrorLevel(e){return e===de.STDERR||e===de.ERROR||e===de.FATAL}static isOutputLevel(e){return e===de.STDOUT||Xe.isErrorLevel(e)}constructor(e){super(e),Pe(this,"cancelListener",void 0),Pe(this,"consolePane",void 0),Pe(this,"consoleInput",void 0),Pe(this,"consoleHistoryScrollPane",void 0),Pe(this,"pending",void 0),Pe(this,"queuedLogMessages",void 0),Pe(this,"processLogMessageQueue",Hi(()=>{this.scrollConsoleHistoryToBottom(),this.setState(r=>{Re.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");var{consoleHistory:a}=r;return a=a.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:a}})},Xe.LOG_THROTTLE)),Pe(this,"getObjects",_e(r=>[...r.values()])),Pe(this,"getContextActions",_e(r=>[...r,{action:this.handleClearShortcut,shortcut:be.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:be.CONSOLE.FOCUS_HISTORY}])),this.handleCommandResult=this.handleCommandResult.bind(this),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandSubmit=this.handleCommandSubmit.bind(this),this.handleClearShortcut=this.handleClearShortcut.bind(this),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleOverflowActions=this.handleOverflowActions.bind(this),this.handleScrollPaneScroll=this.handleScrollPaneScroll.bind(this),this.handleToggleAutoLaunchPanels=this.handleToggleAutoLaunchPanels.bind(this),this.handleToggleClosePanelsOnDisconnect=this.handleToggleClosePanelsOnDisconnect.bind(this),this.handleTogglePrintStdout=this.handleTogglePrintStdout.bind(this),this.handleUploadCsv=this.handleUploadCsv.bind(this),this.handleHideCsv=this.handleHideCsv.bind(this),this.handleCsvFileCanceled=this.handleCsvFileCanceled.bind(this),this.handleCsvFileOpened=this.handleCsvFileOpened.bind(this),this.handleCsvPaste=this.handleCsvPaste.bind(this),this.handleDragEnter=this.handleDragEnter.bind(this),this.handleDragLeave=this.handleDragLeave.bind(this),this.handleClearDragError=this.handleClearDragError.bind(this),this.handleOpenCsvTable=this.handleOpenCsvTable.bind(this),this.handleCsvUpdate=this.handleCsvUpdate.bind(this),this.handleCsvError=this.handleCsvError.bind(this),this.handleCsvInProgress=this.handleCsvInProgress.bind(this),this.consolePane=ae.createRef(),this.consoleInput=ae.createRef(),this.consoleHistoryScrollPane=ae.createRef(),this.pending=new gt,this.queuedLogMessages=[];var{objectMap:t,settings:n}=this.props;this.state=Ne(Ne({consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1},ii),n)}componentDidMount(){this.initConsoleLogging();var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){var{props:n,state:r}=this;this.sendSettingsChange(t,r),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}initConsoleLogging(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}deinitConsoleLogging(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}handleClearShortcut(e){var t;e.preventDefault(),e.stopPropagation(),(t=this.consoleInput.current)===null||t===void 0||t.clear()}handleCommandStarted(e){var{code:t,result:n}=e.detail,r=this.pending.add(n),a={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:r},{commandHistoryStorage:s,language:o,scope:d}=this.props,h=s.addItem(o,d,t,{command:t,startTime:new Date().toJSON()});h.catch(u=>{Re.debug("Error adding workspace item",u)}),this.setState(u=>({consoleHistory:u.consoleHistory.concat(a)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),r.then(u=>{this.handleCommandResult(u,a,h)}).catch(u=>{this.handleCommandError(u,a,h)})}handleCommandResult(e,t,n){var r=Ne(Ne({},t),{},{wrappedResult:void 0,cancelResult:void 0,result:e??t.result});this.setState(a=>{var{consoleHistory:s}=a,o=s.lastIndexOf(t);if(o<0)return Re.error("historyItem not found in consoleHistory"),null;var d=s.concat();return d[o]=r,{consoleHistory:d}}),e&&(this.updateHistory(e,r),this.updateKnownObjects(r),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){if(ce.isCanceled(e)){Re.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:"".concat(e)},n),this.setState(r=>{var a=r.consoleHistory.concat(),s=a.lastIndexOf(t),o=Ne({},t);return o.wrappedResult=void 0,o.cancelResult=void 0,o.endTime=Date.now(),o.result={error:e},a[s]=o,{consoleHistory:a}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();var{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){var{isPrintStdOutEnabled:t}=this.state;t&&Xe.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){var n={};Xe.isErrorLevel(t)?n.error=e:n.message=e;var r={command:void 0,result:n};this.queuedLogMessages.push(r),this.processLogMessageQueue()}openUpdatedItems(e){Re.debug("openUpdatedItems",e);var{isAutoLaunchPanelsEnabled:t}=this.state;if(e!=null){var{openObject:n}=this.props;[...e.created,...e.updated].forEach(r=>n(r,t&&(r.title===void 0||!r.title.startsWith("_"))))}}closeRemovedItems(e){if(!(e==null||e.removed==null||e.removed.length===0)){var{closeObject:t}=this.props,{removed:n}=e;n.forEach(r=>t(r))}}updateHistory(e,t){var n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(r=>{var a=r.consoleHistory.concat();return{consoleHistory:a}}))}updateKnownObjects(e){var t;if(e.result&&(t=e.result.changes),!t||(t.created==null||t.created.length===0)&&(t.updated==null||t.updated.length===0)&&(t.removed==null||t.removed.length===0)){Re.debug2("updateKnownObjects no changes");return}this.setState(n=>{var r,a,s,{consoleHistory:o}=n,d=o.lastIndexOf(e);if(d<0)return Re.error("historyItem not found in state.consoleHistory"),null;var h=new Map(n.objectHistoryMap),u=new Map(n.objectMap),v=function(p){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{title:S}=p;D(S);var g=h.get(S);if(g!=null&&g>=0){var y;o===n.consoleHistory&&(o=o.concat());var P=Ne(Ne({},o[g]),{},{disabledObjects:[...(y=o[g].disabledObjects)!==null&&y!==void 0?y:[],S]});o[g]=P}h.set(S,d),E?u.delete(S):u.set(S,p)};return(r=t)===null||r===void 0||r.updated.forEach(m=>v(m)),(a=t)===null||a===void 0||a.removed.forEach(m=>v(m,!0)),(s=t)===null||s===void 0||s.created.forEach(m=>{var{title:p}=m;D(p),h.set(p,d),u.set(p,m)}),{objectHistoryMap:h,objectMap:u,consoleHistory:o}})}updateObjectMap(){var{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){var n=this.pending.add(t),r=new Date().toJSON();n.then(a=>{var s=Ne(Ne({},a),{},{data:Ne(Ne({},a.data),{},{endTime:r,result:e})}),{commandHistoryStorage:o,language:d}=this.props;o.updateItem(d,s).catch(h=>{Re.warn("Error updating command history storage",h)})}).catch(a=>{Re.debug("Error updating workspace history item",a)})}scrollConsoleHistoryToBottom(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.consoleHistoryScrollPane.current;D(t),!(!e&&Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)>=1)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){var e=this.consoleHistoryScrollPane.current;D(e),e.scrollTop>0&&e.scrollHeight>e.clientHeight?this.setState({isScrollDecorationShown:!0}):this.setState({isScrollDecorationShown:!1})}handleToggleAutoLaunchPanels(){this.setState(e=>({isAutoLaunchPanelsEnabled:!e.isAutoLaunchPanelsEnabled}))}handleToggleClosePanelsOnDisconnect(){this.setState(e=>({isClosePanelsOnDisconnectEnabled:!e.isClosePanelsOnDisconnectEnabled}))}handleTogglePrintStdout(){this.setState(e=>({isPrintStdOutEnabled:!e.isPrintStdOutEnabled}))}handleUploadCsv(){this.setState({showCsvOverlay:!0,dragError:null,csvUploadInProgress:!1})}handleHideCsv(){this.setState({showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1})}handleCsvFileCanceled(){this.setState({csvFile:null,csvPaste:null})}handleCsvFileOpened(e){this.setState({csvFile:e,csvPaste:null})}handleCsvPaste(e){this.setState({csvFile:null,csvPaste:e})}handleDragEnter(e){if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0||e.dataTransfer.items[0].kind==="string")){e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});var{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:ct.MULTIPLE_FILE_ERROR});return}var n=t[0];ct.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:ct.FILE_TYPE_ERROR})}}handleDragLeave(e){e.currentTarget==null||e.currentTarget instanceof Element&&e.relatedTarget instanceof Element&&e.currentTarget.contains(e.relatedTarget)||(e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!1,dragError:null}))}handleClearDragError(){this.setState({dragError:null})}handleOpenCsvTable(e){var{dh:t,openObject:n,commandHistoryStorage:r,language:a,scope:s}=this.props,{consoleHistory:o,objectMap:d}=this.state,h={name:e,title:e,type:t.VariableType.TABLE},u=d.has(e),v={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[u?"updated":"created"]:[h]}}},m=o.concat(v);this.setState({consoleHistory:m}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(v),n({name:e,title:e,type:t.VariableType.TABLE}),r.addItem(a,s,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){var{consoleHistory:n}=this.state,r={startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},a=n.concat(r);this.setState({consoleHistory:a})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?"".concat(e):void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){var{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:r}=this.props;return[...r,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:k.groups.high,icon:n?Ot:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:k.groups.high,icon:e?Ot:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:k.groups.high,icon:t?Ot:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:k.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){var{session:t}=this.props;t.runCode(e).catch(r=>{Re.error("There was an error initiating the command",r)})}else{var n={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(r=>({consoleHistory:r.consoleHistory.concat(n)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{var t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}addCommand(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.consoleInput.current&&(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){var e;(e=this.consoleInput.current)===null||e===void 0||e.focus()}sendSettingsChange(e,t){for(var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=Object.keys(ii),a={},s=!1,o=0;o<r.length;o+=1){var d=r[o],{[d]:h}=t,{[d]:u}=e;h!==u&&(s=!0),a[d]=h}if(!(n&&!s)){var{onSettingsChange:v}=this.props;v(a)}}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){var{actions:e,dh:t,historyChildren:n,language:r,statusBarChildren:a,openObject:s,session:o,scope:d,commandHistoryStorage:h,timeZone:u,disabled:v,unzip:m,supportsType:p,iconForType:E}=this.props,{consoleHeight:S,consoleHistory:g,isScrollDecorationShown:y,objectMap:P,showCsvOverlay:O,csvFile:L,csvPaste:V,dragError:Z,csvUploadInProgress:A}=this.state,z=this.getObjects(P),G=Math.round(S*.7),X=this.getContextActions(e);return l.jsxs("div",{role:"presentation",className:ee("iris-console","h-100","w-100",{disabled:v}),children:[l.jsxs("div",{className:"console-pane",ref:this.consolePane,children:[l.jsx(Hs,{dh:t,session:o,overflowActions:this.handleOverflowActions,openObject:s,objects:z,children:a}),l.jsxs("div",{className:"console-csv-container",onDragOver:ct.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[O&&l.jsx(ct,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:Z,onError:this.handleCsvError,uploadInProgress:A,allowZip:m!=null}),l.jsxs("div",{role:"presentation",className:ee("scroll-pane no-scroll-x",{"scroll-decoration":y}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[l.jsx(is,{items:g,openObject:s,language:r,disabled:v,supportsType:p,iconForType:E}),n]})]}),!O&&l.jsx(Gn,{ref:this.consoleInput,session:o,language:r,scope:d,onSubmit:this.handleCommandSubmit,maxHeight:G,commandHistoryStorage:h}),O&&l.jsx(Ms,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:L??void 0,paste:V??void 0,onInProgress:this.handleCsvInProgress,timeZone:u,unzip:m})]}),l.jsx(k,{actions:X,ignoreClassNames:[Gn.INPUT_CLASS_NAME]})]})}}Pe(Xe,"defaultProps",{statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null,supportsType:Bs,iconForType:Vs});Pe(Xe,"LOG_THROTTLE",500);const Ws=Xe;var Ks={groovy:"Groovy",python:"Python",scala:"Scala"};class Gs{static normalizeScriptLanguage(e){return Ks[e]||null}static getDisabledRunTooltip(e,t,n,r){return e?t?null:"".concat(n," doesn't match the session language – ").concat(r," disabled"):"Console session not connected – ".concat(r," disabled")}static outdentCode(e){var t=e.split(`
10
+ `),n=t.reduce((r,a)=>{var s=a.length-a.trimStart().length;return s===a.length?r:s<r?s:r},Number.MAX_SAFE_INTEGER);return t.map(r=>r.slice(n)).join(`
11
+ `)}}const En=Gs;function yt(i,e,t){return e=zs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function zs(i){var e=Ys(i,"string");return typeof e=="symbol"?e:String(e)}function Ys(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ye=Q.module("ScriptEditor");class ur extends c.Component{constructor(e){super(e),yt(this,"contextActionCleanups",void 0),yt(this,"completionCleanup",void 0),yt(this,"editor",void 0),yt(this,"editorComponent",void 0),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleRun=this.handleRun.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.updateShortcuts=this.updateShortcuts.bind(this),this.contextActionCleanups=[],this.editorComponent=ae.createRef(),this.state={model:null}}componentDidMount(){Ce.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(e){var t,n,{sessionLanguage:r,settings:a}=this.props,s=a?.language,o=s!==((t=e.settings)===null||t===void 0?void 0:t.language);o&&(ye.debug("Set language",s),this.setLanguage(s));var d=r==null&&e.sessionLanguage!=null,h=s===r,u=((n=e.settings)===null||n===void 0?void 0:n.language)===e.sessionLanguage;(d||r!==void 0&&u&&!h)&&(ye.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion());var v=r!=null&&e.sessionLanguage==null;(v&&h||r!==void 0&&!u&&h)&&(ye.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){Ce.removeEventListener("onUpdate",this.updateShortcuts)}getValue(){return this.editor?this.editor.getValue():(ye.error("Editor not initialized"),null)}getSelectedCommand(){var e,t,n=(e=this.editor)===null||e===void 0?void 0:e.getSelection();D(n);var r=(t=this.editor)===null||t===void 0?void 0:t.getModel();D(r);var{startLineNumber:a,endColumn:s}=n,{endLineNumber:o}=n;s===1&&o>a&&(o-=1);var d=r.getLineMinColumn(a),h=r.getLineMaxColumn(o),u=n.setStartPosition(a,d).setEndPosition(o,h);return En.outdentCode(r.getValueInRange(u))}handleEditorInitialized(e){var{focusOnMount:t,onChange:n,onEditorInitialized:r,settings:a,session:s,sessionLanguage:o}=this.props;ye.debug("handleEditorInitialized",o,s,a),this.editor=e,this.setState({model:this.editor.getModel()}),Oe.setEOL(e),Oe.registerPasteHandler(e),s!=null&&a&&o===a.language&&(this.initContextActions(),this.initCodeCompletion()),e.onDidChangeModelContent(n),t!=null&&t&&e.focus(),r(this.editor)}handleEditorWillDestroy(e){ye.debug("handleEditorWillDestroy");var{onEditorWillDestroy:t}=this.props;t(e),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){var{onRunCommand:e}=this.props,t=this.getValue();t!=null&&e(t)}handleRunSelected(){var{onRunCommand:e}=this.props,t=this.getSelectedCommand();e(t)}initContextActions(){if(this.contextActionCleanups.length>0){ye.error("Context actions already initialized.");return}if(this.editor){var e=[];e.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),e.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=e}}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(e=>e.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){ye.error("Code completion already initialized.");return}var{session:e}=this.props;ye.debug("initCodeCompletion",this.editor,e),this.editor&&e!=null&&(this.completionCleanup=Oe.openDocument(this.editor,e))}deInitCodeCompletion(){var{session:e}=this.props;ye.debug("deInitCodeCompletion",this.editor,e),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&e!=null&&Oe.closeDocument(this.editor,e))}append(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;D(this.editor);var n=this.editor.getModel();D(n);var r=n.getValue();r?n.setValue("".concat(r,`
12
+ `).concat(e)):n.setValue("".concat(e));var a=n.getLineCount(),s=n.getLineLength(a)+1;this.editor.setPosition({lineNumber:a,column:s}),t&&this.editor.focus()}updateDimensions(){ye.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){ye.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(e){this.editorComponent.current&&e!==void 0&&this.editorComponent.current.setLanguage(e)}render(){var e,{error:t,isLoaded:n,isLoading:r,session:a,sessionLanguage:s,settings:o}=this.props,{model:d}=this.state,h=t?"Unable to open document. ".concat(t):null,u=o&&(e=o.language)!==null&&e!==void 0?e:null,v=d&&a&&u===s;return l.jsxs(l.Fragment,{children:[(t||r)&&l.jsx("div",{className:"h-100 w-100 position-relative",children:l.jsx(wn,{errorMessage:h,isLoading:r,isLoaded:n})}),n&&l.jsx("div",{className:"h-100 w-100 script-editor",children:o&&l.jsxs(l.Fragment,{children:[l.jsx(xa,{ref:this.editorComponent,settings:o,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),v!=null&&v&&l.jsx(ir,{model:d,language:u,session:a})]})})]})}}yt(ur,"defaultProps",{error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null});const qs=ur;function Tt(i,e,t){return e=Zs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Zs(i){var e=Xs(i,"string");return typeof e=="symbol"?e:String(e)}function Xs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Qs=250,Js=2500;class rn extends c.Component{static getTimeString(e,t){if(e==null||t===""||t===0)return null;var n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":qi.formatElapsedTime(n)}constructor(e){super(e),Tt(this,"timer",void 0),Tt(this,"cleanup",void 0),Tt(this,"loadData",Lt(()=>{var{commandHistoryStorage:t,item:n,language:r}=this.props,{id:a}=n;this.cleanup=t.listenItem(r,a,this.handleUpdate,this.handleError)},Qs)),Tt(this,"getPreviewText",Ur(t=>t.split(`
13
+ `,Js).join(`
14
+ `),{max:1})),this.handleUpdate=this.handleUpdate.bind(this),this.handleError=this.handleError.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.state={currentTime:Date.now()}}componentDidMount(){this.loadData()}componentDidUpdate(e,t){var n,{data:r}=this.state;this.timer==null&&!(r!=null&&r.result)&&r?.startTime&&!(r==null||r.endTime===void 0)?this.startTimer():(r!=null&&r.result&&!((n=t.data)!==null&&n!==void 0&&n.result)||r?.endTime&&!(t.data==null||t.data.endTime===void 0))&&this.stopTimer()}componentWillUnmount(){this.loadData.cancel(),this.cleanup!=null&&this.cleanup(),this.stopTimer()}startTimer(){this.stopTimer(),this.timer=setInterval(this.handleTimeout,1e3)}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}updateTime(){this.setState({currentTime:Date.now()})}handleError(e){this.setState({error:"".concat(e)})}handleUpdate(e){var{data:t}=e??{};this.setState({data:t});var{onUpdate:n}=this.props;n?.(t)}handleTimeout(){this.updateTime()}render(){var e,{item:{name:t},language:n}=this.props,{currentTime:r,data:a,error:s}=this.state,{result:o,startTime:d,endTime:h}=a??{},u=(e=o?.error)!==null&&e!==void 0?e:s,v=rn.getTimeString(d,h??r),m=this.getPreviewText(t),p=!!v;return l.jsxs("div",{className:"command-history-item-tooltip",children:[l.jsxs("div",{className:"scroll-container",children:[l.jsx(Dn,{language:n,children:m}),m.length<t.length&&l.jsx("p",{children:"Preview Truncated..."})]}),l.jsxs("div",{className:"result-info",children:[l.jsxs("div",{className:"d-flex justify-content-between",children:[!!u&&l.jsxs("div",{className:"text-danger mr-1",children:[l.jsx(re,{icon:Gi})," Executed with errors"]}),l.jsxs("div",{className:"time-wrapper",children:["Elapsed time:"," ",p?l.jsx("span",{className:"time-string",children:v}):l.jsx(Wi,{className:"loading-spinner-vertical-align"})]})]}),!!u&&l.jsx("div",{className:"error-message",children:u})]})]})}}Tt(rn,"defaultProps",{onUpdate:()=>{}});const eo=rn;var to=512;function cr(i){var{item:e,language:t,isSelected:n,commandHistoryStorage:r}=i,a=e.name.substring(0,to),s=c.useRef(null),o=c.useCallback(()=>{var d;(d=s.current)===null||d===void 0||d.update()},[s]);return l.jsxs("div",{className:ee("command-history-item",{selected:n}),children:[a,l.jsx(lt,{ref:s,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:l.jsx(eo,{item:e,language:t,onUpdate:o,commandHistoryStorage:r})})]})}cr.defaultProps={isSelected:!1};class en extends c.Component{static itemKey(e,t){return"".concat(t.title)}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{icon:na,mask:e.icon,transform:"right-5 down-5 shrink-4"}),l.jsx(re,{icon:ia,transform:"shrink-3 right-7 down-6"})]}):l.jsx(re,{icon:e.icon})}render(){var{actions:e,hasSelection:t}=this.props;return l.jsx("div",{className:"command-history-actions",children:e.map((n,r)=>l.jsx(K,{kind:"inline",className:ee(n.className),onClick:n.action,tooltip:n.description,disabled:n.selectionRequired!==void 0&&n.selectionRequired&&!t,icon:en.renderContent(n)},en.itemKey(r,n)))})}}const no=en;var io=150,ri=3,ai=Q.module("CommandHistoryViewportUpdater");function ro(i){var{table:e,columns:t,top:n=0,bottom:r=0,search:a,isReversed:s=!1,onUpdate:o}=i,d=c.useMemo(()=>Hi(h=>{var u=h.bottom-h.top,v=Math.max(0,h.top-u*ri),m=h.bottom+u*ri;e.setViewport({top:v,bottom:m,columns:h.columns})},io),[e]);return c.useEffect(function(){var u=e.onUpdate(v=>{var m,p;o({items:(m=v.items)!==null&&m!==void 0?m:[],offset:(p=v.offset)!==null&&p!==void 0?p:0})});return()=>{ai.debug("onUpdate cleanup"),u()}},[e,o]),c.useEffect(function(){e.setSearch(a??"")},[e,a]),c.useEffect(function(){d({top:n,bottom:r,columns:t})},[d,n,r,t,a,s]),c.useEffect(()=>()=>{ai.debug2("Cancel throttledUpdateViewport"),d.cancel()},[d]),null}function si(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function oi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){si(a,n,r,s,o,"next",d)}function o(d){si(a,n,r,s,o,"throw",d)}s(void 0)})}}function Ae(i,e,t){return e=ao(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ao(i){var e=so(i,"string");return typeof e=="symbol"?e:String(e)}function so(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ye=Q.module("CommandHistory");class fe extends c.Component{static getCommandsFromViewport(e,t,n){for(var r=[],a=0;a<n.length;a+=1)for(var s=n[a],o=s[0];o<=s[1];o+=1)if(o>=t&&o<t+e.length){var{name:d}=e[o-t];r.push(d)}return r}static getCommandsFromSnapshot(e,t){return oi(function*(){var n=yield e.getSnapshot(t);return[...n.values()].map(r=>r.name)})()}constructor(e){super(e),Ae(this,"itemActions",void 0),Ae(this,"historyActions",void 0),Ae(this,"pending",void 0),Ae(this,"searchInputRef",void 0),Ae(this,"itemListRef",void 0),Ae(this,"debouncedSearchChange",Lt(()=>{this.setState(n=>{var{searchText:r}=n;return{debouncedSearchText:r,selectedRanges:[]}})},fe.SET_SEARCH_DEBOUNCE_MS)),this.copySelectedCommands=this.copySelectedCommands.bind(this),this.createNotebook=this.createNotebook.bind(this),this.sendToConsole=this.sendToConsole.bind(this),this.renderItem=this.renderItem.bind(this),this.runInConsole=this.runInConsole.bind(this),this.sendToNotebook=this.sendToNotebook.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleViewportUpdate=this.handleViewportUpdate.bind(this),this.itemActions=[{title:"Copy Selection",description:"Copy selected commands to clipboard",icon:ra,shortcut:Zt.COPY,action:this.copySelectedCommands,group:k.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:Hn,shortcut:be.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:fe.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:qt,shortcut:be.COMMAND_HISTORY.RUN,action:this.runInConsole,group:fe.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Un,shortcut:be.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:fe.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:Yi,action:this.createNotebook,group:fe.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:Hn,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Un,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new gt,this.searchInputRef=ae.createRef(),this.itemListRef=ae.createRef();var{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:"",debouncedSearchText:""}}componentWillUnmount(){this.debouncedSearchChange.cancel(),this.pending.cancel()}getSelectedCommands(){var e=this;return oi(function*(){var{items:t,offset:n,selectedRanges:r}=e.state,a=r.slice().sort((o,d)=>o[0]-d[0]);if(a.length===0)return[];if(a[0][0]>=n&&a[a.length-1][1]<n+t.length)return fe.getCommandsFromViewport(t,n,a);var{table:s}=e.props;return e.pending.add(fe.getCommandsFromSnapshot(s,a))})()}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
15
+ `))}updateActions(){this.setState(e=>{var{selectedRanges:t}=e,n=t.reduce((r,a)=>r+a[1]-a[0]+1,0);return n>0&&n<fe.MAX_SELECTION_COUNT?(Ye.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(Ye.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(Da).catch(Ye.error)}createNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(Ye.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(Ye.error)}sendToConsole(){var{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(Ye.error)}runInConsole(){this.getSelectedCommandText().then(e=>{var{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(Ye.error)}handleSelect(e){var{sendToConsole:t}=this.props,{items:n,offset:r}=this.state;if(e<r||e>=r+n.length){Ye.error("Invalid index!",e);return}var{name:a}=n[e-r];t(a)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value}),this.debouncedSearchChange()}handleViewportUpdate(e){var{items:t,offset:n}=e,{table:r}=this.props,a=r.size;this.setState({items:t,itemCount:a,offset:n})}renderItem(e){var{item:t,itemIndex:n,isSelected:r}=e,{language:a,commandHistoryStorage:s}=this.props;return l.jsx(cr,{isSelected:r,item:t,language:a,commandHistoryStorage:s})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}restoreScrollPosition(){var e;(e=this.itemListRef.current)===null||e===void 0||e.restoreScrollPosition()}render(){var e,{language:t,table:n}=this.props,{actions:r,historyActions:a,searchText:s,debouncedSearchText:o,top:d,bottom:h,items:u,itemCount:v,offset:m,selectedRanges:p}=this.state,E=(e=Ji.LANGUAGE_MAP.get(t))!==null&&e!==void 0?e:"";return l.jsxs("div",{className:"command-history",children:[l.jsxs("div",{className:"command-history-search-bar",children:[l.jsx(Xi,{ref:this.searchInputRef,value:s,placeholder:"".concat(E," Command History"),onChange:this.handleSearchChange}),l.jsx(no,{actions:a,hasSelection:p.length>0})]}),l.jsxs("div",{className:"command-history-list",children:[l.jsx(bn,{ref:this.itemListRef,itemCount:v,items:u,offset:m,selectedRanges:p,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:fe.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),l.jsx(ro,{table:n,top:d,bottom:h,search:o,onUpdate:this.handleViewportUpdate}),l.jsx(k,{actions:r})]})]})}}Ae(fe,"ITEM_HEIGHT",29);Ae(fe,"MAX_SELECTION_COUNT",1e4);Ae(fe,"SET_SEARCH_DEBOUNCE_MS",150);Ae(fe,"menuGroups",{send:k.groups.medium+100});const oo=fe;class lo extends c.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){var{logLevel:e,onClick:t}=this.props;t(e)}render(){var{logLevel:e,on:t}=this.props;return l.jsxs("div",{className:ee("log-level-menu-item",e),children:[l.jsx(La,{on:t,onClick:this.handleSwitchClick}),e]})}}const ho=lo;function li(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function di(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?li(Object(t),!0).forEach(function(n){Ee(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):li(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Ee(i,e,t){return e=uo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function uo(i){var e=co(i,"string");return typeof e=="symbol"?e:String(e)}function co(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ne extends c.PureComponent{static getLogText(e){var t=new Date(e.micros/1e3),n=Cn.formatTimestamp(t);return"".concat(n," ").concat(e.logLevel," ").concat(e.message)}constructor(e){super(e),Ee(this,"cancelListener",void 0),Ee(this,"editor",void 0),Ee(this,"editorContainer",void 0),Ee(this,"logLevelMenuItems",void 0),Ee(this,"flushTimer",void 0),Ee(this,"bufferedMessages",void 0),Ee(this,"messages",void 0),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();var{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();var{session:r}=this.props;e.session!==r&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(e){var t=this,n=[];n.push({menuElement:l.jsx("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(var r=function(){var o=ne.AllLogLevels[a],d=e[o]!=null?e[o]:!1;n.push({title:o,group:1,order:a+100,menuElement:l.jsx(ho,{logLevel:o,on:d,onClick:t.handleMenuItemClick,ref:h=>{h!=null&&(t.logLevelMenuItems[o]=h)}})})},a=0;a<ne.AllLogLevels.length;a+=1)r();return n.push({group:1,order:1e3,menuElement:l.jsxs("div",{className:"log-level-menu-controls",children:[l.jsx(K,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),l.jsx(K,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),n}resetLogLevels(){for(var e={},t=function(){var a=ne.AllLogLevels[n],s=ne.DefaultLogLevels.some(o=>o===a);e[a]=s},n=0;n<ne.AllLogLevels.length;n+=1)t();this.setState({shownLogLevels:e})}startListening(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){D(this.editorContainer),this.editor=xn.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbers:"off",lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),[[xt.Escape],[Qi.Shift|xt.Escape]].forEach(e=>{D(this.editor),Oe.disableKeyBindings(this.editor,e),this.editor.addAction({id:"clear-selection-on-escape",label:"",keybindings:[xt.Escape],keybindingContext:"findWidgetVisible && editorTextFocus",run:()=>{var t,n,r=(t=this.editor)===null||t===void 0?void 0:t.getPosition();D(r),(n=this.editor)===null||n===void 0||n.setPosition(r)}})})}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var e,t;(e=this.editor)===null||e===void 0||e.focus(),(t=this.editor)===null||t===void 0||t.trigger("keyboard","actions.find",void 0)}toggleAll(){for(var{shownLogLevels:e}=this.state,t=!0,n=0;n<ne.AllLogLevels.length;n+=1){var r=ne.AllLogLevels[n];if(!e[r]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{for(var a={},s=0;s<ne.AllLogLevels.length;s+=1){var o=ne.AllLogLevels[s];a[o]=!0}this.setState({shownLogLevels:a})}}toggleLogLevel(e){var{shownLogLevels:t}=this.state,n=t[e],r={};r[e]=!n,this.updateLogLevels(r)}updateLogLevels(e){var{shownLogLevels:t}=this.state;t=di(di({},t),e),this.setState({shownLogLevels:t})}appendLogText(e){if(this.editor){var t=this.editor.getModel(),n=t?.getLineCount();D(n);var r=t?.getLineLength(n);D(r);var a=this.isBottomVisible(),s=[];if(r>0&&(s.push({range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:r+1},text:`
16
+ `,forceMoveMarkers:!0}),n+=1,r=0),s.push({range:{startLineNumber:n,startColumn:r,endLineNumber:n,endColumn:r},text:e,forceMoveMarkers:!0}),t?.applyEdits(s),a){var o=t?.getLineCount();D(o),this.editor.revealLine(o,1)}}}refreshLogText(){if(this.editor){this.truncateLogIfNecessary();for(var{shownLogLevels:e}=this.state,t=this.isBottomVisible(),n="",r=0;r<this.messages.length;r+=1){var a=this.messages[r];if(e[a.logLevel]){var s=ne.getLogText(a);s.length>0&&(n+=s,s.charAt(s.length-1)!==`
17
+ `&&(n+=`
18
+ `))}}if(n=n.trimRight(),this.editor.setValue(n),t){var o,d=(o=this.editor.getModel())===null||o===void 0?void 0:o.getLineCount();D(d),this.editor.revealLine(d,1)}this.stopFlushTimer(),this.bufferedMessages=[]}}truncateLogIfNecessary(){this.messages.length>ne.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-ne.truncateSize))}scrollToBottom(){var e,t,n;if(this.editor){var r=(e=this.editor)===null||e===void 0||(t=e.getModel)===null||t===void 0||(n=t.call(e))===null||n===void 0?void 0:n.getLineCount();D(r),this.editor.revealLine(r,1)}}isBottomVisible(){if(!this.editor)return!0;var e=this.editor.getModel(),t=e?.getLineCount();return D(t),this.isLineVisible(t)}isLineVisible(e){var t,n=(t=this.editor)===null||t===void 0?void 0:t.getVisibleRanges();if(n==null||n.length===0)return!1;for(var r=0;r<n.length;r+=1){var a=n[r];if(a.startLineNumber<=e&&e<=a.endLineNumber)return!0}return!1}isLogItemVisible(e){var{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){for(var e="",t=0;t<this.bufferedMessages.length;t+=1){var n=this.bufferedMessages[t],r=ne.getLogText(n);e+=r,r.charAt(r.length-1)!==`
19
+ `&&(e+=`
20
+ `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,ne.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){var e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(K,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:aa,tooltip:"Clear log"}),l.jsx(K,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:sa,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(wt,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:r=>{this.editorContainer=r}})]})}}Ee(ne,"DefaultLogLevels",[de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN]);Ee(ne,"AllLogLevels",[de.INFO,de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN,de.DEBUG,de.TRACE]);Ee(ne,"bufferTimeout",16);Ee(ne,"maxLogSize",131072);Ee(ne,"truncateSize",65536);const vo=ne;function hi(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function mo(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){hi(a,n,r,s,o,"next",d)}function o(d){hi(a,n,r,s,o,"throw",d)}s(void 0)})}}var po=Q.module("HeapUsage");function go(i){var e,{connection:t,defaultUpdateInterval:n,hoverUpdateInterval:r,bgMonitoring:a=!0,monitorDuration:s}=i,o=Ra(),[d,h]=c.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[u,v]=c.useState(!1),m=c.useRef({timestamps:[],usages:[]}),p=Ia(),E=c.useCallback(mo(function*(){try{var N=yield t.getWorkerHeapInfo();if(!p.current)return;if(h(N),a||u){for(var F=(N.totalHeapSize-N.freeMemory)/N.maximumHeapSize,I=Date.now(),{timestamps:oe,usages:Ge}=m.current;oe.length!==0&&I-oe[0]>s*1.5;)oe.shift(),Ge.shift();oe.push(I),Ge.push(F)}else m.current={timestamps:[],usages:[]}}catch(ze){po.warn("Unable to get heap usage",ze)}}),[t,p,a,u,s]);Ma(E,u?r:n);var S=(N,F)=>Math.round(N*10**F)/10**F,g=2,y=1024**3,{freeMemory:P,totalHeapSize:O,maximumHeapSize:L}=d,V=S(P/y,g),Z=S(O/y,g),A=S(L/y,g),z=Z-V,G=function(F,I){var oe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return l.jsxs("div",{className:ee("heap-usage-info-row",{"heading-bottom-border":oe}),children:[l.jsx("div",{className:"font-weight-bold",children:F}),l.jsx("div",{children:I})]})},{timestamps:X,usages:ve}=m.current,R=(e=X[X.length-1])!==null&&e!==void 0?e:0,$=O/L,H=(O-P)/L;return l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:"calc(".concat($*100,"% - ").concat($*2,"px")}}),l.jsx("div",{className:ee("used-memory",{"heap-overflow":(O-P)/L>.95}),style:{width:"calc(".concat(H*100,"% - ").concat(H*2,"px")}}),l.jsxs("div",{className:"memory-text",children:[A.toFixed(1)," GB"]}),l.jsx(lt,{onEntered:()=>v(!0),onExited:()=>v(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[G("In use:","".concat(z.toFixed(g)," of ").concat(A.toFixed(g)," GB"),!0),G("Free:","".concat(V.toFixed(g)," GB")),G("Total:","".concat(Z.toFixed(g)," GB")),G("Max:","".concat(A.toFixed(g)," GB")),l.jsx("div",{className:"heap-plot",children:l.jsx(Fa,{data:[{x:[...X],y:[...ve],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:o.linecolor,range:[R-s,R],linecolor:o.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:o.linecolor,range:[0,1],linecolor:o.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(s/1e3/60)," min."]})]})})]})}function ui(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function fo(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ui(Object(t),!0).forEach(function(n){bo(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ui(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function bo(i,e,t){return e=Co(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Co(i){var e=So(i,"string");return typeof e=="symbol"?e:String(e)}function So(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Rn=Object.freeze({}),Eo=new Map,Md=i=>i.api,Fd=i=>i.user,In=i=>i.storage,vr=i=>In(i).commandHistoryStorage,mr=i=>In(i).fileStorage,Ad=i=>In(i).workspaceStorage,yo=i=>i.defaultWorkspaceSettings,To=i=>{var{workspace:e}=i;return e},He=i=>{for(var e=To(i).data.settings,t=fo({},yo(i)),n=Object.keys(e),r=0;r<n.length;r+=1){var a=n[r];e[a]!==void 0&&(t[a]=e[a])}return t},jd=i=>i.defaultWorkspaceSettings,_d=i=>He(i).defaultDateTimeFormat,kd=i=>{var e;return(e=He(i).defaultDecimalFormatOptions)!==null&&e!==void 0?e:Rn},Hd=i=>{var e;return(e=He(i).defaultIntegerFormatOptions)!==null&&e!==void 0?e:Rn},Ud=i=>{var e;return(e=He(i).formatter)!==null&&e!==void 0?e:[]},Po=i=>He(i).timeZone,$d=i=>He(i).showTimeZone,Bd=i=>He(i).showTSeparator,Vd=i=>He(i).truncateNumbersWithPound,Wd=i=>He(i).shortcutOverrides,Oo=i=>{var e;return(e=He(i).defaultNotebookSettings)!==null&&e!==void 0?e:Rn},Kd=i=>i.activeTool,wo=i=>{var e;return(e=i.plugins)!==null&&e!==void 0?e:Eo},pr="SET_ACTIVE_TOOL",gr="SET_API",fr="SET_COMMAND_HISTORY_STORAGE",br="SET_FILE_STORAGE",Cr="SET_PLUGINS",Sr="SET_USER",Er="SET_WORKSPACE",yr="SET_DEFAULT_WORKSPACE_SETTINGS",Tr="SET_WORKSPACE_STORAGE",Pr="SET_SERVER_CONFIG_VALUES";function ci(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function tt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ci(Object(t),!0).forEach(function(n){No(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ci(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function No(i,e,t){return e=xo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xo(i){var e=Do(i,"string");return typeof e=="symbol"?e:String(e)}function Do(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Gd=i=>({type:Sr,payload:i}),zd=i=>({type:gr,payload:i}),Lo=i=>({type:Er,payload:i}),Yd=i=>({type:yr,payload:i}),qd=i=>({type:Tr,payload:i}),Zd=i=>({type:fr,payload:i}),Xd=i=>({type:br,payload:i}),Ro=i=>(e,t)=>{e(Lo(i));var{storage:n}=t(),{workspaceStorage:r}=n;return r.save(i)},Io=i=>(e,t)=>{var{workspace:n}=t(),{data:r}=n,a=tt(tt({},n),{},{data:tt(tt(tt({},r),i),{},{settings:tt(tt({},r.settings),i.settings)})});return e(Ro(a))},Mo=i=>e=>e(Io({settings:i})),Qd=i=>({type:pr,payload:i}),Jd=i=>({type:Cr,payload:i}),eh=i=>({type:Pr,payload:i});function vi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function mn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?vi(Object(t),!0).forEach(function(n){Fo(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):vi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Fo(i,e,t){return e=Ao(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ao(i){var e=jo(i,"string");return typeof e=="symbol"?e:String(e)}function jo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Or(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:{var r=n.payload;return r==null?null:t!=null?mn(mn({},t),r):mn({},r)}default:return t}}}function Je(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:return n.payload;default:return t}}}const _o=Je(gr,null),ko=Je(pr,null),Ho=Je(Cr,null),Uo=Je(fr,null),$o=Je(br,null),Bo=Je(Tr,null),Vo=On({commandHistoryStorage:Uo,fileStorage:$o,workspaceStorage:Bo}),Wo=Or(Sr,null),Ko=Or(Er,null),Go=Je(yr,null),zo=Je(Pr,null);var Yo={activeTool:ko,api:_o,plugins:Ho,storage:Vo,user:Wo,workspace:Ko,defaultWorkspaceSettings:Go,serverConfigValues:zo};const qo=Yo;var mi=Q.module("redux-logger"),Zo=i=>e=>t=>{mi.debug("dispatching",t);var n=e(t);return mi.debug("next state",i.getState()),n};const Xo=Zo;var Qo=Q.module("redux-crashReporter"),Jo=i=>e=>t=>{try{return e(t)}catch(n){throw Qo.error("Error executing",t," with state ",i.getState(),":",n),n}};const el=Jo,tl=[Xo,el,$r];var pn;Object.entries(qo).map(i=>{var[e,t]=i;return Nn.register(e,t)});var nl=(pn=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!==null&&pn!==void 0?pn:Wr,wr=Br(On(Nn.reducers),nl(Vr(...tl)));Nn.setListener(i=>{wr.replaceReducer(On(i))});const th=wr;function At(i,e,t){return e=il(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function il(i){var e=rl(i,"string");return typeof e=="symbol"?e:String(e)}function rl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ft{}At(ft,"SESSION_OPENED","ConsoleEvent.SESSION_OPENED");At(ft,"SESSION_CLOSED","ConsoleEvent.SESSION_CLOSED");At(ft,"FOCUS_HISTORY","ConsoleEvent.FOCUS_HISTORY");At(ft,"SEND_COMMAND","ConsoleEvent.SEND_COMMAND");At(ft,"SETTINGS_CHANGED","ConsoleEvent.SETTINGS_CHANGED");const we=ft;function et(i,e,t){return e=al(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function al(i){var e=sl(i,"string");return typeof e=="symbol"?e:String(e)}function sl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class We{}et(We,"TABLE_CHANGED","InputFilterEvent.TABLE_CHANGED");et(We,"COLUMNS_CHANGED","InputFilterEvent.COLUMNS_CHANGED");et(We,"FILTERS_CHANGED","InputFilterEvent.FILTERS_CHANGED");et(We,"CLEAR_ALL_FILTERS","InputFilterEvent.CLEAR_ALL_FILTERS");et(We,"COLUMN_SELECTED","InputFilterEvent.COLUMN_SELECTED");et(We,"OPEN_DROPDOWN","InputFilterEvent.OPEN_DROPDOWN");et(We,"OPEN_INPUT","InputFilterEvent.OPEN_INPUT");et(We,"OPEN_FILTER_SET_MANAGER","InputFilterEvent.OPEN_FILTER_SET_MANAGER");const pi=We,nh=Object.freeze({OPEN:"MarkdownEvent.OPEN"});function Ke(i,e,t){return e=ol(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ol(i){var e=ll(i,"string");return typeof e=="symbol"?e:String(e)}function ll(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ue{}Ke(Ue,"CREATE_NOTEBOOK","NotebookEvent.createNotebook");Ke(Ue,"SELECT_NOTEBOOK","NotebookEvent.selectNotebook");Ke(Ue,"CLOSE_FILE","NotebookEvent.closeFile");Ke(Ue,"RENAME","NotebookEvent.rename");Ke(Ue,"RENAME_FILE","NotebookEvent.renameFile");Ke(Ue,"REGISTER_FILE","NotebookEvent.registerFile");Ke(Ue,"SEND_TO_NOTEBOOK","NotebookEvent.sendToNotebook");Ke(Ue,"UNREGISTER_FILE","NotebookEvent.unregisterFile");Ke(Ue,"PROMOTE_FROM_PREVIEW","NotebookEvent.promoteFromPreview");const W=Ue;function bt(i,e,t){return e=dl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function dl(i){var e=hl(i,"string");return typeof e=="symbol"?e:String(e)}function hl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ut{}bt(ut,"focus","TabEvent.focus");bt(ut,"blur","TabEvent.blur");bt(ut,"openPQObject","TabEvent.openPQObject");bt(ut,"openControl","TabEvent.openControl");bt(ut,"reload","TabEvent.reload");bt(ut,"clearAllFilters","TabEvent.clearAllFilters");const Vt=ut;function ul(i,e,t){return e=cl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function cl(i){var e=vl(i,"string");return typeof e=="symbol"?e:String(e)}function vl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Nr extends c.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){var e,t,n,{glContainer:r}=this.props;return[...(e=r==null||(t=r.tab)===null||t===void 0||(n=t.header)===null||n===void 0?void 0:n.tabs)!==null&&e!==void 0?e:[]]}handleCloseTab(){var{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){var e=this.getAllTabs();e.forEach(t=>{var n;return(n=(t?.contentItem).container)===null||n===void 0?void 0:n.close()})}handleCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=t.length-1;n>0;n-=1){var r,a,s,o,d,h,u;if(((r=t[n].contentItem)===null||r===void 0||(a=r.config)===null||a===void 0?void 0:a.id)===((s=e.tab)===null||s===void 0||(o=s.contentItem)===null||o===void 0||(d=o.config)===null||d===void 0?void 0:d.id))break;(h=((u=t[n])===null||u===void 0?void 0:u.contentItem).container)===null||h===void 0||h.close()}}canCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=!0,r=t.length-1;r>0;r-=1){var a,s,o,d,h,u,v,m;if(((a=t[r].contentItem)===null||a===void 0||(s=a.config)===null||s===void 0?void 0:s.id)===((o=e.tab)===null||o===void 0||(d=o.contentItem)===null||d===void 0||(h=d.config)===null||h===void 0?void 0:h.id))break;var p=!!(!((u=t[r])===null||u===void 0||(v=u.contentItem)===null||v===void 0||(m=v.config)===null||m===void 0)&&m.isClosable);if(p){n=!1;break}}return n}canCloseAny(){for(var e=this.getAllTabs(),t=!0,n=e.length-1;n>0;n-=1){var r,a,s,o=!!(!((r=e[n])===null||r===void 0||(a=r.contentItem)===null||a===void 0||(s=a.config)===null||s===void 0)&&s.isClosable);if(o){t=!1;break}}return t}render(){var e,t,n,{additionalActions:r,glContainer:a}=this.props,s=[...r],o=(e=a.tab)===null||e===void 0||(t=e.contentItem)===null||t===void 0||(n=t.config)===null||n===void 0?void 0:n.isClosable;return s.push({title:"Close",order:10,group:k.groups.low,action:this.handleCloseTab,disabled:o===void 0||!o}),s.push(()=>({title:"Close Tabs to Right",order:20,group:k.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:k.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),l.jsx(k,{actions:s})}}ul(Nr,"defaultProps",{additionalActions:[]});const ml=Nr;function xr(i,e,t){return e=pl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function pl(i){var e=gl(i,"string");return typeof e=="symbol"?e:String(e)}function gl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Dr extends c.PureComponent{constructor(e){super(e),xr(this,"renameInputRef",void 0),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=ae.createRef();var{value:t}=e;this.state={value:t,valueWasValidated:!1}}componentDidUpdate(e){var{isShown:t}=e,{isShown:n}=this.props;n&&!t&&this.resetState()}resetState(){var{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,t;(e=this.renameInputRef)===null||e===void 0||(t=e.current)===null||t===void 0||t.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){var{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();var{value:t}=this.state,n=t?.trim();if(n!==void 0&&n!==""){var{onSubmit:r}=this.props;r(n)}else this.setState({value:n,valueWasValidated:!0})}renderRenameDialog(){var{isShared:e,isOwner:t,itemType:n}=this.props,{value:r,valueWasValidated:a}=this.state;return l.jsxs("form",{className:ee("p-3",{"was-validated":a}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:s=>{s.stopPropagation()},onMouseUp:s=>{s.stopPropagation()},children:[l.jsxs("div",{className:"form-group",children:[l.jsxs("label",{htmlFor:"rename-dialog-".concat(n,"-input"),children:["Rename ",n]}),l.jsx("input",{type:"text",className:"form-control",id:"rename-dialog-".concat(n,"-input"),value:r??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),l.jsxs("div",{className:"invalid-feedback",children:[n," name cannot be empty"]}),(e||!t)&&l.jsxs("div",{className:"pt-2",children:["Renaming this ",n," will rename for all users."]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx(K,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){var{isShown:e,onCancel:t}=this.props;return l.jsx(Aa,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}xr(Dr,"defaultProps",{isShared:!1,isOwner:!0,itemType:"Item",value:""});function yn(i,e,t){return e=fl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function fl(i){var e=bl(i,"string");return typeof e=="symbol"?e:String(e)}function bl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Cl=Q.module("Panel");class Lr extends c.PureComponent{constructor(e){super(e),yn(this,"ref",void 0),yn(this,"getAdditionActions",_e((n,r,a)=>{var s=[];return r&&s.push(this.getCloneAction()),a&&s.push(this.getRenameAction()),[...s,...n]})),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this),this.ref=ae.createRef();var{glContainer:t}=this.props;this.state={title:se.getTitleFromContainer(t),showRenameDialog:!1,isWithinPanel:!0}}componentDidMount(){var e,t,{componentPanel:n,glContainer:r,glEventHub:a}=this.props;r.on("resize",this.handleResize),r.on("show",this.handleBeforeShow),r.on("shown",this.handleShow),r.on("hide",this.handleHide),r.on("tab",this.handleTab),r.on("tabClicked",this.handleTabClicked),a.on(we.SESSION_CLOSED,this.handleSessionClosed),a.on(we.SESSION_OPENED,this.handleSessionOpened),a.on(Vt.focus,this.handleTabFocus),a.on(Vt.blur,this.handleTabBlur),a.on(pi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),a.emit(xe.MOUNT,n??this),this.setState({isWithinPanel:((e=this.ref.current)===null||e===void 0||(t=e.parentElement)===null||t===void 0?void 0:t.closest(".dh-panel"))!=null})}componentWillUnmount(){var{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.off("resize",this.handleResize),t.off("show",this.handleBeforeShow),t.off("shown",this.handleShow),t.off("hide",this.handleHide),t.off("tab",this.handleTab),t.off("tabClicked",this.handleTabClicked),n.off(we.SESSION_CLOSED,this.handleSessionClosed),n.off(we.SESSION_OPENED,this.handleSessionOpened),n.off(Vt.focus,this.handleTabFocus),n.off(Vt.blur,this.handleTabBlur),n.off(pi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(xe.UNMOUNT,e??this)}handleTab(e){e!=null&&this.setState({title:se.getTitleFromTab(e)}),this.forceUpdate();var{onTab:t}=this.props;t(e)}handleTabClicked(e){var{onTabClicked:t}=this.props;t(e)}handleClearAllFilters(){var{onClearAllFilters:e}=this.props;e(...arguments)}handleFocus(e){var{componentPanel:t,glEventHub:n}=this.props;n.emit(xe.FOCUS,t??this);var{onFocus:r}=this.props;r(e)}handleBlur(e){var{onBlur:t}=this.props;t(e)}handleHide(){var{onHide:e}=this.props;e(...arguments)}handleResize(){var{onResize:e}=this.props;e(...arguments)}handleSessionClosed(e){var{onSessionClose:t}=this.props;t(e)}handleSessionOpened(e,t){var{onSessionOpen:n}=this.props;n(e,t)}handleBeforeShow(){var{onBeforeShow:e}=this.props;e(...arguments)}handleShow(){var{onShow:e}=this.props;e(...arguments)}handleTabBlur(){var{onTabBlur:e}=this.props;e(...arguments)}handleTabFocus(){var{onTabFocus:e}=this.props;e(...arguments)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){var{glContainer:t}=this.props;this.setState({showRenameDialog:!1,title:e});var n=se.getRootFromContainer(t),r=se.getComponentConfigFromContainer(t);D(r),se.renameComponent(n,r,e)}handleCopyPanel(){var{glContainer:e,glEventHub:t}=this.props,n=se.getRootFromContainer(e),r=se.getComponentConfigFromContainer(e);if(r==null){Cl.error("Could not get component config from container",e);return}var a=se.cloneComponent(n,r);a!==null&&t.emit(xe.CLONED,this,a)}getCloneAction(){return{title:"Copy Panel",order:10,group:k.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:k.groups.medium,action:this.handleShowRenameDialog}}render(){var{children:e,className:t,renderTabTooltip:n,glContainer:r,additionalActions:a,errorMessage:s,isLoaded:o,isLoading:d,isClonable:h,isRenamable:u}=this.props,{tab:v}=r,{showRenameDialog:m,title:p,isWithinPanel:E}=this.state;return l.jsxs("div",{className:ee("h-100 w-100 dh-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,ref:this.ref,children:[e,l.jsx(wn,{errorMessage:s,isLoaded:o,isLoading:d}),!E&&v!=null&&Ui.createPortal(l.jsxs(l.Fragment,{children:[l.jsx(ml,{glContainer:r,additionalActions:this.getAdditionActions(a,h,u)}),u&&l.jsx(Dr,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),n!=null&&l.jsx(lt,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:n()})]}),v.element[0])]})}}yn(Lr,"defaultProps",{className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1});const jt=Lr,ih=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"});var Sl=Object.freeze({}),El=new Map,an=Object.freeze([]),rh=(i,e)=>{var t;return(t=ke(i,e).columns)!==null&&t!==void 0?t:an},ah=(i,e)=>{var t;return(t=ke(i,e).filterSets)!==null&&t!==void 0?t:an},sh=(i,e)=>{var t;return(t=ke(i,e).filters)!==null&&t!==void 0?t:an},oh=(i,e)=>{var t;return(t=ke(i,e).tableMap)!==null&&t!==void 0?t:El},lh=(i,e)=>ke(i,e).isolatedLinkerPanelId,Rr=(i,e)=>{var t;return(t=ke(i,e).links)!==null&&t!==void 0?t:an},dh=(i,e)=>ke(i,e).columnSelectionValidator,hh=(i,e)=>{var t;return(t=ke(i,e).consoleSettings)!==null&&t!==void 0?t:Sl},uh=(i,e)=>ke(i,e).connection,_t=(i,e)=>ke(i,e).sessionWrapper,ch=(i,e)=>t=>t(dt(i,{connection:e})),vh=(i,e)=>t=>t(dt(i,{sessionWrapper:e})),Ir=(i,e)=>t=>t(dt(i,{links:e})),mh=(i,e)=>(t,n)=>{var r=Rr(n(),i),a=e.filter(s=>r.findIndex(o=>_n(o.start,s.start)&&_n(o.end,s.end))<0);return t(Ir(i,r.concat(a)))},ph=(i,e)=>(t,n)=>{var r=Rr(n(),i),a=r.filter(s=>!e.includes(s.id));return t(Ir(i,a))},gh=(i,e)=>t=>t(dt(i,{isolatedLinkerPanelId:e})),fh=(i,e)=>t=>t(dt(i,{columnSelectionValidator:e})),yl=(i,e)=>t=>t(dt(i,{consoleSettings:e})),bh=(i,e)=>t=>t(dt(i,{filterSets:e}));function tn(i,e,t){return e=Tl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Tl(i){var e=Pl(i,"string");return typeof e=="symbol"?e:String(e)}function Pl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Wt=Q.module("CommandHistoryPanel");class kt extends c.Component{static handleError(e){Wt.error(e)}constructor(e){super(e),tn(this,"container",void 0),tn(this,"pending",void 0),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=ae.createRef(),this.pending=new gt;var{session:t,sessionId:n,language:r}=e;this.state={panelState:{},session:t,sessionId:n,language:r,contextActions:[{action:this.handleFocusHistory,shortcut:be.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){var{glEventHub:e,session:t}=this.props;e.on(we.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){var{glEventHub:e}=this.props;e.off(we.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var e;(e=this.container.current)===null||e===void 0||e.restoreScrollPosition()}handleSessionOpened(e,t){var{language:n,sessionId:r}=t;this.setState({session:e,sessionId:r,language:n},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{session:n,language:r}=this.state;if(Wt.debug("handleSendToNotebook",n,e),!n){Wt.error("Session is not connected.");return}var{glEventHub:a}=this.props;a.emit(t?W.CREATE_NOTEBOOK:W.SEND_TO_NOTEBOOK,n,r,e)}handleSendToConsole(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;Wt.debug("handleSendToConsole",e);var{glEventHub:r}=this.props;r.emit(we.SEND_COMMAND,e,t,n)}loadTable(){var{commandHistoryStorage:e}=this.props,{language:t,sessionId:n}=this.state;D(t),D(n),this.pending.add(e.getTable(t,n,Date.now()),r=>r.close()).then(r=>{this.setState({table:r})}).catch(kt.handleError)}render(){var{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:r,contextActions:a,table:s}=this.state;return l.jsxs(jt,{className:"command-history-pane",componentPanel:this,glContainer:e,glEventHub:t,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!s&&l.jsx("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),s&&r!=null&&l.jsxs(l.Fragment,{children:[l.jsx(oo,{ref:this.container,language:r,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:s,commandHistoryStorage:n}),l.jsx(k,{actions:a})]})]})}}tn(kt,"COMPONENT","CommandHistoryPanel");tn(kt,"TITLE","Command History");var Ol=(i,e)=>{var t=vr(i),n=_t(i,e.localDashboardId),{session:r,config:a}=n??{},{type:s,id:o}=a??{};return{commandHistoryStorage:t,language:s,session:r,sessionId:o}},wl=Mt(Ol,null,null,{forwardRef:!0})(kt);const Nl=wl;function gi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function fi(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gi(Object(t),!0).forEach(function(n){st(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):gi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function st(i,e,t){return e=xl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xl(i){var e=Dl(i,"string");return typeof e=="symbol"?e:String(e)}function Dl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Kt=Q.module("ConsolePanel"),Ll=500,Rl=Object.freeze({consoleSettings:{},itemIds:[]});class sn extends c.PureComponent{constructor(e){super(e),st(this,"consoleRef",void 0),st(this,"objectSubscriptionCleanup",void 0),st(this,"savePanelState",Lt(()=>{var{consoleSettings:s,itemIds:o}=this.state,d={consoleSettings:s,itemIds:[...o]};Kt.debug("Saving panel state",d),this.setState({panelState:d})},Ll)),this.handleFocusCommandHistory=this.handleFocusCommandHistory.bind(this),this.handleOpenObject=this.handleOpenObject.bind(this),this.handleCloseObject=this.handleCloseObject.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleShow=this.handleShow.bind(this),this.handlePanelMount=this.handlePanelMount.bind(this),this.supportsType=this.supportsType.bind(this),this.iconForType=this.iconForType.bind(this),this.consoleRef=ae.createRef();var{panelState:t}=e,n=fi(fi({},Rl),t||{}),{consoleSettings:r,itemIds:a}=n;this.state={consoleSettings:r,itemIds:new Map(a),objectMap:new Map,error:void 0,panelState:n}}componentDidMount(){var{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(xe.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,t){var{consoleSettings:n,itemIds:r}=this.state;(t.consoleSettings!==n||t.itemIds!==r)&&this.savePanelState()}componentWillUnmount(){var e,{glEventHub:t}=this.props;this.savePanelState.flush(),t.off(xe.MOUNT,this.handlePanelMount),(e=this.objectSubscriptionCleanup)===null||e===void 0||e.call(this)}subscribeToFieldUpdates(){var{sessionWrapper:e}=this.props;if(e!=null){var{session:t}=e;this.objectSubscriptionCleanup=t.subscribeToFieldUpdates(n=>{Kt.debug("Got updates",n),this.setState(r=>{var{objectMap:a}=r,{updated:s,created:o,removed:d}=n,h=[...s,...d],u=new Map(a);h.forEach(m=>{var{title:p}=m;p!==void 0&&u.delete(p)});var v=[...s,...o];return v.forEach(m=>{m.title!==void 0&&u.set(m.title,m)}),{objectMap:u}})})}}setItemId(e,t){this.setState(n=>{var{itemIds:r}=n,a=new Map(r);return a.set(e,t),{itemIds:a}})}getItemId(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{itemIds:n}=this.state,r=n.get(e);return r==null&&t&&(r=$i.generate(),this.setItemId(e,r)),r}handleTabFocus(){var e;(e=this.consoleRef.current)===null||e===void 0||e.focus()}handlePanelMount(e){var t,n,r,{itemIds:a}=this.state,s=e==null||(t=e.props)===null||t===void 0?void 0:t.id,o=e==null||(n=e.props)===null||n===void 0||(r=n.metadata)===null||r===void 0?void 0:r.sourcePanelId;if(s&&o){var d=new Set(a.values());d.has(o)&&this.setItemId(s,s)}}handleFocusCommandHistory(){var{glEventHub:e}=this.props;e.emit(we.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{sessionWrapper:n}=this.props;if(n!=null){var{session:r}=n,{root:a}=this.context,s=e.title!=null?this.getItemId(e.title,!1):null;(t||s!=null&&se.getStackForRoot(a,{id:s},!1,!1,!1)!=null)&&this.openWidget(e,r)}}handleCloseObject(e){var{title:t}=e;if(t!==void 0){var n=this.getItemId(t,!1);if(n!=null){var{glEventHub:r}=this.props;r.emit(xe.CLOSE,n)}}}handleSettingsChange(e){var{glEventHub:t}=this.props;Kt.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(we.SETTINGS_CHANGED,e)}openWidget(e,t){var{glEventHub:n}=this.props,{title:r}=e;D(r);var a=this.getItemId(r),s={fetch:()=>t.getObject(e),panelId:a,widget:e};Kt.debug("openWidget",s),n.emit(xe.OPEN,s)}addCommand(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;(t=this.consoleRef.current)===null||t===void 0||t.addCommand(e,n,r)}closeDisconnectedPanels(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,{consoleSettings:t,itemIds:n}=this.state,{isClosePanelsOnDisconnectEnabled:r=!0}=t;if(!(!r&&!e)){var a=[...n.values()],{glEventHub:s}=this.props;a.forEach(o=>{s.emit(xe.CLOSE,o)}),this.setState({itemIds:new Map})}}updateDimensions(){var e;(e=this.consoleRef.current)===null||e===void 0||e.updateDimensions()}supportsType(e){var{plugins:t}=this.props;return[...t.values()].some(n=>$n(n,e))}iconForType(e){var{plugins:t}=this.props,n=[...t.values()].find(r=>$n(r,e));return n!=null?ja(n):l.jsx(Va,{type:e})}render(){var{commandHistoryStorage:e,glContainer:t,glEventHub:n,sessionWrapper:r,timeZone:a,unzip:s}=this.props;if(r==null)return l.jsx(wn,{isLoading:!1,errorMessage:"Console is disabled."});var{consoleSettings:o,error:d,objectMap:h}=this.state,{config:u,session:v,connection:m,details:p={},dh:E}=r,{workerName:S,processInfoId:g}=p,{id:y,type:P}=u;return l.jsx(jt,{className:"iris-panel-console",componentPanel:this,glContainer:t,glEventHub:n,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:d!=null?"".concat(d):void 0,children:v!=null&&l.jsx(Ws,{dh:E,ref:this.consoleRef,settings:o,session:v,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:P,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:Ji.LANGUAGE_MAP.get(P)}),S!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),S]}),g!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),g,l.jsx("div",{children:"•"})]}),l.jsx(go,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})]}),scope:y,timeZone:a,objectMap:h,unzip:s,supportsType:this.supportsType,iconForType:this.iconForType})})}}st(sn,"COMPONENT","ConsolePanel");st(sn,"TITLE","Console");st(sn,"contextType",_a);var Il=(i,e)=>({commandHistoryStorage:vr(i),sessionWrapper:_t(i,e.localDashboardId),timeZone:Po(i),plugins:wo(i)}),Ml=Mt(Il,null,null,{forwardRef:!0})(sn);const gn=Ml;function De(i){return i.type==="directory"}function Fl(i,e,t){return e=Al(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Al(i){var e=jl(i,"string");return typeof e=="symbol"?e:String(e)}function jl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class _l extends Error{constructor(){super("No file exists at the path specified"),Fl(this,"isFileNotFound",!0)}}const Mn=_l;function bi(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Ci(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){bi(a,n,r,s,o,"next",d)}function o(d){bi(a,n,r,s,o,"throw",d)}s(void 0)})}}var Ve;(function(i){i.GROOVY="text/x-groovy",i.PLAIN_TEXT="text/plain",i.PYTHON="text/x-python",i.PYTHON_COMPILED="application/x-python-code",i.SCALA="text/x-scala",i.UNKNOWN=""})(Ve||(Ve={}));class Fe{static fileExists(e,t){return Ci(function*(){try{return yield e.info(t),!0}catch(n){if(!(n instanceof Mn))throw n;return!1}})()}static fileExtensionToString(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return e.length===0?"":".".concat(e)}static getDepth(e){var t;if(!Fe.hasPath(e))throw new Error("Invalid path provided: ".concat(e));var n=(t=e.match(/\//g))!==null&&t!==void 0?t:[];return n.length-1}static getExtension(e){var t=this.getBaseName(e).split(".");if(t.length>1){var n;return(n=t.pop())!==null&&n!==void 0?n:""}return""}static getBaseName(e){var t;return(t=e.split("/").pop())!==null&&t!==void 0?t:""}static getCopyFileName(e){var t=e.lastIndexOf("."),n=null,r=null;t<0?r=e:(r=e.substring(0,t),n=e.substring(t+1));var a=r?"".concat(r,"-copy"):"Copy";return n!==null?"".concat(a,".").concat(n):a}static getUniqueCopyFileName(e,t){return Ci(function*(){for(var n=Fe.getCopyFileName(t);yield Fe.fileExists(e,n);)n=Fe.getCopyFileName(n);return n})()}static getMimeType(e){var t=this.getExtension(e).toLowerCase();switch(t){case"groovy":return Ve.GROOVY;case"py":return Ve.PYTHON;case"pyc":return Ve.PYTHON_COMPILED;case"scala":return Ve.SCALA;case"txt":return Ve.PLAIN_TEXT;default:return Ve.UNKNOWN}}static getParent(e){if(!Fe.hasPath(e))throw new Error("Invalid name provided: ".concat(e));for(var t=e.split("/");t.pop()==="";);if(t.length===0)throw new Error("No parent for path provided: ".concat(e));return"".concat(t.join("/"),"/")}static getPath(e){if(!Fe.hasPath(e))throw new Error("Invalid filename provided: ".concat(e));var t=e.split("/");return t.pop(),"".concat(t.join("/"),"/")}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:"".concat(e,"/")}static replaceExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=e.lastIndexOf("."),r=n>-1?e.substring(0,n):e,a=Fe.fileExtensionToString(t);return"".concat(r).concat(a)}static validateName(e){var t=[".",".."],n=/[\\/\0]/g,r=new Map([["\0","null"]]);if(!e)throw new Nt("Name cannot be empty");if(t.includes(e))throw new Nt('"'.concat(e,'" is a reserved name'));if(n.test(e)){var a,s;throw new Nt('Invalid characters in name: "'.concat((a=(s=e.match(n))===null||s===void 0?void 0:s.reduce((o,d)=>o.includes(d)?o:[...o,d],[]).map(o=>r.has(o)?r.get(o):o).join('", "'))!==null&&a!==void 0?a:"",'"'))}}static reducePaths(e){var t=e.filter(n=>Fe.isPath(n));return e.filter(n=>!t.some(r=>n!==r&&n.startsWith(r)))}static removeRoot(e,t){if(e.length===0)return t;if(!t.startsWith(e))throw new Error("Filename ".concat(t," does not start with expected root ").concat(e));return t.substring(e.length)}static addRoot(e,t){return"".concat(e).concat(t)}}const w=Fe;var Fn=26;function Tn(i){return De(i)?w.makePath(i.filename):w.getPath(i.filename)}function Si(i,e){if(i.length===0||e==null)throw new Error("No items to move");var t=Tn(e);if(i.some(n=>{var{filename:r}=n;return w.getPath(r)===t}))throw new Error("File already in the destination folder");if(i.some(n=>De(n)&&t.startsWith(w.makePath(n.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:i,targetPath:t}}function kl(i){if(De(i))return i.isExpanded?oa:la;var e=w.getMimeType(i.basename);switch(e){case Ve.PYTHON:return ha;default:return da}}function Pn(i){var e,{children:t,draggedItems:n,isDragInProgress:r,isDropTargetValid:a,isSelected:s,item:o,itemIndex:d,dropTargetItem:h,onDragStart:u,onDragOver:v,onDragEnd:m,onDrop:p}=i,E=(e=n?.some(A=>A.id===o.id))!==null&&e!==void 0?e:!1,S=Tn(o),g=r&&h?Tn(h):null,y=r&&a&&De(o)&&g===S,P=r&&a&&g===S,O=r&&!a&&g===S,L=kl(o),V=w.getDepth(o.filename),Z=Array(V).fill(null).map((A,z)=>l.jsx("span",{className:"file-list-depth-line"},z));return l.jsxs("div",{className:ee("d-flex w-100 align-items-center","file-list-item",{"is-dragged":E,"is-exact-drop-target":y,"is-in-drop-target":P,"is-invalid-drop-target":O,"is-selected":s}),onDragStart:A=>u(d,A),onDragOver:A=>v(d,A),onDragEnd:A=>m(d,A),onDrop:A=>p(d,A),draggable:!0,role:"presentation","aria-label":o.basename,children:[Z," ",l.jsx(re,{icon:L,className:"item-icon",fixedWidth:!0})," ",l.jsx("span",{className:"truncation-wrapper",children:t??l.jsxs(l.Fragment,{children:[o.basename,l.jsx(lt,{children:o.basename})]})})]})}function Ei(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Gt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ei(Object(t),!0).forEach(function(n){Hl(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ei(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Hl(i,e,t){return e=Ul(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ul(i){var e=$l(i,"string");return typeof e=="symbol"?e:String(e)}function $l(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var pe=Q.module("FileList"),Bl=500,yi="item-list-scroll-pane";function Vl(i){var{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:r,onSelect:a,onSelectionChange:s=()=>{},renderItem:o=Pn,rowHeight:d=Fn,overscanCount:h=bn.DEFAULT_OVERSCAN}=i,[u,v]=c.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=c.useState({top:0,bottom:0}),[E,S]=c.useState(),[g,y]=c.useState(),[P,O]=c.useState(),[L,V]=c.useState([]),Z=c.useRef(),A=c.useRef(null),z=c.useRef(null),G=c.useCallback(C=>{if(C.length===0||u==null)return[];for(var M=[],B=0;B<C.length;B+=1)for(var te=C[B],me=te[0];me<=te[1];me+=1)me>=u.offset&&me<u.offset+u.items.length&&M.push(u.items[me-u.offset]);return M},[u]),X=c.useCallback(C=>{var M=G([[C,C]]);if(M.length>0)return M[0]},[G]),ve=c.useCallback(()=>{var C=Bn.count(L);if(C===0)return null;if(C===1){var M=L[0][0],B=X(M);if(B!=null)return B.filename}return"".concat(C," items")},[X,L]),R=c.useCallback(C=>{if(!(!g||!E)){pe.debug("dropItems",g,"to",C);try{var{files:M,targetPath:B}=Si(g,E);if(r?.(M,B),C!=null){var te;V([[C,C]]),(te=A.current)===null||te===void 0||te.focusItem(C)}}catch(me){pe.error("Unable to complete move",me)}}},[g,E,r]),$=c.useCallback((C,M)=>{var B=u.items[C-u.offset];B!==void 0&&(pe.debug("handleItemClick",B),a(B,M),De(B)&&t?.setExpanded(B.filename,!B.isExpanded))},[u,a,t]),H=c.useCallback((C,M)=>{var B;pe.debug2("handleItemDragStart",C,L);var te=L;Bn.isSelected(L,C)||(te=[[C,C]],V(te)),y(G(te)),(B=A.current)===null||B===void 0||B.resetMouseState();var me=document.createElement("div");me.innerHTML='<div class="dnd-placeholder-content">'.concat(ve(),"</div>"),me.className="file-list-dnd-placeholder",document.body.appendChild(me),M.dataTransfer.setDragImage(me,0,0),M.dataTransfer.effectAllowed="move",O(me)},[ve,G,L]),N=c.useCallback((C,M)=>{M.preventDefault(),pe.debug2("handleItemDragOver",M),S(X(C))},[X]),F=c.useCallback((C,M)=>{pe.debug("handleItemDragEnd",C),P?.remove(),y(void 0),S(void 0),O(void 0)},[P]),I=c.useCallback((C,M)=>{R(C)},[R]),oe=c.useCallback(()=>{pe.debug2("handleItemDragExit"),S(void 0)},[]),Ge=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(yi)&&(C.preventDefault(),pe.debug2("handleListDragOver",C),S({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),ze=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(yi)&&(pe.debug("handleListDrop"),R())},[R]),f=c.useCallback(function(C){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(pe.debug2("handleSelectionChange",C),M===!0||C!==L){V(C);var B=G(C);s(B)}},[G,s,L]),b=c.useCallback(C=>{if(pe.debug2("handleFocusChange",C),C!=null){var[M]=G([[C,C]]);n(M)}else n();Z.current=C},[G,n]),T=c.useCallback((C,M)=>{pe.debug("handleViewportChange",C,M),(C!==m.top||M!==m.bottom)&&p({top:C,bottom:M})},[m]),x=c.useMemo(()=>{if(!g||!E)return!1;try{return Si(g,E),pe.debug("handleValidateDropTarget true"),!0}catch{return pe.debug("handleValidateDropTarget false"),!1}},[g,E]),{focusedPath:j}=i;c.useEffect(()=>{j!==void 0&&(j==="/"?t.collapseAll():(t.setExpanded(j,!1),t.setExpanded(j,!0)))},[t,j]),c.useEffect(function(){pe.debug("updating table viewport",m),t?.setViewport({top:Math.max(0,m.top-h),bottom:m.bottom+h})},[h,t,m]),c.useEffect(function(){var M=t.onUpdate(B=>{v({items:B.items.map(te=>Gt(Gt({},te),{},{itemName:te.basename})),offset:B.offset,itemCount:t.size})});return()=>{M()}},[t]),c.useEffect(function(){Z.current!=null&&b(Z.current),L.length>0&&f(L,!0)},[u,b,f,L]),c.useEffect(function(){if(E!=null&&De(E)&&E.filename!=="/"){var M=setTimeout(()=>{E.isExpanded||t?.setExpanded(E.filename,!0)},Bl);return()=>clearTimeout(M)}},[E,t]);var $e=c.useCallback(C=>o(Gt(Gt({},C),{},{isDragInProgress:g!=null,dropTargetItem:E,draggedItems:g,isDropTargetValid:x,onDragStart:H,onDragEnd:F,onDragOver:N,onDragExit:oe,onDrop:I})),[F,oe,N,H,I,g,E,x,o]);return l.jsx("div",{ref:z,className:ee("file-list",{"is-dragging":g!=null}),onDragOver:Ge,onDrop:ze,children:l.jsx(bn,{ref:A,items:u.items,itemCount:u.itemCount,offset:u.offset,onFocusChange:b,onSelect:$,onSelectionChange:f,onViewportChange:T,selectedRanges:L,renderItem:$e,rowHeight:d,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}var Wl={name:"File Explorer",DELETE:Ce.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[Y.DELETE],macShortcut:[q.CMD,Y.BACKSPACE]}),RENAME:Ce.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]})};const Ti={FILE_EXPLORER:Wl};var Pi=Q.module("FileListItemEditor"),Kl=()=>Promise.resolve();function Gl(i){var{item:e,onCancel:t,onSubmit:n,validate:r=Kl}=i,a=c.useRef(null),[s,o]=c.useState(e.basename),[d,h]=c.useState(),[u,v]=c.useState(Promise.resolve()),m=c.useCallback(()=>{var P;(P=a.current)===null||P===void 0||P.focus()},[a]),p=c.useCallback(P=>P.stopPropagation(),[]),E=c.useCallback(()=>{u.then(()=>{n(s)}).catch(P=>Pi.info("Unable to validate name",P))},[n,s,u]);c.useEffect(function(){var O=ce.makeCancelable(r(s));return O.then(()=>h(void 0)).catch(L=>{ce.isCanceled(L)||h(L)}),v(O),()=>O.cancel()},[r,s]),c.useEffect(function(){m()},[m]);var S=c.useCallback(()=>{Pi.debug2("handleBlur"),E()},[E]),g=c.useCallback(P=>{var{value:O}=P.target;o(O)},[]),y=c.useCallback(P=>{P.stopPropagation();var{key:O}=P;switch(O){case"Enter":{E();break}case"Escape":{t();break}}},[t,E]);return l.jsxs("div",{className:"file-list-item-editor",children:[l.jsx("input",{type:"text",className:ee("form-control file-list-item-editor-input",{"is-invalid":d}),value:s,ref:a,onBlur:S,onKeyDown:y,onChange:g,onClick:p,onDoubleClick:p,onMouseDown:p}),d&&l.jsx("div",{className:"invalid-feedback",children:"".concat(d)})]})}function Oi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function fn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Oi(Object(t),!0).forEach(function(n){zl(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Oi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function zl(i,e,t){return e=Yl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Yl(i){var e=ql(i,"string");return typeof e=="symbol"?e:String(e)}function ql(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Mr(i){var{isMultiSelect:e=!1,focusedPath:t,showContextMenu:n=!1,onCreateFile:r,onCreateFolder:a,onCopy:s,onDelete:o,onMove:d,onRename:h,onSelect:u,onSelectionChange:v,table:m,rowHeight:p=Fn,validateRename:E=()=>Promise.resolve()}=i,[S,g]=c.useState(),[y,P]=c.useState([]),[O,L]=c.useState(),V=c.useCallback(I=>{P(I),v?.(I)},[v]),Z=c.useCallback(I=>{L(I)},[]),A=c.useCallback(()=>{O&&s?.(O)},[O,s]),z=c.useCallback(()=>{y.length>0&&o?.(y)},[o,y]),G=c.useCallback(()=>{r?.()},[r]),X=c.useCallback(()=>{O&&a?.(w.getPath(O.filename))},[O,a]),ve=c.useCallback(()=>{O&&g(O)},[O]),R=c.useCallback(()=>{g(void 0)},[]),$=c.useCallback(I=>{S&&(h?.(S,I),g(void 0))},[h,S]),H=c.useMemo(()=>{if(S)return[];var I=[];return r&&I.push({title:"New File",description:"Create new file",action:G,group:k.groups.medium}),a&&I.push({title:"New Folder",description:"Create new folder",action:X,group:k.groups.medium}),s&&I.push({title:"Copy File",description:"Copy the selected file",action:A,group:k.groups.low,disabled:O==null||De(O)}),o&&y.length>0&&I.push({title:"Delete",description:"Delete",shortcut:Ti.FILE_EXPLORER.DELETE,action:z,group:k.groups.low}),h&&I.push({title:"Rename",description:"Rename",shortcut:Ti.FILE_EXPLORER.RENAME,action:ve,group:k.groups.low,disabled:O==null}),I},[A,z,G,X,ve,O,s,r,a,o,h,y,S]),N=c.useCallback(I=>(D(S),E(S,I)),[S,E]),F=c.useCallback(I=>{var{item:oe}=I;return S&&S.filename===oe.filename?l.jsx(Pn,fn(fn({},I),{},{children:l.jsx(Gl,{item:oe,validate:N,onSubmit:$,onCancel:R})})):l.jsx(Pn,fn({},I))},[R,$,S,N]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(Vl,{onMove:d,onSelect:u,onSelectionChange:V,onFocusChange:Z,renderItem:F,rowHeight:p,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(k,{actions:H})]})}Mr.displayName="FileListContainer";function wi(i,e,t){return e=Zl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Zl(i){var e=Xl(i,"string");return typeof e=="symbol"?e:String(e)}function Xl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ql extends Nt{constructor(e){super("Name already exists"),wi(this,"isExistingFile",!0),wi(this,"info",void 0),this.info=e}}const zt=Ql;function Ni(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function xi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Ni(a,n,r,s,o,"next",d)}function o(d){Ni(a,n,r,s,o,"throw",d)}s(void 0)})}}var Ie=Q.module("FileExplorer");function An(i){var{storage:e,isMultiSelect:t=!1,focusedPath:n,onCopy:r=()=>{},onDelete:a=()=>{},onRename:s=()=>{},onCreateFile:o=()=>{},onCreateFolder:d=()=>{},onSelect:h,onSelectionChange:u,rowHeight:v=Fn}=i,[m,p]=c.useState([]),[E,S]=c.useState();c.useEffect(function(){var $;function H(){return N.apply(this,arguments)}function N(){return N=xi(function*(){Ie.debug("initTable"),$=ce.makeCancelable(e.getTable(),F=>F.close());try{S(yield $)}catch(F){ce.isCanceled(F)||Ie.error("Unable to initialize table",F)}}),N.apply(this,arguments)}return H(),()=>{$.cancel()}},[e]);var g=c.useCallback(R=>{ce.isCanceled(R)||Ie.error(R)},[]),y=c.useCallback(()=>{Ie.debug("handleCreateFile"),o()},[o]),P=c.useCallback(()=>{Ie.debug("handleCreateFolder"),d()},[d]),O=c.useCallback(R=>{Ie.debug("handleCopyFile",R.filename),r(R)},[r]),L=c.useCallback(R=>{Ie.debug("handleDelete, pending confirmation",R),p(R)},[]),V=c.useCallback(()=>{Ie.debug("handleDeleteConfirm",m),m.forEach(R=>e.deleteFile(De(R)?w.makePath(R.filename):R.filename)),a(m),p([])},[m,a,e]),Z=c.useCallback(()=>{Ie.debug("handleDeleteCancel"),p([])},[]),A=c.useCallback((R,$)=>{var H=w.reducePaths(R.map(N=>De(N)?w.makePath(N.filename):N.filename));H.forEach(N=>{var F=w.isPath(N)?"".concat($).concat(w.getBaseName(N.substring(0,N.length-1)),"/"):"".concat($).concat(w.getBaseName(N));e.moveFile(N,F).then(()=>{s(N,F)}).catch(g)})},[g,s,e]),z=c.useCallback((R,$)=>{var H=R.filename,N=De(R);N&&!H.endsWith("/")&&(H="".concat(H,"/"));var F="".concat(w.getParent(H)).concat($);N&&!F.endsWith("/")&&(F="".concat(F,"/")),Ie.debug2("handleRename",H,F),e.moveFile(H,F).catch(g),s(H,F)},[g,s,e]),G=c.useCallback(function(){var R=xi(function*($,H){if(H!==$.basename){w.validateName(H);var N="".concat(w.getPath($.filename)).concat(H);try{var F=yield e.info(N);throw new zt(F)}catch(I){if(!(I instanceof Mn))throw I}}});return function($,H){return R.apply(this,arguments)}}(),[e]),X=m.length>0,ve=c.useMemo(()=>m.length===1?'Are you sure you want to delete "'.concat(m[0].filename,'"?'):"Are you sure you want to delete the selected files?",[m]);return l.jsxs("div",{className:"file-explorer",children:[E&&l.jsx(Mr,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onCopy:O,onCreateFolder:P,onCreateFile:y,onMove:A,onDelete:L,onRename:z,onSelect:h,onSelectionChange:u,rowHeight:v,table:E,validateRename:G}),l.jsx(Rt,{isOpen:X,headerText:ve,bodyText:"You cannot undo this action.",onCancel:Z,onConfirm:V,confirmButtonText:"Delete"})]})}An.displayName="FileExplorer";function Di(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Jl(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Di(a,n,r,s,o,"next",d)}function o(d){Di(a,n,r,s,o,"throw",d)}s(void 0)})}}function qe(i,e,t){return e=ed(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ed(i){var e=td(i,"string");return typeof e=="symbol"?e:String(e)}function td(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var nt=Q.module("NewItemModal");class ot extends c.PureComponent{static getValidationMessage(e){return e instanceof zt&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":"".concat(e)}static handleError(e){ce.isCanceled(e)||nt.error(e)}constructor(e){super(e),qe(this,"inputRef",ae.createRef()),qe(this,"cancelableValidatePromise",void 0),qe(this,"cancelableExistingItemPromise",void 0),qe(this,"pending",new gt),qe(this,"pathMap",new Map),qe(this,"isInitialLoad",!0),this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);var{defaultValue:t}=e,n=w.hasPath(t)?w.getPath(t):"/";this.state={isSubmitting:!1,path:n,prevExtension:w.getExtension(t),showExtensionChangeModal:!1,showOverwriteModal:!1,value:w.getBaseName(t)}}componentDidUpdate(e,t){var{isOpen:n}=this.props,{isOpen:r}=e,{value:a,path:s}=this.state;!r&&n&&(this.resetValue(),this.isInitialLoad=!0),r&&n&&(!this.isInitialLoad&&(s!==t.path||a!==t.value)&&this.updateValidationStatus(s,a),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){var{defaultValue:e}=this.props,t=w.hasPath(e)?w.getPath(e):"/";this.setState({path:t,value:w.getBaseName(e),validationError:void 0,prevExtension:w.getExtension(e),isSubmitting:!1})}getValidationPromise(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ce.makeCancelable(this.validateName(e,t,n)),this.cancelableValidatePromise}validateName(e,t,n){var r=this;return Jl(function*(){w.validateName(t);var{defaultValue:a,storage:s}=r.props;if(n){var o="".concat(e).concat(t);if(o!==a)try{var d=yield s.info(o);throw new zt(d)}catch(h){if(!(h instanceof Mn))throw h}}return t})()}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(ot.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){var{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(nt.debug("handleSelect",e),e.type==="directory")this.setState({path:w.makePath(e.filename)});else{var t=e.basename,n=w.getPath(e.filename);this.setState({value:t,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(e){var{key:t}=e;switch(e.stopPropagation(),t){case"Enter":{e.preventDefault(),this.submitModal();break}case"Escape":{e.preventDefault();var{onCancel:n}=this.props;n();break}}}handleValidationError(e){if(!(e instanceof Nt))throw e;nt.debug("Validation error",e),this.setState({validationError:e})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});var{onSubmit:e}=this.props,{path:t,value:n}=this.state;nt.debug("handleOverwriteConfirm",t,n),e("".concat(t).concat(n),!0)}handleExtensionChangeCancel(){nt.debug("handleExtensionChangeCancel"),this.setState(e=>{var{value:t,prevExtension:n}=e,r=w.replaceExtension(t,n);return{showExtensionChangeModal:!1,value:r}}),this.submitModal(!0)}handleExtensionChangeConfirm(){nt.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){var e=this.inputRef.current;if(e){var{type:t}=this.props,{value:n}=e,r=t==="directory"?n.length:n.lastIndexOf(".");e.focus(),e.setSelectionRange(0,r>0?r:n.length)}}submitModal(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.setState(t=>{var{prevExtension:n,value:r,path:a}=t,{notifyOnExtensionChange:s,type:o}=this.props;nt.debug("submitModal",n,r);var d=w.getExtension(r);return s&&!e&&n!==null&&n!==d?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:d}:(this.getValidationPromise(a,r,!0).then(h=>{var{onSubmit:u}=this.props;u("".concat(a).concat(r))}).catch(h=>{if(h instanceof zt&&o!=="directory"&&h.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw h}).catch(h=>{throw ce.isCanceled(h)&&this.setState({isSubmitting:!1}),h}).catch(this.handleValidationError).catch(ot.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(e){this.setState({path:e})}renderPathButtons(e){var t=e.split("/");return t.pop(),t.map((n,r)=>{for(var a="",s=0;s<r;s+=1)a+="".concat(t[s],"/");return a+="".concat(n,"/"),l.jsxs(ae.Fragment,{children:[l.jsx(K,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(a),"aria-label":r===0?"Home":void 0,icon:r===0?l.jsx(re,{icon:ua,transform:"right-1.6"}):void 0,tooltip:r===0?"Home":void 0,children:n}),"/"]},a)})}render(){var{storage:e,isOpen:t,onCancel:n,placeholder:r,title:a,type:s}=this.props,{isSubmitting:o,path:d,showExtensionChangeModal:h,showOverwriteModal:u,validationError:v,value:m,prevExtension:p,newExtension:E}=this.state,S=s==="directory",g=w.fileExtensionToString(p),y=w.fileExtensionToString(E),P=S?"Create":"Save",O=S?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(ca,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal",children:[l.jsx(va,{toggle:n,children:a}),l.jsx(ma,{children:l.jsx("form",{children:l.jsxs("div",{className:"d-flex flex-column new-file-modal-content",children:[l.jsxs("div",{className:"flex-grow-0 mb-4",children:[l.jsx("label",{htmlFor:"file-name-input",children:O}),l.jsx("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:ee("form-control",{"is-invalid":v}),value:m,placeholder:r,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),v&&l.jsx("div",{className:"invalid-feedback",children:ot.getValidationMessage(v)})]}),l.jsxs("div",{className:"flex-grow-0",children:[l.jsx("label",{children:"Directory: /"}),this.renderPathButtons(d)]}),l.jsx("div",{className:"flex-grow-1 file-explorer-container",children:l.jsx(An,{onSelect:this.handleSelect,storage:e,focusedPath:d})})]})})}),l.jsxs(ka,{children:[l.jsx(K,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(K,{kind:"primary",disabled:o,onClick:this.handleModalSubmit,children:P})]})]}),l.jsx(Rt,{isOpen:u,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),l.jsx(Rt,{isOpen:h,headerText:"Confirm extension change",bodyText:'Are you sure you want to change extension from "'.concat(g,'" to "').concat(y,'"?'),onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:'Keep "'.concat(g,'"'),confirmButtonText:'Use "'.concat(y,'"')})]})}}qe(ot,"propTypes",{isOpen:Me.bool,title:Me.string.isRequired,defaultValue:Me.string,type:Me.oneOf(["file","directory"]).isRequired,onSubmit:Me.func,onCancel:Me.func,placeholder:Me.string,storage:Me.shape({}).isRequired,notifyOnExtensionChange:Me.bool});qe(ot,"defaultProps",{isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(i,e)=>{},onCancel:()=>{}});const Fr=ot;function nd(i){var{createFile:e,createFolder:t,onSearchChange:n,defaultSearchText:r=""}=i;return l.jsxs("div",{className:"file-explorer-toolbar",children:[l.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[l.jsx(K,{kind:"ghost",icon:Yi,tooltip:"New notebook",onClick:e,"aria-label":"New notebook"}),l.jsx(K,{kind:"ghost",icon:pa,tooltip:"New folder",onClick:t,"aria-label":"New folder"})]}),n&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(Ha,{value:r,onChange:n,placeholder:"Search by name"})})]})}function Li(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function id(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Li(a,n,r,s,o,"next",d)}function o(d){Li(a,n,r,s,o,"throw",d)}s(void 0)})}}function Ar(i,e,t){return e=rd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function rd(i){var e=ad(i,"string");return typeof e=="symbol"?e:String(e)}function ad(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var it=Q.module("FileExplorerPanel"),sd=(i,e)=>{var t=mr(i),n=_t(i,e.localDashboardId),{session:r,config:a}=n??{},s=a?.type;return{fileStorage:t,language:s,session:r}},od=Mt(sd,null,null,{forwardRef:!0});function ld(i){var e=i;return e!=null&&typeof e.button=="number"}class pt extends ae.Component{static handleError(e){it.error(e)}static isFocusEvent(e){return ld(e)?e.detail>=2:!0}constructor(e){super(e),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCopyFile=this.handleCopyFile.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);var{session:t,language:n}=e;this.state={isShown:!1,language:n,session:t,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){var{glEventHub:e}=this.props,{session:t,language:n}=this.state,r={language:n,value:""};it.debug("handleCreateFile",t,n,r),e.emit(W.CREATE_NOTEBOOK,t,n,r)}handleCreateDirectory(){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){it.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){it.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});var{fileStorage:t}=this.props;t.createDirectory(e).catch(pt.handleError)}handleCopyFile(e){var t=this;return id(function*(){var{fileStorage:n}=t.props;if(De(e)){it.error("Invalid item in handleCopyItem",e);return}var r=yield w.getUniqueCopyFileName(n,e.filename);yield n.copyFile(e.filename,r)})()}handleDelete(e){var{glEventHub:t}=this.props;e.forEach(n=>{t.emit(W.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(e){var t="/";e.length===1&&(e[0].type==="directory"?t=w.makePath(e[0].filename):t=w.getPath(e[0].filename)),this.setState({focusedFilePath:t})}handleFileSelect(e,t){if(it.debug("fileSelect",e),e.type!=="directory"){var n=pt.isFocusEvent(t),r={id:e.filename,itemName:e.filename},{glEventHub:a}=this.props,{session:s,language:o}=this.state,d={value:null,language:o};a.emit(W.SELECT_NOTEBOOK,s,o,d,r,n)}}handleRename(e,t){var{glEventHub:n}=this.props;it.debug("handleRename",e,t),n.emit(W.RENAME_FILE,e,t)}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,language:n})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){var{glContainer:e}=this.props,{isHidden:t}=e;return t}render(){var{fileStorage:e,glContainer:t,glEventHub:n}=this.props,{isShown:r,showCreateFolder:a,focusedFilePath:s}=this.state;return l.jsxs(jt,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(nd,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),r&&l.jsx(An,{isMultiSelect:!0,storage:e,onCopy:this.handleCopyFile,onCreateFile:this.handleCreateFile,onCreateFolder:this.handleCreateDirectory,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(Fr,{isOpen:a,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:s})]})}}Ar(pt,"COMPONENT","FileExplorerPanel");Ar(pt,"TITLE","File Explorer");var dd=od(pt);const hd=dd;function It(i,e,t){return e=ud(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ud(i){var e=cd(i,"string");return typeof e=="symbol"?e:String(e)}function cd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ri=Q.module("LogPanel");class on extends c.PureComponent{constructor(e){super(e),It(this,"isBottomVisible",void 0),It(this,"logView",void 0),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;var{session:t}=this.props;this.state={session:t}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Ri.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Ri.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){var{glContainer:e,glEventHub:t}=this.props,{session:n}=this.state;return l.jsxs(jt,{componentPanel:this,glContainer:e,glEventHub:t,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[n==null&&l.jsx("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),n!=null&&l.jsx(vo,{session:n,ref:r=>{this.logView=r}})]})}}It(on,"defaultProps",{session:null});It(on,"COMPONENT","LogPanel");It(on,"TITLE","Log");var vd=(i,e)=>{var t;return{session:(t=_t(i,e.localDashboardId))===null||t===void 0?void 0:t.session}},md=Mt(vd,null,null,{forwardRef:!0})(on);const pd=md;function Yt(i,e,t){return e=gd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function gd(i){var e=fd(i,"string");return typeof e=="symbol"?e:String(e)}function fd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class jr extends c.PureComponent{constructor(e){super(e),Yt(this,"commands",void 0),Yt(this,"codeElements",void 0),Yt(this,"editorScrollView",void 0),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=ae.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){var{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){var t=[...this.commands.keys()],n=t.findIndex(r=>r===e)+1;return n>=t.length?null:t[n]}handleRunSelected(e){var t,n;e.preventDefault(),e.stopPropagation();var{nextStartLine:r}=this.state,a=[...this.commands.keys()],s=a.findIndex(S=>S===r||r==null);if(!(s<0)){var o=a[s],d=this.commands.get(o),h=this.getNextStartLine(o),u=(t=this.codeElements.get(o))===null||t===void 0?void 0:t.current,v=u==null||(n=u.parentElement)===null||n===void 0?void 0:n.nextElementSibling;if(v!=null){var m,{offsetTop:p}=v,E=p;(m=this.editorScrollView.current)===null||m===void 0||m.scroll({top:E,left:0})}this.runCode(d),this.setState({nextStartLine:h})}}runCode(e){var{onRunCode:t}=this.props;t(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){var{children:t,className:n,inline:r,node:a}=e,{hasRunCode:s,nextStartLine:o}=this.state,{children:d,position:h}=a;D(h);var{start:u}=h,{line:v}=u,m=d[0].value,p=ae.createRef(),E=this.commands.size===0,S=o===v||E&&o==null&&!s,g=n!==void 0&&n.startsWith("language-")?n.substring(9):"plaintext";return r!=null&&r?l.jsx("code",{className:n,children:t}):(this.commands.set(v,m),this.codeElements.set(v,p),l.jsxs("div",{className:ee("markdown-notebook-code-block",{"is-selected":S}),ref:p,onClick:()=>{this.setState({nextStartLine:v})},role:"presentation",children:[l.jsx(K,{kind:"ghost",icon:qt,className:"btn-play-block",onClick:y=>{y.stopPropagation(),y.preventDefault(),this.runCode(m),this.setState({nextStartLine:v})},tooltip:"Run code"}),l.jsx("code",{children:l.jsx(Dn,{language:g,children:ae.Children.map(t,y=>typeof y=="string"?y.trim():y)})})]}))}renderLink(e){var{onLinkClick:t}=this.props,{href:n,children:r,target:a}=e;return l.jsx("a",{href:n,onClick:t,target:a,children:r})}render(){var{content:e,transformImageUri:t,transformLinkUri:n}=this.props,{hasCode:r,hasRunCode:a,nextStartLine:s}=this.state;return l.jsxs("div",{className:"markdown-notebook",children:[l.jsx("div",{className:"markdown-notebook-toolbar",children:l.jsx(K,{className:ee("btn-play-selected-cell",{flashing:r&&!a}),kind:"ghost",icon:qt,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:a&&s==null||!r,children:"Run Selected Code"})}),l.jsx("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:l.jsx(Kr,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[Gr],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}Yt(jr,"defaultProps",{onRunCode:()=>{}});const bd=jr;function Ii(i,e,t,n,r,a,s){try{var o=i[a](s),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Mi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var a=i.apply(e,t);function s(d){Ii(a,n,r,s,o,"next",d)}function o(d){Ii(a,n,r,s,o,"throw",d)}s(void 0)})}}function Fi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Se(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Fi(Object(t),!0).forEach(function(n){ue(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Fi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ue(i,e,t){return e=Cd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Cd(i){var e=Sd(i,"string");return typeof e=="symbol"?e:String(e)}function Sd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var _=Q.module("NotebookPanel"),Ai=400;class le extends c.Component{static handleError(e){ce.isCanceled(e)||_.error(e)}static unsavedNotebookCount(){return document.querySelectorAll(".".concat(le.UNSAVED_INDICATOR_CLASS_NAME,".").concat(le.UNSAVED_STATUS_CLASS_NAME)).length}static languageFromFileName(e){var t=w.getExtension(e).toLowerCase();switch(t){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}constructor(e){super(e),ue(this,"pending",void 0),ue(this,"debouncedSavePanelState",void 0),ue(this,"debouncedLoad",void 0),ue(this,"notebook",void 0),ue(this,"tabTitleElement",void 0),ue(this,"tabInitOnce",void 0),ue(this,"editor",void 0),ue(this,"getSettings",_e((m,p)=>Se(Se({},m),{},{minimap:{enabled:p}}))),ue(this,"getOverflowActions",_e((m,p)=>[{title:"Find",icon:ba,action:this.handleFind,group:k.groups.high,shortcut:be.NOTEBOOK.FIND,order:10},{title:"Copy File",icon:Ca,action:this.handleCopy,group:k.groups.medium,order:20},{title:"Rename File",icon:Sa,action:this.handleShowRename,group:k.groups.medium,order:30},{title:"Delete File",icon:Ki,action:this.handleDelete,group:k.groups.medium,order:40},{title:"Show Minimap",icon:m?Ot:void 0,action:this.handleMinimapChange,group:k.groups.low,shortcut:be.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:p?Ot:void 0,action:this.handleWordWrapChange,group:k.groups.low,shortcut:be.NOTEBOOK.WORDWRAP,order:30}])),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleDeleteConfirm=this.handleDeleteConfirm.bind(this),this.handleDeleteCancel=this.handleDeleteCancel.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelDropped=this.handlePanelDropped.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabClick=this.handleTabClick.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.handlePreviewPromotion=this.handlePreviewPromotion.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new gt,this.debouncedSavePanelState=Lt(this.savePanelState.bind(this),Ai),this.debouncedLoad=Lt(this.load.bind(this),Ai),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;var{isDashboardActive:t,session:n,sessionLanguage:r,panelState:a}=e,s={value:"",language:"",wordWrap:"off"},o=null,{isPreview:d}=e;a!=null&&({fileMetadata:o=o,isPreview:d=d,settings:s=s}=a);var h=o!=null&&w.hasPath(o.itemName),u=h===!0&&s.value!=null||!h&&s.value!=null&&s.value.length>0,v=u?1:0;this.state={error:void 0,isDashboardActive:t,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:d,savedChangeCount:0,changeCount:v,fileMetadata:o,settings:s,session:n,sessionLanguage:r,panelState:{fileMetadata:o,settings:s},showCloseModal:!1,showDeleteModal:!1,showSaveAsModal:!1,scriptCode:""},_.debug("constructor",e,this.state)}componentDidMount(){var{glContainer:e,glEventHub:t}=this.props,{tab:n}=e;n!=null&&this.initTab(n),this.initNotebookContent(),t.on(W.RENAME_FILE,this.handleRenameFile),t.on(xe.DROPPED,this.handlePanelDropped),e.on(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion)}componentDidUpdate(e,t){var{isPreview:n,settings:r}=this.state,{wordWrap:a}=r,{defaultNotebookSettings:s}=this.props;n!==t.isPreview&&this.setPreviewStatus(),a!==t.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),s.isMinimapEnabled!==e.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();var{glEventHub:e,glContainer:t}=this.props,{fileMetadata:n,isPreview:r}=this.state;e.off(W.RENAME_FILE,this.handleRenameFile),e.off(xe.DROPPED,this.handlePanelDropped),t.off(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion),e.emit(W.UNREGISTER_FILE,n,r)}initTab(e){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(e)}initTabCloseOverride(){var{glContainer:e}=this.props;e.beforeClose(t=>{if(t?.force===!0)return!0;var{changeCount:n,savedChangeCount:r}=this.state;return n!==r?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(e){var t=e.element.get(0);D(t);var n=t.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){var{changeCount:e,savedChangeCount:t,settings:n}=this.state,{value:r}=n;if(e!==t&&this.notebook){var a=this.notebook.getValue();return a??r}return r}initNotebookContent(){var{fileMetadata:e,settings:t,isPreview:n}=this.state;if(e&&e.id){_.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){_.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){var{glEventHub:n,metadata:r}=this.props,{id:a}=r;n.emit(W.REGISTER_FILE,a,e,t)}renameTab(e,t){var{glEventHub:n}=this.props;n.emit(W.RENAME,e,t)}load(){var{fileMetadata:e,settings:t}=this.state;D(e);var{id:n}=e,{fileStorage:r}=this.props;this.pending.add(r.loadFile(n)).then(a=>{var s;_.debug("Loaded file",a);var{filename:o}=a,{itemName:d}=this.state;if(o!==d){var{metadata:h}=this.props,{id:u}=h;this.renameTab(u,w.getBaseName(o))}var v=Se(Se({},t),{},{language:(s=le.languageFromFileName(o))!==null&&s!==void 0?s:""});t.value==null&&(v.value=a.content),t.wordWrap===void 0&&(t.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:v}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){var{fileMetadata:e}=this.state;if(e&&w.hasPath(e.itemName)){var t=this.getNotebookValue();return t!==void 0?(this.saveContent(e.itemName,t),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(e,t){_.debug("saveContent",e,t),this.updateSavedChangeCount();var{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:e,content:t,basename:e})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(e=>{var{changeCount:t}=e;return{savedChangeCount:t}})}setPreviewStatus(){if(this.tabTitleElement){var{isPreview:e}=this.state;_.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}}handlePreviewPromotion(){this.removePreviewStatus()}savePanelState(){this.setState(e=>{var{changeCount:t,savedChangeCount:n,fileMetadata:r,isPreview:a,settings:s}=e,o=this.getNotebookValue(),d=t!==n?o:void 0,h=Se(Se({},s),{},{value:o}),u=Se(Se({},s),{},{value:d}),v={settings:u,fileMetadata:r,isPreview:a};return _.debug("Saving panel state",v),{settings:h,panelState:v}})}handleCloseDiscard(){this.setState({showCloseModal:!1});var{glContainer:e}=this.props;e.close({force:!0})}handleCloseSave(){if(this.setState({showCloseModal:!1}),this.save()){var{glContainer:e}=this.props;e.close({force:!0})}}handleCloseCancel(){this.setState({showCloseModal:!1})}handleOverwrite(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e,itemName:e},{force:!0}),this.focus()}handleCopy(){var e=this;return Mi(function*(){var{fileStorage:t,glEventHub:n,session:r}=e.props,{fileMetadata:a,settings:s}=e.state;D(a);var{language:o}=s,{itemName:d}=a,h=yield w.getUniqueCopyFileName(t,d);_.debug("handleCopy",a,d,h),yield t.copyFile(d,h);var u={id:h,itemName:h},v={value:null,language:o};n.emit(W.SELECT_NOTEBOOK,r,o,v,u,!0)})()}handleDelete(){_.debug("handleDelete, pending confirmation"),this.setState({showDeleteModal:!0})}handleDeleteConfirm(){var e=this;return Mi(function*(){var{fileStorage:t,glContainer:n,glEventHub:r}=e.props,{fileMetadata:a}=e.state;_.debug("handleDeleteConfirm",a?.itemName),e.setState({showDeleteModal:!1}),a&&(w.hasPath(a.itemName)&&(yield w.fileExists(t,a.itemName))?(r.emit(W.CLOSE_FILE,a,{force:!0}),t.deleteFile(a.itemName)):n.close({force:!0}))})()}handleDeleteCancel(){this.setState({showDeleteModal:!1})}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){_.debug2("handleEditorChanged",e),this.removePreviewStatus(),this.setState(t=>{var{changeCount:n,savedChangeCount:r}=t,{isUndoing:a,isRedoing:s}=e;return a?{changeCount:n-1,savedChangeCount:r}:!s&&n<r?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:r}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){var{defaultNotebookSettings:e}=this.props;this.editor.updateOptions({minimap:{enabled:e.isMinimapEnabled}})}}handleMinimapChange(){var e,{defaultNotebookSettings:t,updateSettings:n}=this.props,r={defaultNotebookSettings:{isMinimapEnabled:!((e=t.isMinimapEnabled)!==null&&e!==void 0&&e)}};n(r)}updateEditorWordWrap(){if(this.editor){var{settings:e}=this.state,{wordWrap:t}=e;this.editor.updateOptions({wordWrap:t})}}handleWordWrapChange(){this.editor&&this.setState(e=>{var{settings:t}=e,n=t.wordWrap==="on"?"off":"on";return{settings:Se(Se({},t),{},{wordWrap:n})}})}handleBlur(){_.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){_.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(e){var{notebooksUrl:t,session:n,sessionLanguage:r}=this.props,{href:a}=e.currentTarget;if(!(!a||!a.startsWith(t))){e.stopPropagation(),e.preventDefault();var s="/".concat(a.substring(t.length)).replace(/%20/g," ");if(s==="/"){_.debug("Ignoring invalid notebook link",s);return}_.debug("Notebook link clicked, opening",s);var{glEventHub:o}=this.props,d={value:null,language:r},h={id:s,itemName:s};o.emit(W.SELECT_NOTEBOOK,n,r,d,h)}}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(e){var t=e;ce.isCanceled(t)||(ce.isTimedOut(t)&&(t=new Error("File not found.")),_.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){_.debug("handleSave"),this.save()}handleSaveSuccess(e){var t,{fileStorage:n}=this.props,r={id:e.filename,itemName:e.filename},a=(t=le.languageFromFileName(e.filename))!==null&&t!==void 0?t:"";this.setState(s=>{var{fileMetadata:o}=s,d=Se(Se({},s.settings),{},{language:a});return _.debug("handleSaveSuccess",r,o,d),o&&w.hasPath(o.itemName)&&o.itemName!==r.itemName&&(_.debug("handleSaveSuccess deleting old file",o.itemName),n.deleteFile(o.itemName).catch(le.handleError)),{fileMetadata:r,settings:d,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(r,!1)}handleSaveError(e){ce.isCanceled(e)||(this.setState({savedChangeCount:0}),_.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;n&&this.handleOverwrite(e),_.debug("handleSaveAsSubmit",e);var{fileMetadata:r}=this.state;if(r){var{itemName:a}=r,s=(t=this.getNotebookValue())!==null&&t!==void 0?t:"";if(this.setState({showSaveAsModal:!1}),w.getBaseName(a)!==w.getBaseName(e)){var{metadata:o}=this.props,{id:d}=o;this.renameTab(d,w.getBaseName(e))}this.saveContent(e,s)}}handleRenameFile(e,t,n){var{fileMetadata:r,panelState:a}=this.state,{glContainer:s}=this.props;if(r?.itemName==="/".concat(t)&&n&&JSON.stringify(a)!==JSON.stringify(n)){s.close();return}r&&r.id===e&&(this.setState({fileMetadata:{id:t,itemName:t}}),this.debouncedSavePanelState())}handleResize(){var e;(e=this.notebook)===null||e===void 0||e.updateDimensions()}handleRunCommand(e){this.runCommand(e)}handleRunAll(){var e;if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand((e=this.notebook.getValue())!==null&&e!==void 0?e:void 0)}handleRunSelected(){if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,sessionLanguage:n})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var e;_.debug("handleShow"),(e=this.notebook)===null||e===void 0||e.updateDimensions()}handlePanelDropped(e){var{metadata:{id:t}}=this.props;e===t&&this.forceUpdate()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){_.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];_.debug("handleTabFocus",...t);var{glContainer:r}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!r.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){_.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handleTabClick(e){_.debug("handle NotebookPanel tab click"),this.focus(),e.detail===2&&this.removePreviewStatus()}handleTransformLinkUri(e){var{notebooksUrl:t}=this.props,{fileMetadata:n}=this.state;if(e.endsWith("/"))return e;if(e.startsWith("/"))return"".concat(t).concat(e.substring(1));var r=n?.itemName;if(r===void 0)return e;r.charAt(0)==="/"&&(r=r.substring(1));var a=new URL(r,t);return new URL(e,a).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",{glEventHub:r}=this.props,{session:a,sessionLanguage:s,settings:o}=this.state,d=Se(Se({},o),{},{language:t,value:n}),h={id:null,itemName:e};_.debug("handleCreateNotebook",a,s,d,h),r.emit(W.CREATE_NOTEBOOK,a,s,d,h)}runCommand(e){if(e===void 0||e===""){_.debug("Ignoring empty command.");return}this.removePreviewStatus();var{glEventHub:t}=this.props;t.emit(we.SEND_COMMAND,e,!1,!0)}removePreviewStatus(){this.setState(e=>{var{isPreview:t}=e;if(t){var{fileMetadata:n}=this.state;return n&&this.registerFileMetadata(n,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){var e,t,{defaultNotebookSettings:n}=this.props,{settings:r}=this.state;return this.getOverflowActions((e=n.isMinimapEnabled)!==null&&e!==void 0?e:!1,this.getSettings(r,(t=n.isMinimapEnabled)!==null&&t!==void 0?t:!1).wordWrap==="on")}render(){var e,t,n,{fileStorage:r,glContainer:a,glContainer:{tab:s},glEventHub:o,defaultNotebookSettings:d}=this.props,{changeCount:h,savedChangeCount:u,error:v,isDashboardActive:m,isLoaded:p,isLoading:E,isPreview:S,fileMetadata:g,session:y,sessionLanguage:P,settings:O,showCloseModal:L,showDeleteModal:V,showSaveAsModal:Z}=this.state,A=m&&!a.isHidden&&!S,z=(e=g?.itemName)!==null&&e!==void 0?e:le.DEFAULT_NAME,G=z.endsWith(".md"),X=g?.id!=null,ve=this.getSettings(O,(t=d.isMinimapEnabled)!==null&&t!==void 0?t:!1),R=y!=null,$=P===ve.language,H=!p||!R||!$,N=!p,F=[{action:this.handleSave,shortcut:Zt.SAVE},{action:this.handleMinimapChange,shortcut:be.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:be.NOTEBOOK.WORDWRAP}],I=En.getDisabledRunTooltip(R,$,"Notebook extension","Run"),oe=En.getDisabledRunTooltip(R,$,"Notebook extension","Run Selected"),Ge=[{title:X?"Rename":"Save As…",order:10,group:k.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:k.groups.high,order:20}],ze=s?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[ze!=null&&Ui.createPortal(l.jsx("span",{className:ee(le.UNSAVED_INDICATOR_CLASS_NAME,{[le.UNSAVED_STATUS_CLASS_NAME]:h!==u})}),ze),l.jsxs(jt,{className:"notebook-container",componentPanel:this,glContainer:a,glEventHub:o,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabClicked:this.handleTabClick,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:Ge,renderTabTooltip:()=>z,children:[!G&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:H,icon:l.jsx(re,{icon:qt,transform:"grow-4"}),tooltip:"Run ".concat(be.NOTEBOOK.RUN.getDisplayText()),"aria-label":"Run"}),I!=null&&l.jsx(lt,{children:I})]}),l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:H,icon:l.jsx(re,{icon:ga,transform:"grow-4"}),tooltip:"Run Selected ".concat(be.NOTEBOOK.RUN_SELECTED.getDisplayText()),"aria-label":"Run Selected"}),oe!=null&&l.jsx(lt,{children:oe})]}),l.jsx(K,{kind:"ghost",className:"mr-auto",disabled:N,onClick:this.handleSave,icon:fa,tooltip:"Save ".concat(Zt.SAVE.getDisplayText()),"aria-label":"Save"}),l.jsx(K,{kind:"ghost",className:"btn-overflow",disabled:N,icon:zi,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(wt,{actions:this.getDropdownOverflowActions,popperOptions:le.POPPER_OPTIONS})})]}),l.jsx(qs,{isLoaded:p,isLoading:E,error:v,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:y,sessionLanguage:P,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:ve,focusOnMount:A,ref:f=>{this.notebook=f}})]}),G&&l.jsx(bd,{content:(n=ve.value)!==null&&n!==void 0?n:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(Fr,{isOpen:Z,type:"file",defaultValue:z,title:X?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:r}),l.jsx(Rt,{isOpen:V,headerText:'Are you sure you want to delete "'.concat(z,'"?'),bodyText:"You cannot undo this action.",onCancel:this.handleDeleteCancel,onConfirm:this.handleDeleteConfirm,confirmButtonText:"Delete"}),l.jsx(Rt,{isOpen:L,headerText:"Do you want to save the changes you made to ".concat(z,"?"),bodyText:"Your changes will be lost if you don't save them.",onCancel:this.handleCloseCancel,onDiscard:this.handleCloseDiscard,onConfirm:this.handleCloseSave,discardButtonText:"Discard Changes",confirmButtonText:"Save"}),l.jsx(k,{actions:F})]})]})}}ue(le,"COMPONENT","NotebookPanel");ue(le,"POPPER_OPTIONS",{placement:"bottom-end"});ue(le,"DEFAULT_NAME","Untitled");ue(le,"UNSAVED_INDICATOR_CLASS_NAME","editor-unsaved-indicator");ue(le,"UNSAVED_STATUS_CLASS_NAME","is-unsaved");ue(le,"defaultProps",{isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:{isMinimapEnabled:!0}});var Ed=(i,e)=>{var t=mr(i),n=Oo(i),r=_t(i,e.localDashboardId),{session:a,config:s}=r??{},{type:o}=s??{};return{fileStorage:t,defaultNotebookSettings:n,session:a,sessionLanguage:o}},yd=Mt(Ed,{updateSettings:Mo},null,{forwardRef:!0})(le);const rt=yd;function ji(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function _i(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ji(Object(t),!0).forEach(function(n){Td(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ji(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Td(i,e,t){return e=Pd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Pd(i){var e=Od(i,"string");return typeof e=="symbol"?e:String(e)}function Od(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ie=Q.module("ConsolePlugin");function ki(i){return i.notebook!==void 0}function wd(i){Ba(i)}function Ch(i){wd(i);var{id:e,hydrateConsole:t,layout:n,panelManager:r,registerComponent:a,notebooksUrl:s}=i,o=c.useRef(0),[d,h]=c.useState(new Map),[u,v]=c.useState(new Map),m=zr(),p=c.useCallback(()=>r.getLastUsedPanelOfType(gn),[r]),E=c.useCallback((f,b)=>{h(T=>new Map(T.set(f,b)))},[h]),S=c.useCallback(f=>{h(b=>(b.delete(f),new Map(b)))},[h]),g=c.useCallback((f,b)=>{v(T=>new Map(T.set(f,b)))},[v]),y=c.useCallback(f=>{v(b=>(b.delete(f),new Map(b)))},[v]),P=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,x=f&&f.trim();if(!x)ie.info("Ignoring empty code");else{var j=p();if(!j||!(j instanceof gn.WrappedComponent)){ie.error("Console panel not found");return}ie.debug("Send command: ",f,b,T),j.addCommand(f,b,T)}},[p]),O=c.useCallback(f=>{m(yl(e,f))},[m,e]),L=c.useCallback(f=>{var{language:b}=f,T=b==="python"?"py":b,x=null;return T==null?(ie.debug("No extension for language",b),x="Untitled-".concat(o.current)):x="Untitled-".concat(o.current,".").concat(T),o.current+=1,x},[]),V=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{id:T}=f;if(T!=null&&d.has(T))return d.get(T);if(T!=null&&u.has(T))return u.get(T);if(b)return $i.generate()},[d,u]),Z=c.useCallback((f,b)=>{se.renameComponent(n.root,{id:f},b)},[n.root]),A=c.useCallback((f,b)=>{ie.debug("Rename file panel",f,b);var T;if(d.has(f)&&(T=d.get(f),S(f),T!=null&&E(b,T)),u.has(f)&&(T=u.get(f),y(f),T!=null&&g(b,T)),T===void 0){ie.debug2("File ".concat(f," isn't open, no need to rename the tab"));return}Z(T,w.getBaseName(b))},[d,u,Z,E,g,S,y]),z=c.useCallback(f=>{var b=V(f,!1);if(b==null){ie.error("Could not find panel id for file metadata",f);return}se.activateTab(n.root,{id:b})},[V,n.root]),G=c.useCallback((f,b,T)=>{if(ie.debug("registerFilePanel",f,b,T),b==null||b.id==null){ie.debug("Ignore empty file id",b);return}var{id:x}=b;if(T){g(x,f);return}if(d.has(x)){var j=d.get(x);if(f===j){ie.debug("Update tab title for file ".concat(x));var{itemName:$e}=b;A(x,$e)}else ie.error("File ".concat(x," already associated with a different tab ").concat(j));return}E(x,f),u.has(x)&&y(x)},[d,u,A,E,g,y]),X=c.useCallback((f,b)=>{if(ie.debug("unregisterFileTab",f,b),f==null||f.id==null){ie.debug("Ignore empty file id",f);return}var{id:T}=f;if(b){y(T);return}S(T)},[S,y]),ve=c.useCallback((f,b)=>{ie.debug("closeFilePanel",f);var{id:T}=f,x=null,j=!1;if(d.has(T))x=d.get(T);else if(u.has(T))x=u.get(T),j=!0;else{ie.debug("File ".concat(T," isn't open, ignore close event"));return}X(f,j),se.closeComponent(n.root,{id:x},b)},[n.root,d,u,X]),R=c.useCallback(f=>{var{itemName:b}=f;return w.getBaseName(b)},[]),$=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpen",f,b,d),b!=null&&d.has(b)},[d]),H=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpenAsPreview",f,b,u),b!=null&&u.has(b)},[u]),N=c.useCallback(f=>{if(f!=null){var b=r.getOpenedPanelById(f);b&&ki(b)&&b.focus()}},[r]),F=c.useCallback(f=>{var{id:b,settings:T,fileMetadata:x,session:j,sessionLanguage:$e,isPreview:C=!1}=f,M={settings:T,fileMetadata:x},B=R(x);return{type:"react-component",component:rt.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:b},session:j,sessionLanguage:$e,panelState:M,isPreview:C,notebooksUrl:s},title:B,id:b}},[R,e,s]),I=c.useCallback(function(f,b,T){var x=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{id:null,itemName:L(T)},j=V(x);if($(x)&&j!=null){ie.debug("File is already open, focus panel"),z(x),N(j);return}var $e=se.getStackForComponentTypes(n.root,[rt.COMPONENT]),C=F({id:j,settings:T,fileMetadata:x,session:f,sessionLanguage:b});ie.debug("createNotebook",C,d),se.openComponentInStack($e,C)},[$,N,L,V,n.root,F,d,z]),oe=c.useCallback(function(f,b,T,x){var j=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;ie.debug("selectNotebook",x,j);var $e=$(x),C=H(x),[M]=[...u.values()],B=!j,te=B&&M?M:V(x);if(te==null||te==="")throw new Error("Unable to retrieve or create panelId for metadata",x);if($e||C)z(x);else{var me=se.getStackForComponentTypes(n.root,[rt.COMPONENT]),_r=F({id:te,settings:T,fileMetadata:x,session:f,sessionLanguage:b,isPreview:B});se.openComponentInStack(me,_r)}if(C&&j){var jn=x.id,kr=se.getStackForConfig(n.root,{component:rt.COMPONENT,id:te}),dn=se.getContentItemInStack(kr,{component:rt.COMPONENT,id:te});dn&&Ua(dn)&&(dn.container.emit(W.PROMOTE_FROM_PREVIEW),y(jn),E(jn,te))}j&&N(te)},[z,$,H,N,V,n.root,F,u,y,E]),Ge=c.useCallback(function(f,b){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},x=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,j=r.getLastUsedPanelOfType(rt);j&&ki(j)?T!=null&&T.value!=null&&j.notebook!=null&&j.notebook.append(T.value):x&&I(f,b,T)},[I,r]),ze=c.useCallback((f,b)=>$a.hydrate(_i(_i({},f),{},{notebooksUrl:s}),b),[s]);return Ct(a,gn,t),Ct(a,Nl),Ct(a,hd),Ct(a,pd),Ct(a,rt,ze),Le(n.eventHub,we.SEND_COMMAND,P),Le(n.eventHub,we.SETTINGS_CHANGED,O),Le(n.eventHub,W.CLOSE_FILE,ve),Le(n.eventHub,W.CREATE_NOTEBOOK,I),Le(n.eventHub,W.SELECT_NOTEBOOK,oe),Le(n.eventHub,W.RENAME,Z),Le(n.eventHub,W.RENAME_FILE,A),Le(n.eventHub,W.SEND_TO_NOTEBOOK,Ge),Le(n.eventHub,W.REGISTER_FILE,G),Le(n.eventHub,W.UNREGISTER_FILE,X),null}function ln(i,e,t){return e=Nd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Nd(i){var e=xd(i,"string");return typeof e=="symbol"?e:String(e)}function xd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ht{}ln(Ht,"DROPDOWN_FILTER","ControlType.DROPDOWN_FILTER");ln(Ht,"INPUT_FILTER","ControlType.INPUT_FILTER");ln(Ht,"MARKDOWN","ControlType.MARKDOWN");ln(Ht,"FILTER_SET_MANAGER","ControlType.FILTER_SET_MANAGER");const Sh=Ht;export{sh as $,w as A,Mn as B,Sh as C,zd as D,Zd as E,hd as F,Xd as G,ch as H,pi as I,vh as J,Jd as K,pd as L,nh as M,W as N,Va as O,Gd as P,Lo as Q,Yd as R,qd as S,ih as T,eh as U,Ad as V,jt as W,gh as X,oh as Y,lh as Z,dh as _,kd as a,Rr as a0,He as a1,rh as a2,bh as a3,ah as a4,Dn as a5,De as a6,Ir as a7,mh as a8,ph as a9,fh as aa,we as ab,Vt as ac,yl as ad,hh as ae,Hd as b,Md as c,$d as d,Bd as e,Vd as f,_d as g,Po as h,jd as i,Wd as j,Ud as k,gn as l,Nl as m,Qd as n,Io as o,Kd as p,wo as q,Je as r,th as s,uh as t,Mo as u,_t as v,Fd as w,To as x,rt as y,Ch as z};
21
+ //# sourceMappingURL=ControlType-ccb39f97.js.map