@deephaven/embed-grid 0.23.1-beta.4 → 0.23.1-beta.6

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.
@@ -19,7 +19,7 @@ ${o}`);for(let r=0;r<e;r+=1){const l=this.type.shouldTrim?t[i][r].trim():t[i][r]
19
19
  `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:null},EXCEL_CSV:{name:"Excel csv (strict)",delimiter:",",newline:`\r
20
20
  `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},MY_SQL_CSV:{name:"MySQL csv",delimiter:" ",newline:`
21
21
  `,escapeChar:"\\",shouldTrim:!0,skipEmptyLines:!1,nullString:"\\N"},RFC4180_CSV:{name:"RFC4180 csv",delimiter:",",newline:`\r
22
- `,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 Rl=ee.module("CsvInputBar"),ig=Object.entries(kn.TYPES).map(([e,t])=>h("option",{value:e,children:t.name},e));class ja extends y.exports.Component{constructor(t){super(t),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=Z.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:kn.DEFAULT_TYPE,parser:null}}componentDidUpdate(t){var r;const{file:n,paste:s}=this.props,{tableName:i,tableNameSet:o}=this.state;if(!o&&n!=null&&!i){const l=n.name.lastIndexOf("."),a=Un.legalizeTableName(n.name.substring(0,l));this.setState({tableName:a,tableNameSet:!0}),(r=this.inputRef.current)==null||r.focus()}else(n==null&&t.file!=null||s==null&&t.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});s!=null&&s!==""&&!i&&this.inputRef.current&&this.inputRef.current.focus(),n!=null&&n!==t.file?this.setState({type:kn.fromExtension(n.name)}):s!=null&&s!==""&&(t.paste===void 0||t.paste==="")&&this.setState({type:kn.AUTO})}componentWillUnmount(){const{parser:t}=this.state;t&&t.cancel()}handleCancel(){const{onClose:t}=this.props;t()}handleError(t){const{onClose:n,onError:s}=this.props;Rl.error(t),s(t),n()}handleTableName(t){this.setState({tableName:t.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){const{isFirstRowHeaders:t}=this.state;this.setState({isFirstRowHeaders:!t})}handleUpload(t){t.stopPropagation(),t.preventDefault();const{file:n,paste:s}=this.props;n!=null?n.name.endsWith(".zip")?this.handleZipFile(n):this.handleFile(n):s!==void 0&&s!==""&&this.handleFile(new Blob([s],{type:"text/plain"}))}handleFile(t,n=!1){Rl.info(`Starting CSV parser for ${t instanceof File?t.name:"pasted values"} ${n?"":t.size} bytes`);const{session:s,timeZone:i,onInProgress:o}=this.props,{tableName:r,isFirstRowHeaders:l,type:a}=this.state,c=u=>{u.length===1?s.bindTableToVariable(u[0],r).then(()=>this.openTable()).catch(m=>this.handleError(m)):s.mergeTables(u).then(m=>{s.bindTableToVariable(m,r).then(()=>this.openTable()).catch(p=>this.handleError(p)),u.forEach(p=>p.close())}).catch(m=>this.handleError(m))},d=new Qa({onFileCompleted:c,session:s,file:t,type:kn.TYPES[a],readHeaders:l,onProgress:this.handleProgress,onError:this.handleError,timeZone:i,isZip:n});d.parse(),this.setState({showProgress:!0,parser:d}),o(!0)}handleZipFile(t){const{onUpdate:n,unzip:s}=this.props;if(s==null){this.handleError(new Error("No support for zip files available."));return}s(t).then(i=>{let o=!1;for(let r=0;r<i.length;r+=1){const l=i[r];if(mn.isValidExtension(l.name)){n(`Loading ${l.name} as csv from ${t.name}`),o=!0,this.handleFile(l,!0);break}}if(!o)throw new Error(`No csv file found in ${t.name}`)}).catch(i=>this.handleError(i))}handleProgress(t){const{showProgress:n}=this.state;return n&&this.setState({progressValue:t}),!n}handleCancelInProgress(){const{onInProgress:t}=this.props,{parser:n}=this.state;n&&n.cancel(),this.setState({showProgress:!1,progressValue:0}),t(!1)}openTable(){const{onOpenTable:t,onClose:n}=this.props,{tableName:s}=this.state;t(s),n()}handleQueryTypeChange(t){this.setState({type:t.target.value})}render(){const{file:t,paste:n}=this.props,{tableName:s,isFirstRowHeaders:i,showProgress:o,progressValue:r,type:l}=this.state,a=Boolean(n)&&!s;return E("div",{className:"csv-input-bar",children:[!o&&E("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[E("div",{className:"form-group",children:[h("label",{htmlFor:"tableNameInput",children:"Table name"}),h("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:z("form-control",{"is-invalid":a}),value:s,onChange:this.handleTableName})]}),E("div",{className:"form-group",children:[h("label",{htmlFor:"formatSelect",children:"File format"}),h("select",{id:"formatSelect",className:"custom-select",value:l,onChange:this.handleQueryTypeChange,children:ig})]}),h(at,{className:"firstRowHeaders",checked:i,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),E("div",{className:"csv-input-buttons form-group",children:[h(Y,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),h(Y,{kind:"primary",type:"submit",disabled:!(t!==null||n!==void 0&&n!=="")||!s,children:"Upload"})]})]}),o&&E("div",{className:"csv-progress-container",children:[h("label",{children:"Uploading Table"}),h("div",{className:"progress",children:h("div",{className:"progress-bar bg-primary",style:{width:`${r}%`},"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100})}),E("label",{children:[r,"%"]}),h(Y,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}ja.defaultProps={file:null,paste:null,unzip:null};const Il=ee.module("ConsoleMenu");class qi extends y.exports.PureComponent{constructor(t){super(t),this.makeTableActions=Re((n,s,i)=>{const o=n.filter(r=>Fs.isTableType(r.type));return qi.makeItemActions(o,s,r=>{this.tableSearchField=r},this.handleTableFilterChange,i)}),this.makeWidgetActions=Re((n,s,i)=>{const o=n.filter(r=>Fs.isWidgetType(r.type));return qi.makeItemActions(o,s,r=>{this.widgetSearchField=r},this.handleWidgetFilterChange,i)}),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:""}}static makeItemActions(t,n,s,i,o){if(t.length===0)return[];const r={menuElement:h(Bn,{value:n,onChange:i,className:"console-menu",ref:s})};let l=t;n&&(l=l.filter(({title:c})=>c!=null&&c.toLowerCase().indexOf(n.toLowerCase())>=0));const a=l.map(c=>({title:c.title,action:()=>{o(c)}}));return[r,...a]}handleTableFilterChange(t){Il.debug("filtering tables..."),this.setState({tableFilterText:t.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){var t;(t=this.tableSearchField)==null||t.focus()}handleWidgetFilterChange(t){Il.debug("filtering widgets..."),this.setState({widgetFilterText:t.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){var t;(t=this.widgetSearchField)==null||t.focus()}render(){const{overflowActions:t,objects:n,openObject:s}=this.props,{tableFilterText:i,widgetFilterText:o}=this.state,r=this.makeTableActions(n,i,s),l=this.makeWidgetActions(n,o,s),a={placement:"bottom-end"};return E("div",{className:"console-pane-menu",children:[E(Y,{kind:"ghost",className:"btn-link-icon",disabled:r.length===0,onClick:()=>{},children:[E("div",{className:"fa-md fa-layers",children:[h(K,{mask:tr,icon:On,transform:"right-5 down-5"}),h(K,{icon:On,transform:"right-8 down-6"})]}),h(He,{children:"Tables"}),h(Pn,{actions:r,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions ")]}),E(Y,{kind:"ghost",className:"btn-link-icon",disabled:l.length===0,onClick:()=>{},children:[E("div",{className:"fa-md fa-layers",children:[h(K,{mask:Wl,icon:On,transform:"right-5 down-5"}),h(K,{icon:On,transform:"right-8 down-6"})]}),h(He,{children:"Widgets"}),h(Pn,{actions:l,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions")]}),h(Y,{kind:"ghost",className:"btn-overflow btn-link-icon",icon:ud,tooltip:"More Actions...",onClick:()=>{},children:h(Pn,{actions:t,popperOptions:a})})]})}}class Za extends y.exports.PureComponent{constructor(t){super(t),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new Zi,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}startListening(){const{session:t}=this.props;t.addEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){const{session:t}=this.props;t.removeEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(t){const{result:n}=t.detail;this.pending.add(n).then(()=>this.handleCommandCompleted(null)).catch(s=>this.handleCommandCompleted(s)),this.setState({isCommandRunning:!0})}handleCommandCompleted(t){t instanceof Is||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){const{children:t,openObject:n,overflowActions:s,objects:i}=this.props,{isDisconnected:o,isCommandRunning:r}=this.state;let l=null,a=null;return o?(l="console-status-icon-disconnected",a="Worker is disconnected"):r?(l="console-status-icon-pending",a="Worker is busy"):(l="console-status-icon-idle",a="Worker is idle"),E("div",{className:"console-pane-status-bar",children:[E("div",{children:[h("div",{className:z("console-status-icon",l)}),h(He,{children:a})]}),t,h(qi,{overflowActions:s,openObject:n,objects:i})]})}}Za.defaultProps={children:null};const En=ee.module("Console"),Ml={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0},Ys=class extends y.exports.PureComponent{constructor(e){super(e),this.processLogMessageQueue=ls(()=>{this.scrollConsoleHistoryToBottom(),this.setState(s=>{En.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");let{consoleHistory:i}=s;return i=i.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:i}})},Ys.LOG_THROTTLE),this.getObjects=Re(s=>[...s.values()]),this.getContextActions=Re(s=>[...s,{action:this.handleClearShortcut,shortcut:rs.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:rs.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=Z.createRef(),this.consoleInput=Z.createRef(),this.consoleHistoryScrollPane=Z.createRef(),this.pending=new Zi,this.queuedLogMessages=[];const{objectMap:t,settings:n}=this.props;this.state={consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1,...Ml,...n}}static isErrorLevel(e){return e===Ye.STDERR||e===Ye.ERROR||e===Ye.FATAL}static isOutputLevel(e){return e===Ye.STDOUT||Ys.isErrorLevel(e)}componentDidMount(){this.initConsoleLogging();const{session:e}=this.props;e.addEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){const{props:n,state:s}=this;this.sendSettingsChange(t,s),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){const{session:e}=this.props;e.removeEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}initConsoleLogging(){const{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.clear()}handleCommandStarted(e){const{code:t,result:n}=e.detail,s=this.pending.add(n),i={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:s},{commandHistoryStorage:o,language:r,scope:l}=this.props,a=o.addItem(r,l,t,{command:t,startTime:new Date().toJSON()});a.catch(c=>{En.debug("Error adding workspace item",c)}),this.setState(c=>({consoleHistory:c.consoleHistory.concat(i)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),s.then(c=>{this.handleCommandResult(c,i,a)}).catch(c=>{this.handleCommandError(c,i,a)})}handleCommandResult(e,t,n){const s=t;s.wrappedResult=void 0,s.cancelResult=void 0,e&&(s.result=e,this.updateHistory(e,s),this.updateKnownObjects(s),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){const s=t;if(s.wrappedResult=void 0,s.cancelResult=void 0,Pe.isCanceled(e)){En.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:`${e}`},n),this.setState(i=>{const o=i.consoleHistory.concat(),r=o.lastIndexOf(s);return s.endTime=Date.now(),s.result={error:e},o[r]={...s},{consoleHistory:o}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();const{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){const{isPrintStdOutEnabled:t}=this.state;!t||Ys.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){const n={};Ys.isErrorLevel(t)?n.error=e:n.message=e;const s={command:void 0,result:n};this.queuedLogMessages.push(s),this.processLogMessageQueue()}openUpdatedItems(e){const{isAutoLaunchPanelsEnabled:t}=this.state;if(e==null||!t)return;const{openObject:n}=this.props;[...e.created,...e.updated].forEach(s=>n(s))}closeRemovedItems(e){if(e==null||e.removed==null||e.removed.length===0)return;const{closeObject:t}=this.props,{removed:n}=e;n.forEach(s=>t(s))}updateHistory(e,t){const n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(s=>({consoleHistory:s.consoleHistory.concat()})))}updateKnownObjects(e){let 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)){En.debug2("updateKnownObjects no changes");return}this.setState(n=>{const s=n.consoleHistory.concat(),i=s.lastIndexOf(e);if(i<0)return En.error("historyItem not found in state.consoleHistory"),null;const o=new Map(n.objectHistoryMap),r=new Map(n.objectMap),l=(a,c=!1)=>{var m;const{title:d}=a;x(d);const u=o.get(d);u!=null&&u>=0&&(s[u].disabledObjects=[...(m=s[u].disabledObjects)!=null?m:[],d]),o.set(d,i),c?r.delete(d):r.set(d,a)};return t==null||t.updated.forEach(a=>l(a)),t==null||t.removed.forEach(a=>l(a,!0)),t==null||t.created.forEach(a=>{const{title:c}=a;x(c),o.set(c,i),r.set(c,a)}),{objectHistoryMap:o,objectMap:r,consoleHistory:s}})}updateObjectMap(){const{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){const n=this.pending.add(t),s=new Date().toJSON();n.then(i=>{const o={...i,data:{...i.data,endTime:s,result:e}},{commandHistoryStorage:r,language:l}=this.props;r.updateItem(l,o).catch(a=>{En.warn("Error updating command history storage",a)})}).catch(i=>{En.debug("Error updating workspace history item",i)})}scrollConsoleHistoryToBottom(e=!1){const t=this.consoleHistoryScrollPane.current;x(t),!(!e&&t.scrollTop<t.scrollHeight-t.offsetHeight)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){const e=this.consoleHistoryScrollPane.current;x(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")return;e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});const{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:mn.MULTIPLE_FILE_ERROR});return}const n=t[0];mn.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:mn.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){const{openObject:t,commandHistoryStorage:n,language:s,scope:i}=this.props,{consoleHistory:o,objectMap:r}=this.state,l={name:e,title:e,type:T.VariableType.TABLE},a=r.has(e),c={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[a?"updated":"created"]:[l]}}},d=o.concat(c);this.setState({consoleHistory:d}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(c),t({name:e,title:e,type:T.VariableType.TABLE}),n.addItem(s,i,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){const{consoleHistory:n}=this.state,s={command:"",startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},i=n.concat(s);this.setState({consoleHistory:i})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?`${e}`:void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){const{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:s}=this.props;return[...s,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:oe.groups.high,icon:n?is:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:oe.groups.high,icon:e?is:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:oe.groups.high,icon:t?is:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:oe.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){const{session:t}=this.props;t.runCode(e).catch(n=>{En.error("There was an error initiating the command",n)})}else{const t={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(n=>({consoleHistory:n.consoleHistory.concat(t)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{const t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}addCommand(e,t=!0,n=!1){!this.consoleInput.current||(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){var e;(e=this.consoleInput.current)==null||e.focus()}sendSettingsChange(e,t,n=!0){const s=Object.keys(Ml),i={};let o=!1;for(let l=0;l<s.length;l+=1){const a=s[l],{[a]:c}=t,{[a]:d}=e;c!==d&&(o=!0),i[a]=c}if(n&&!o)return;const{onSettingsChange:r}=this.props;r(i)}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){const{actions:e,historyChildren:t,language:n,statusBarChildren:s,openObject:i,session:o,scope:r,commandHistoryStorage:l,timeZone:a,disabled:c,unzip:d}=this.props,{consoleHeight:u,consoleHistory:m,isScrollDecorationShown:p,objectMap:g,showCsvOverlay:f,csvFile:C,csvPaste:b,dragError:w,csvUploadInProgress:v}=this.state,I=this.getObjects(g),S=Math.round(u*.7),R=this.getContextActions(e);return E("div",{role:"presentation",className:z("iris-console","h-100","w-100",{disabled:c}),children:[E("div",{className:"console-pane",ref:this.consolePane,children:[h(Za,{session:o,overflowActions:this.handleOverflowActions,openObject:i,objects:I,children:s}),E("div",{className:"console-csv-container",onDragOver:mn.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[f&&h(mn,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:w,onError:this.handleCsvError,uploadInProgress:v,allowZip:d!=null}),E("div",{role:"presentation",className:z("scroll-pane no-scroll-x",{"scroll-decoration":p}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[h(Ga,{items:m,openObject:i,language:n,disabled:c}),t]})]}),!f&&h($i,{ref:this.consoleInput,session:o,language:n,scope:r,onSubmit:this.handleCommandSubmit,maxHeight:S,commandHistoryStorage:l}),f&&h(ja,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:C!=null?C:void 0,paste:b!=null?b:void 0,onInProgress:this.handleCsvInProgress,timeZone:a,unzip:d})]}),h(oe,{actions:R,ignoreClassNames:[$i.INPUT_CLASS_NAME]})]})}};let Ja=Ys;Ja.defaultProps={statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null};Ja.LOG_THROTTLE=500;class Er extends y.exports.Component{constructor(t){super(t),this.handleResize=this.handleResize.bind(this),this.container=null,this.state={}}componentDidMount(){this.initEditor(),window.addEventListener("resize",this.handleResize)}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),this.destroyEditor()}setLanguage(t){if(this.editor){const n=this.editor.getModel();x(n),pn.setModelLanguage(n,t)}}handleResize(){this.updateDimensions()}toggleFind(){this.editor&&(this.editor.focus(),this.editor.trigger("toggleFind","actions.find",void 0))}updateDimensions(){var t;(t=this.editor)==null||t.layout()}initEditor(){const{onEditorInitialized:t}=this.props;let{settings:n}=this.props;n={copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"python",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,tabCompletion:"on",value:"",wordWrap:"off",...n},x(this.container),this.editor=pn.create(this.container,n),this.editor.addAction({id:"find",label:"Find",keybindings:[Rt.CtrlCmd|Yt.KeyF],precondition:void 0,keybindingContext:void 0,contextMenuGroupId:"navigation",contextMenuOrder:1,run:()=>{this.toggleFind()}}),this.editor.layout(),Ue.removeConflictingKeybindings(this.editor),t(this.editor)}destroyEditor(){const{onEditorWillDestroy:t}=this.props;x(this.editor),t(this.editor),this.editor.dispose(),this.editor=void 0}render(){const{className:t}=this.props;return h("div",{className:z("editor-container",t),ref:n=>{this.container=n}})}}Er.defaultProps={className:"fill-parent-absolute",onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},settings:{}};const yt=ee.module("ScriptEditor");class og extends y.exports.Component{constructor(t){super(t),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=Z.createRef(),this.state={model:null}}componentDidMount(){ye.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(t){var d,u;const{sessionLanguage:n,settings:s}=this.props,i=s==null?void 0:s.language;i!==((d=t.settings)==null?void 0:d.language)&&(yt.debug("Set language",i),this.setLanguage(i));const r=n==null&&t.sessionLanguage!=null,l=i===n,a=((u=t.settings)==null?void 0:u.language)===t.sessionLanguage;(r||n!==void 0&&a&&!l)&&(yt.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion()),(n!=null&&t.sessionLanguage==null&&l||n!==void 0&&!a&&l)&&(yt.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){ye.removeEventListener("onUpdate",this.updateShortcuts)}getValue(){return this.editor?this.editor.getValue():(yt.error("Editor not initialized"),null)}getSelectedCommand(){var c,d;const t=(c=this.editor)==null?void 0:c.getSelection();x(t);const n=(d=this.editor)==null?void 0:d.getModel();x(n);const{startLineNumber:s,endColumn:i}=t;let{endLineNumber:o}=t;i===1&&o>s&&(o-=1);const r=n==null?void 0:n.getLineMinColumn(s),l=n==null?void 0:n.getLineMaxColumn(o),a=t.setStartPosition(s,r).setEndPosition(o,l);return n==null?void 0:n.getValueInRange(a)}handleEditorInitialized(t){const{focusOnMount:n,onChange:s,onEditorInitialized:i,settings:o,session:r,sessionLanguage:l}=this.props;yt.debug("handleEditorInitialized",l,r,o),this.editor=t,this.setState({model:this.editor.getModel()}),Ue.setEOL(t),Ue.registerPasteHandler(t),r!=null&&o&&l===o.language&&(this.initContextActions(),this.initCodeCompletion()),t.onDidChangeModelContent(s),n!=null&&n&&t.focus(),i(this.editor)}handleEditorWillDestroy(t){yt.debug("handleEditorWillDestroy");const{onEditorWillDestroy:n}=this.props;n(t),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){const{onRunCommand:t}=this.props,n=this.getValue();n!=null&&t(n)}handleRunSelected(){const{onRunCommand:t}=this.props,n=this.getSelectedCommand();t(n)}initContextActions(){if(this.contextActionCleanups.length>0){yt.error("Context actions already initialized.");return}if(!this.editor)return;const t=[];t.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Ue.getMonacoKeyCodeFromShortcut(rs.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),t.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Ue.getMonacoKeyCodeFromShortcut(rs.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=t}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(t=>t.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){yt.error("Code completion already initialized.");return}const{session:t}=this.props;yt.debug("initCodeCompletion",this.editor,t),this.editor&&t!=null&&(this.completionCleanup=Ue.openDocument(this.editor,t))}deInitCodeCompletion(){const{session:t}=this.props;yt.debug("deInitCodeCompletion",this.editor,t),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0),this.editor&&t!=null&&Ue.closeDocument(this.editor,t)}append(t,n=!0){x(this.editor);const s=this.editor.getModel();x(s);const i=s.getValue();i?s.setValue(`${i}
22
+ `,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 Rl=ee.module("CsvInputBar"),ig=Object.entries(kn.TYPES).map(([e,t])=>h("option",{value:e,children:t.name},e));class ja extends y.exports.Component{constructor(t){super(t),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=Z.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:kn.DEFAULT_TYPE,parser:null}}componentDidUpdate(t){var r;const{file:n,paste:s}=this.props,{tableName:i,tableNameSet:o}=this.state;if(!o&&n!=null&&!i){const l=n.name.lastIndexOf("."),a=Un.legalizeTableName(n.name.substring(0,l));this.setState({tableName:a,tableNameSet:!0}),(r=this.inputRef.current)==null||r.focus()}else(n==null&&t.file!=null||s==null&&t.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});s!=null&&s!==""&&!i&&this.inputRef.current&&this.inputRef.current.focus(),n!=null&&n!==t.file?this.setState({type:kn.fromExtension(n.name)}):s!=null&&s!==""&&(t.paste===void 0||t.paste==="")&&this.setState({type:kn.AUTO})}componentWillUnmount(){const{parser:t}=this.state;t&&t.cancel()}handleCancel(){const{onClose:t}=this.props;t()}handleError(t){const{onClose:n,onError:s}=this.props;Rl.error(t),s(t),n()}handleTableName(t){this.setState({tableName:t.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){const{isFirstRowHeaders:t}=this.state;this.setState({isFirstRowHeaders:!t})}handleUpload(t){t.stopPropagation(),t.preventDefault();const{file:n,paste:s}=this.props;n!=null?n.name.endsWith(".zip")?this.handleZipFile(n):this.handleFile(n):s!==void 0&&s!==""&&this.handleFile(new Blob([s],{type:"text/plain"}))}handleFile(t,n=!1){Rl.info(`Starting CSV parser for ${t instanceof File?t.name:"pasted values"} ${n?"":t.size} bytes`);const{session:s,timeZone:i,onInProgress:o}=this.props,{tableName:r,isFirstRowHeaders:l,type:a}=this.state,c=u=>{u.length===1?s.bindTableToVariable(u[0],r).then(()=>this.openTable()).catch(m=>this.handleError(m)):s.mergeTables(u).then(m=>{s.bindTableToVariable(m,r).then(()=>this.openTable()).catch(p=>this.handleError(p)),u.forEach(p=>p.close())}).catch(m=>this.handleError(m))},d=new Qa({onFileCompleted:c,session:s,file:t,type:kn.TYPES[a],readHeaders:l,onProgress:this.handleProgress,onError:this.handleError,timeZone:i,isZip:n});d.parse(),this.setState({showProgress:!0,parser:d}),o(!0)}handleZipFile(t){const{onUpdate:n,unzip:s}=this.props;if(s==null){this.handleError(new Error("No support for zip files available."));return}s(t).then(i=>{let o=!1;for(let r=0;r<i.length;r+=1){const l=i[r];if(mn.isValidExtension(l.name)){n(`Loading ${l.name} as csv from ${t.name}`),o=!0,this.handleFile(l,!0);break}}if(!o)throw new Error(`No csv file found in ${t.name}`)}).catch(i=>this.handleError(i))}handleProgress(t){const{showProgress:n}=this.state;return n&&this.setState({progressValue:t}),!n}handleCancelInProgress(){const{onInProgress:t}=this.props,{parser:n}=this.state;n&&n.cancel(),this.setState({showProgress:!1,progressValue:0}),t(!1)}openTable(){const{onOpenTable:t,onClose:n}=this.props,{tableName:s}=this.state;t(s),n()}handleQueryTypeChange(t){this.setState({type:t.target.value})}render(){const{file:t,paste:n}=this.props,{tableName:s,isFirstRowHeaders:i,showProgress:o,progressValue:r,type:l}=this.state,a=Boolean(n)&&!s;return E("div",{className:"csv-input-bar",children:[!o&&E("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[E("div",{className:"form-group",children:[h("label",{htmlFor:"tableNameInput",children:"Table name"}),h("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:z("form-control",{"is-invalid":a}),value:s,onChange:this.handleTableName})]}),E("div",{className:"form-group",children:[h("label",{htmlFor:"formatSelect",children:"File format"}),h("select",{id:"formatSelect",className:"custom-select",value:l,onChange:this.handleQueryTypeChange,children:ig})]}),h(at,{className:"firstRowHeaders",checked:i,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),E("div",{className:"csv-input-buttons form-group",children:[h(Y,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),h(Y,{kind:"primary",type:"submit",disabled:!(t!==null||n!==void 0&&n!=="")||!s,children:"Upload"})]})]}),o&&E("div",{className:"csv-progress-container",children:[h("label",{children:"Uploading Table"}),h("div",{className:"progress",children:h("div",{className:"progress-bar bg-primary",style:{width:`${r}%`},"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100})}),E("label",{children:[r,"%"]}),h(Y,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}ja.defaultProps={file:null,paste:null,unzip:null};const Il=ee.module("ConsoleMenu");class qi extends y.exports.PureComponent{constructor(t){super(t),this.makeTableActions=Re((n,s,i)=>{const o=n.filter(r=>Fs.isTableType(r.type));return qi.makeItemActions(o,s,r=>{this.tableSearchField=r},this.handleTableFilterChange,i)}),this.makeWidgetActions=Re((n,s,i)=>{const o=n.filter(r=>Fs.isWidgetType(r.type));return qi.makeItemActions(o,s,r=>{this.widgetSearchField=r},this.handleWidgetFilterChange,i)}),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:""}}static makeItemActions(t,n,s,i,o){if(t.length===0)return[];const r={menuElement:h(Bn,{value:n,onChange:i,className:"console-menu",ref:s})};let l=t;n&&(l=l.filter(({title:c})=>c!=null&&c.toLowerCase().indexOf(n.toLowerCase())>=0));const a=l.map(c=>({title:c.title,action:()=>{o(c)}}));return[r,...a]}handleTableFilterChange(t){Il.debug("filtering tables..."),this.setState({tableFilterText:t.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){var t;(t=this.tableSearchField)==null||t.focus()}handleWidgetFilterChange(t){Il.debug("filtering widgets..."),this.setState({widgetFilterText:t.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){var t;(t=this.widgetSearchField)==null||t.focus()}render(){const{overflowActions:t,objects:n,openObject:s}=this.props,{tableFilterText:i,widgetFilterText:o}=this.state,r=this.makeTableActions(n,i,s),l=this.makeWidgetActions(n,o,s),a={placement:"bottom-end"};return E("div",{className:"console-pane-menu",children:[E(Y,{kind:"ghost",className:"btn-link-icon",disabled:r.length===0,onClick:()=>{},children:[E("div",{className:"fa-md fa-layers",children:[h(K,{mask:tr,icon:On,transform:"right-5 down-5"}),h(K,{icon:On,transform:"right-8 down-6"})]}),h(He,{children:"Tables"}),h(Pn,{actions:r,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions ")]}),E(Y,{kind:"ghost",className:"btn-link-icon",disabled:l.length===0,onClick:()=>{},children:[E("div",{className:"fa-md fa-layers",children:[h(K,{mask:Wl,icon:On,transform:"right-5 down-5"}),h(K,{icon:On,transform:"right-8 down-6"})]}),h(He,{children:"Widgets"}),h(Pn,{actions:l,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions")]}),h(Y,{kind:"ghost",className:"btn-overflow btn-link-icon",icon:ud,tooltip:"More Actions...",onClick:()=>{},children:h(Pn,{actions:t,popperOptions:a})})]})}}class Za extends y.exports.PureComponent{constructor(t){super(t),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new Zi,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}startListening(){const{session:t}=this.props;t.addEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){const{session:t}=this.props;t.removeEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(t){const{result:n}=t.detail;this.pending.add(n).then(()=>this.handleCommandCompleted(null)).catch(s=>this.handleCommandCompleted(s)),this.setState({isCommandRunning:!0})}handleCommandCompleted(t){t instanceof Is||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){const{children:t,openObject:n,overflowActions:s,objects:i}=this.props,{isDisconnected:o,isCommandRunning:r}=this.state;let l=null,a=null;return o?(l="console-status-icon-disconnected",a="Worker is disconnected"):r?(l="console-status-icon-pending",a="Worker is busy"):(l="console-status-icon-idle",a="Worker is idle"),E("div",{className:"console-pane-status-bar",children:[E("div",{children:[h("div",{className:z("console-status-icon",l)}),h(He,{children:a})]}),t,h(qi,{overflowActions:s,openObject:n,objects:i})]})}}Za.defaultProps={children:null};const En=ee.module("Console"),Ml={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0},Ys=class extends y.exports.PureComponent{constructor(e){super(e),this.processLogMessageQueue=ls(()=>{this.scrollConsoleHistoryToBottom(),this.setState(s=>{En.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");let{consoleHistory:i}=s;return i=i.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:i}})},Ys.LOG_THROTTLE),this.getObjects=Re(s=>[...s.values()]),this.getContextActions=Re(s=>[...s,{action:this.handleClearShortcut,shortcut:rs.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:rs.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=Z.createRef(),this.consoleInput=Z.createRef(),this.consoleHistoryScrollPane=Z.createRef(),this.pending=new Zi,this.queuedLogMessages=[];const{objectMap:t,settings:n}=this.props;this.state={consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1,...Ml,...n}}static isErrorLevel(e){return e===Ye.STDERR||e===Ye.ERROR||e===Ye.FATAL}static isOutputLevel(e){return e===Ye.STDOUT||Ys.isErrorLevel(e)}componentDidMount(){this.initConsoleLogging();const{session:e}=this.props;e.addEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){const{props:n,state:s}=this;this.sendSettingsChange(t,s),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){const{session:e}=this.props;e.removeEventListener(T.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}initConsoleLogging(){const{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.clear()}handleCommandStarted(e){const{code:t,result:n}=e.detail,s=this.pending.add(n),i={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:s},{commandHistoryStorage:o,language:r,scope:l}=this.props,a=o.addItem(r,l,t,{command:t,startTime:new Date().toJSON()});a.catch(c=>{En.debug("Error adding workspace item",c)}),this.setState(c=>({consoleHistory:c.consoleHistory.concat(i)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),s.then(c=>{this.handleCommandResult(c,i,a)}).catch(c=>{this.handleCommandError(c,i,a)})}handleCommandResult(e,t,n){const s=t;s.wrappedResult=void 0,s.cancelResult=void 0,e&&(s.result=e,this.updateHistory(e,s),this.updateKnownObjects(s),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){const s=t;if(s.wrappedResult=void 0,s.cancelResult=void 0,Pe.isCanceled(e)){En.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:`${e}`},n),this.setState(i=>{const o=i.consoleHistory.concat(),r=o.lastIndexOf(s);return s.endTime=Date.now(),s.result={error:e},o[r]={...s},{consoleHistory:o}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();const{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){const{isPrintStdOutEnabled:t}=this.state;!t||Ys.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){const n={};Ys.isErrorLevel(t)?n.error=e:n.message=e;const s={command:void 0,result:n};this.queuedLogMessages.push(s),this.processLogMessageQueue()}openUpdatedItems(e){const{isAutoLaunchPanelsEnabled:t}=this.state;if(e==null||!t)return;const{openObject:n}=this.props;[...e.created,...e.updated].forEach(s=>n(s))}closeRemovedItems(e){if(e==null||e.removed==null||e.removed.length===0)return;const{closeObject:t}=this.props,{removed:n}=e;n.forEach(s=>t(s))}updateHistory(e,t){const n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(s=>({consoleHistory:s.consoleHistory.concat()})))}updateKnownObjects(e){let 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)){En.debug2("updateKnownObjects no changes");return}this.setState(n=>{const s=n.consoleHistory.concat(),i=s.lastIndexOf(e);if(i<0)return En.error("historyItem not found in state.consoleHistory"),null;const o=new Map(n.objectHistoryMap),r=new Map(n.objectMap),l=(a,c=!1)=>{var m;const{title:d}=a;x(d);const u=o.get(d);u!=null&&u>=0&&(s[u].disabledObjects=[...(m=s[u].disabledObjects)!=null?m:[],d]),o.set(d,i),c?r.delete(d):r.set(d,a)};return t==null||t.updated.forEach(a=>l(a)),t==null||t.removed.forEach(a=>l(a,!0)),t==null||t.created.forEach(a=>{const{title:c}=a;x(c),o.set(c,i),r.set(c,a)}),{objectHistoryMap:o,objectMap:r,consoleHistory:s}})}updateObjectMap(){const{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){const n=this.pending.add(t),s=new Date().toJSON();n.then(i=>{const o={...i,data:{...i.data,endTime:s,result:e}},{commandHistoryStorage:r,language:l}=this.props;r.updateItem(l,o).catch(a=>{En.warn("Error updating command history storage",a)})}).catch(i=>{En.debug("Error updating workspace history item",i)})}scrollConsoleHistoryToBottom(e=!1){const t=this.consoleHistoryScrollPane.current;x(t),!(!e&&t.scrollTop<t.scrollHeight-t.offsetHeight)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){const e=this.consoleHistoryScrollPane.current;x(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")return;e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});const{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:mn.MULTIPLE_FILE_ERROR});return}const n=t[0];mn.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:mn.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){const{openObject:t,commandHistoryStorage:n,language:s,scope:i}=this.props,{consoleHistory:o,objectMap:r}=this.state,l={name:e,title:e,type:T.VariableType.TABLE},a=r.has(e),c={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[a?"updated":"created"]:[l]}}},d=o.concat(c);this.setState({consoleHistory:d}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(c),t({name:e,title:e,type:T.VariableType.TABLE}),n.addItem(s,i,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){const{consoleHistory:n}=this.state,s={command:"",startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},i=n.concat(s);this.setState({consoleHistory:i})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?`${e}`:void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){const{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:s}=this.props;return[...s,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:oe.groups.high,icon:n?is:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:oe.groups.high,icon:e?is:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:oe.groups.high,icon:t?is:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:oe.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){const{session:t}=this.props;t.runCode(e).catch(n=>{En.error("There was an error initiating the command",n)})}else{const t={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(n=>({consoleHistory:n.consoleHistory.concat(t)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{const t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}addCommand(e,t=!0,n=!1){!this.consoleInput.current||(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){var e;(e=this.consoleInput.current)==null||e.focus()}sendSettingsChange(e,t,n=!0){const s=Object.keys(Ml),i={};let o=!1;for(let l=0;l<s.length;l+=1){const a=s[l],{[a]:c}=t,{[a]:d}=e;c!==d&&(o=!0),i[a]=c}if(n&&!o)return;const{onSettingsChange:r}=this.props;r(i)}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){const{actions:e,historyChildren:t,language:n,statusBarChildren:s,openObject:i,session:o,scope:r,commandHistoryStorage:l,timeZone:a,disabled:c,unzip:d}=this.props,{consoleHeight:u,consoleHistory:m,isScrollDecorationShown:p,objectMap:g,showCsvOverlay:f,csvFile:C,csvPaste:b,dragError:w,csvUploadInProgress:v}=this.state,I=this.getObjects(g),S=Math.round(u*.7),R=this.getContextActions(e);return E("div",{role:"presentation",className:z("iris-console","h-100","w-100",{disabled:c}),children:[E("div",{className:"console-pane",ref:this.consolePane,children:[h(Za,{session:o,overflowActions:this.handleOverflowActions,openObject:i,objects:I,children:s}),E("div",{className:"console-csv-container",onDragOver:mn.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[f&&h(mn,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:w,onError:this.handleCsvError,uploadInProgress:v,allowZip:d!=null}),E("div",{role:"presentation",className:z("scroll-pane no-scroll-x",{"scroll-decoration":p}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[h(Ga,{items:m,openObject:i,language:n,disabled:c}),t]})]}),!f&&h($i,{ref:this.consoleInput,session:o,language:n,scope:r,onSubmit:this.handleCommandSubmit,maxHeight:S,commandHistoryStorage:l}),f&&h(ja,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:C!=null?C:void 0,paste:b!=null?b:void 0,onInProgress:this.handleCsvInProgress,timeZone:a,unzip:d})]}),h(oe,{actions:R,ignoreClassNames:[$i.INPUT_CLASS_NAME]})]})}};let Ja=Ys;Ja.defaultProps={statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null};Ja.LOG_THROTTLE=500;class Er extends y.exports.Component{constructor(t){super(t),this.handleResize=this.handleResize.bind(this),this.container=null,this.state={}}componentDidMount(){this.initEditor(),window.addEventListener("resize",this.handleResize)}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),this.destroyEditor()}setLanguage(t){if(this.editor){const n=this.editor.getModel();x(n),pn.setModelLanguage(n,t)}}handleResize(){this.updateDimensions()}toggleFind(){this.editor&&(this.editor.focus(),this.editor.trigger("toggleFind","actions.find",void 0))}updateDimensions(){var t;(t=this.editor)==null||t.layout()}initEditor(){const{onEditorInitialized:t}=this.props;let{settings:n}=this.props;n={copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"python",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,tabCompletion:"on",value:"",wordWrap:"off",...n},x(this.container),this.editor=pn.create(this.container,n),this.editor.addAction({id:"find",label:"Find",keybindings:[Rt.CtrlCmd|Yt.KeyF],precondition:void 0,keybindingContext:void 0,contextMenuGroupId:"navigation",contextMenuOrder:1,run:()=>{this.toggleFind()}}),this.editor.layout(),Ue.removeConflictingKeybindings(this.editor),t(this.editor)}destroyEditor(){const{onEditorWillDestroy:t}=this.props;x(this.editor),t(this.editor),this.editor.dispose(),this.editor=void 0}render(){const{className:t}=this.props;return h("div",{className:z("editor-container",t),ref:n=>{this.container=n}})}}Er.defaultProps={className:"fill-parent-absolute",onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},settings:{}};const yt=ee.module("ScriptEditor");class og extends y.exports.Component{constructor(t){super(t),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=Z.createRef(),this.state={model:null}}componentDidMount(){ye.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(t){var d,u;const{sessionLanguage:n,settings:s}=this.props,i=s==null?void 0:s.language;i!==((d=t.settings)==null?void 0:d.language)&&(yt.debug("Set language",i),this.setLanguage(i));const r=n==null&&t.sessionLanguage!=null,l=i===n,a=((u=t.settings)==null?void 0:u.language)===t.sessionLanguage;(r||n!==void 0&&a&&!l)&&(yt.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion()),(n!=null&&t.sessionLanguage==null&&l||n!==void 0&&!a&&l)&&(yt.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){ye.removeEventListener("onUpdate",this.updateShortcuts)}getValue(){return this.editor?this.editor.getValue():(yt.error("Editor not initialized"),null)}getSelectedCommand(){var c,d;const t=(c=this.editor)==null?void 0:c.getSelection();x(t);const n=(d=this.editor)==null?void 0:d.getModel();x(n);const{startLineNumber:s,endColumn:i}=t;let{endLineNumber:o}=t;i===1&&o>s&&(o-=1);const r=n==null?void 0:n.getLineMinColumn(s),l=n==null?void 0:n.getLineMaxColumn(o),a=t.setStartPosition(s,r).setEndPosition(o,l);return n==null?void 0:n.getValueInRange(a)}handleEditorInitialized(t){const{focusOnMount:n,onChange:s,onEditorInitialized:i,settings:o,session:r,sessionLanguage:l}=this.props;yt.debug("handleEditorInitialized",l,r,o),this.editor=t,this.setState({model:this.editor.getModel()}),Ue.setEOL(t),Ue.registerPasteHandler(t),r!=null&&o&&l===o.language&&(this.initContextActions(),this.initCodeCompletion()),t.onDidChangeModelContent(s),n!=null&&n&&t.focus(),i(this.editor)}handleEditorWillDestroy(t){yt.debug("handleEditorWillDestroy");const{onEditorWillDestroy:n}=this.props;n(t),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){const{onRunCommand:t}=this.props,n=this.getValue();n!=null&&t(n)}handleRunSelected(){const{onRunCommand:t}=this.props,n=this.getSelectedCommand();t(n)}initContextActions(){if(this.contextActionCleanups.length>0){yt.error("Context actions already initialized.");return}if(!this.editor)return;const t=[];t.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Ue.getMonacoKeyCodeFromShortcut(rs.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),t.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Ue.getMonacoKeyCodeFromShortcut(rs.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=t}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(t=>t.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){yt.error("Code completion already initialized.");return}const{session:t}=this.props;yt.debug("initCodeCompletion",this.editor,t),this.editor&&t!=null&&(this.completionCleanup=Ue.openDocument(this.editor,t))}deInitCodeCompletion(){const{session:t}=this.props;yt.debug("deInitCodeCompletion",this.editor,t),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&t!=null&&Ue.closeDocument(this.editor,t))}append(t,n=!0){x(this.editor);const s=this.editor.getModel();x(s);const i=s.getValue();i?s.setValue(`${i}
23
23
  ${t}`):s.setValue(`${t}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.editor.setPosition({lineNumber:o,column:r}),n&&this.editor.focus()}updateDimensions(){yt.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){yt.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(t){this.editorComponent.current&&t!==void 0&&this.editorComponent.current.setLanguage(t)}render(){var u;const{error:t,isLoaded:n,isLoading:s,session:i,sessionLanguage:o,settings:r}=this.props,{model:l}=this.state,a=t?`Unable to open document. ${t}`:null,c=r&&(u=r.language)!=null?u:null,d=l&&i&&c===o;return E(Fe,{children:[(t||s)&&h("div",{className:"h-100 w-100 position-relative",children:h(ua,{errorMessage:a,isLoading:s,isLoaded:n})}),n&&h("div",{className:"h-100 w-100 script-editor",children:r&&E(Fe,{children:[h(Er,{ref:this.editorComponent,settings:r,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),d!=null&&d&&h(qa,{model:l,language:c,session:i})]})})]})}}og.defaultProps={error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null};const rg=250,lg=2500,ec=class extends y.exports.Component{constructor(e){super(e),this.loadData=Et(()=>{const{commandHistoryStorage:t,item:n,language:s}=this.props,{id:i}=n;this.cleanup=t.listenItem(s,i,this.handleUpdate,this.handleError)},rg),this.getPreviewText=me(t=>t.split(`
24
24
  `,lg).join(`
25
25
  `),{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()}}static getTimeString(e,t){if(e==null||t===""||t===0)return null;const n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":jt.formatElapsedTime(n)}componentDidMount(){this.loadData()}componentDidUpdate(e,t){var s;const{data:n}=this.state;this.timer==null&&!(n!=null&&n.result)&&Boolean(n==null?void 0:n.startTime)&&!(n==null||n.endTime===void 0)?this.startTimer():((n==null?void 0:n.result)&&!((s=t.data)!=null&&s.result)||Boolean(n==null?void 0:n.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:`${e}`})}handleUpdate(e){const{data:t}=e!=null?e:{};this.setState({data:t});const{onUpdate:n}=this.props;n==null||n(t)}handleTimeout(){this.updateTime()}render(){var m;const{item:{name:e},language:t}=this.props,{currentTime:n,data:s,error:i}=this.state,{result:o,startTime:r,endTime:l}=s!=null?s:{},a=(m=o==null?void 0:o.error)!=null?m:i,c=ec.getTimeString(r,l!=null?l:n),d=this.getPreviewText(e),u=Boolean(c);return E("div",{className:"command-history-item-tooltip",children:[E("div",{className:"scroll-container",children:[h(Ua,{language:t,children:d}),d.length<e.length&&h("p",{children:"Preview Truncated..."})]}),E("div",{className:"result-info",children:[E("div",{className:"d-flex justify-content-between",children:[Boolean(a)&&E("div",{className:"text-danger mr-1",children:[h(K,{icon:Ln})," Executed with errors"]}),E("div",{className:"time-wrapper",children:["Elapsed time:"," ",u?h("span",{className:"time-string",children:c}):h(Vt,{})]})]}),Boolean(a)&&h("div",{className:"error-message",children:a})]})]})}};let tc=ec;tc.defaultProps={onUpdate:()=>{}};const ag=512;function nc(e){const{item:t,language:n,isSelected:s,commandHistoryStorage:i}=e,o=t.name.substring(0,ag),r=y.exports.useRef(null),l=y.exports.useCallback(()=>{var a;(a=r.current)==null||a.update()},[r]);return E("div",{className:z("command-history-item",{selected:s}),children:[o,h(He,{ref:r,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:h(tc,{item:t,language:n,onUpdate:l,commandHistoryStorage:i})})]})}nc.defaultProps={isSelected:!1};class Ki extends y.exports.Component{static itemKey(t,n){return`${n.title}`}static renderContent(t){return t.selectionRequired!==void 0&&t.selectionRequired?E("div",{className:"fa-md fa-layers",children:[h(K,{icon:Qo,mask:t.icon,transform:"right-5 down-5 shrink-4"}),h(K,{icon:ed,transform:"shrink-3 right-7 down-6"})]}):h(K,{icon:t.icon})}render(){const{actions:t,hasSelection:n}=this.props;return h("div",{className:"command-history-actions",children:t.map((s,i)=>h(Y,{kind:"inline",className:z(s.className),onClick:s.action,tooltip:s.description,disabled:s.selectionRequired!==void 0&&s.selectionRequired&&!n,icon:Ki.renderContent(s)},Ki.itemKey(i,s)))})}}const cg=150,Dl=3,Nl=ee.module("CommandHistoryViewportUpdater");function dg({table:e,columns:t,top:n=0,bottom:s=0,search:i,isReversed:o=!1,onUpdate:r}){const l=y.exports.useMemo(()=>ls(a=>{const c=a.bottom-a.top,d=Math.max(0,a.top-c*Dl),u=a.bottom+c*Dl;e.setViewport({top:d,bottom:u,columns:a.columns})},cg),[e]);return y.exports.useEffect(function(){const c=e.onUpdate(d=>{var u,m;r({items:(u=d.items)!=null?u:[],offset:(m=d.offset)!=null?m:0})});return()=>{Nl.debug("onUpdate cleanup"),c()}},[e,r]),y.exports.useEffect(function(){e.setSearch(i!=null?i:"")},[e,i]),y.exports.useEffect(function(){l({top:n,bottom:s,columns:t})},[l,n,s,t,i,o]),y.exports.useEffect(()=>()=>{Nl.debug2("Cancel throttledUpdateViewport"),l.cancel()},[l]),null}const yn=ee.module("CommandHistory"),un=class extends y.exports.Component{constructor(e){super(e),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:ad,shortcut:cr.COPY,action:this.copySelectedCommands,group:oe.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:Br,shortcut:rs.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:un.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:bd,shortcut:rs.COMMAND_HISTORY.RUN,action:this.runInConsole,group:un.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Ur,shortcut:rs.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:un.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:fd,action:this.createNotebook,group:un.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:Br,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Ur,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new Zi,this.searchInputRef=Z.createRef(),this.itemListRef=Z.createRef();const{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:""}}static getCommandsFromViewport(e,t,n){const s=[];for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=o[0];r<=o[1];r+=1)if(r>=t&&r<t+e.length){const{name:l}=e[r-t];s.push(l)}}return s}static async getCommandsFromSnapshot(e,t){return[...(await e.getSnapshot(t)).values()].map(s=>s.name)}componentWillUnmount(){this.pending.cancel()}async getSelectedCommands(){const{items:e,offset:t,selectedRanges:n}=this.state,s=n.slice().sort((o,r)=>o[0]-r[0]);if(s.length===0)return[];if(s[0][0]>=t&&s[s.length-1][1]<t+e.length)return un.getCommandsFromViewport(e,t,s);const{table:i}=this.props;return this.pending.add(un.getCommandsFromSnapshot(i,s))}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
@@ -30,4 +30,4 @@ ${t}`):s.setValue(`${t}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
30
30
  `&&(e+=`
31
31
  `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,it.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(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return E("div",{className:"log-pane h-100 w-100",children:[E("div",{className:"log-pane-menu",children:[h(Y,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Ud,tooltip:"Clear log"}),h(Y,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:cd,tooltip:"Log Settings",onClick:()=>{},children:h(Pn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let ri=it;ri.DefaultLogLevels=[Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN];ri.AllLogLevels=[Ye.INFO,Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN,Ye.DEBUG,Ye.TRACE];ri.bufferTimeout=16;ri.maxLogSize=131072;ri.truncateSize=65536;_i.register([pc,gc,fc,Cc,bc,wc]);const hg=typeof So=="function"?So(_i):So.default(_i),hn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(hn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(hn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(hn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(hn.EVENT_LOADFINISHED))}};let Qe=hn;Qe.EVENT_UPDATED="ChartModel.EVENT_UPDATED";Qe.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";Qe.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";Qe.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";Qe.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";Qe.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";Qe.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";Qe.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const mg="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",pg="#403e41",gg="#5b5a5c",fg="#c0bfbf",Cg="#4878ea",bg="rgba(91, 90, 92, 0.7)",Je={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:mg,gridcolor:pg,linecolor:gg,zerolinecolor:fg,activecolor:Cg,rangebgcolor:bg,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},Fn=Object.freeze({paper_bgcolor:Je["paper-bgcolor"],plot_bgcolor:Je["plot-bgcolor"],title_color:Je["title-color"],colorway:Je.colorway,gridcolor:Je.gridcolor,linecolor:Je.linecolor,zerolinecolor:Je.zerolinecolor,activecolor:Je.activecolor,rangebgcolor:Je.rangebgcolor,area_color:Je["area-color"],trend_color:Je["trend-color"],line_color:Je["line-color"],error_band_line_color:Je["error-band-line-color"],error_band_fill_color:Je["error-band-fill-color"],ohlc_increasing:Je["ohlc-increasing"],ohlc_decreasing:Je["ohlc-decreasing"]}),Ai=ee.module("ChartUtils"),Rn=Object.freeze(T.calendar.DayOfWeek.values()),Fl="io.deephaven.time.DateTime",wg=36e5,Sg=1e6;function vg(e){return e.asDate!==void 0}function Tg(e){return e.asNumber!==void 0}function xl(e){return e.dhTimeZone!==void 0}function Eg(e){return e!=null&&e.range!=null&&(e.autorange===!1||e.autorange===void 0)}const Q=class{static getPlotlyChartType(e,t){switch(e){case T.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case T.plot.SeriesPlotStyle.LINE:return"scatter";case T.plot.SeriesPlotStyle.BAR:case T.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case T.plot.SeriesPlotStyle.PIE:return"pie";case T.plot.SeriesPlotStyle.TREEMAP:return"treemap";case T.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case T.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e){switch(e){case T.plot.SeriesPlotStyle.SCATTER:return"markers";case T.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(e,t){switch(e){case T.plot.SeriesPlotStyle.PIE:switch(t){case T.plot.SourceType.X:return"labels";case T.plot.SourceType.Y:return"values"}break;case T.plot.SeriesPlotStyle.OHLC:switch(t){case T.plot.SourceType.TIME:return"x"}break;case T.plot.SeriesPlotStyle.TREEMAP:switch(t){case T.plot.SourceType.X:return"ids";case T.plot.SourceType.Y:return"values";case T.plot.SourceType.LABEL:return"labels";case T.plot.SourceType.PARENT:return"parents";case T.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case T.plot.SourceType.X:return"x";case T.plot.SourceType.Y:return"y";case T.plot.SourceType.Z:return"z";case T.plot.SourceType.X_LOW:return"xLow";case T.plot.SourceType.X_HIGH:return"xHigh";case T.plot.SourceType.Y_LOW:return"yLow";case T.plot.SourceType.Y_HIGH:return"yHigh";case T.plot.SourceType.TIME:return"time";case T.plot.SourceType.OPEN:return"open";case T.plot.SourceType.HIGH:return"high";case T.plot.SourceType.LOW:return"low";case T.plot.SourceType.CLOSE:return"close";case T.plot.SourceType.SHAPE:return"shape";case T.plot.SourceType.SIZE:return"size";case T.plot.SourceType.LABEL:return"label";case T.plot.SourceType.COLOR:return"color";case T.plot.SourceType.PARENT:return"parent";case T.plot.SourceType.HOVER_TEXT:return"hovertext";case T.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){var n,s;const{sources:t}=e;return t.length===2&&((s=(n=t[0])==null?void 0:n.axis)==null?void 0:s.type)===T.plot.AxisType.Y?Q.ORIENTATION.HORIZONTAL:Q.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,r)=>o-e[r]),i=t.map((o,r)=>e[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n==null?void 0:n.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e==null?void 0:e.getColumnTypeFormatter(t);return o!=null&&xl(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=T.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);x(i);const[,o,r,l,,a,c,d,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=d!=null&&d!==""?"e":"f",b=u!==""?u:C,w=a.length+c.length,I=`0${p}${f}.${w}${b}`,S=Q.convertNumberPrefix(o),R=Q.convertNumberPrefix(m);return{tickformat:I,tickprefix:S,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return F.isDateType(s)?(o=Q.getPlotlyDateFormat(t,s,i),o=Q.addTickSpacing(o,n,!0)):F.isNumberType(s)&&(o=Q.getPlotlyNumberFormat(t,s,i),o=Q.addTickSpacing(o,n,!1)),n.formatType===T.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/Sg),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s=Q.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:s}}static makeSeriesDataFromSeries(e,t,n,s=Fn){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=e,c=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),d=Q.getChartType(o,c),u=Q.getPlotlyChartMode(o),m=Q.getPlotlySeriesOrientation(e),p=Q.makeSeriesData(d,u,i,m);return Q.addSourcesToSeriesData(p,o,a,t),Q.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,c=Q.getPlotlyProperty(t,a);kl(i,c,[]);const d=l!=null?Q.getAxisPropertyName(l.type):null;if(d!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${d}axis`]=`${d}${p}`}}}}static addStylingToSeriesData(e,t,n=Fn,s=null,i=null,o=null){const r=e;r.marker={line:{}},r.line={width:1},t===T.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":t===T.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":t===T.plot.SeriesPlotStyle.STEP?r.line.shape="hv":t===T.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):t===T.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):t===T.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):t===T.plot.SeriesPlotStyle.TREEMAP&&(r.hoverinfo="text",r.textinfo="label+text",r.tiling={packing:"squarify",pad:0},r.textposition="middle center",r.outsidetextfont={color:n.title_color}),s!=null&&(t===T.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&t!==T.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=Q.getAllAxes(e),o=Q.groupArray(i,"type"),{charts:r}=e;for(let l=0;l<r.length;l+=1){const a=r[l];for(let c=0;c<a.series.length;c+=1){const d=a.series[c],{sources:u}=d,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:C}=f,b=o.get(C);x(b);const w=b.indexOf(f),v=Q.getAxisPropertyName(C);if(v!=null){const I=Q.getAxisLayoutProperty(v,w);if(n.has(I))Ai.debug(`${I} already added.`);else{Ai.debug(`Adding ${I} to axisFormats.`);const S=Q.getPlotlyAxisFormat(g,t);if(S===null)n.set(I,s);else{n.set(I,S);const{businessCalendar:R}=f;if(R!=null){const M=[],{businessPeriods:O,businessDays:P,holidays:W,timeZone:B}=R,N=t==null?void 0:t.getColumnTypeFormatter(Fl);let H;xl(N)&&(H=N.dhTimeZone);const k=H?(B.standardOffset-H.standardOffset)/60:0;W.length>0&&M.push(...Q.createRangeBreakValuesFromHolidays(W,B,H)),O.forEach(L=>M.push({pattern:"hour",bounds:[Q.periodToDecimal(L.close)+k,Q.periodToDecimal(L.open)+k]})),P.length<Rn.length&&Q.createBoundsFromDays(P).forEach(L=>M.push({pattern:"day of week",bounds:L})),S.rangebreaks=M}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case T.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return Q.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case T.plot.AxisType.X:return"x";case T.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case T.plot.AxisPosition.BOTTOM:return"bottom";case T.plot.AxisPosition.TOP:return"top";case T.plot.AxisPosition.LEFT:return"left";case T.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];Eg(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=Fn){const r=e,l=Q.getAllAxes(t);for(let a=0;a<t.charts.length;a+=1){const c=t.charts[a],d=n==null?void 0:n(c),u=Q.getChartBounds(t,c,s,i);Q.updateLayoutAxes(r,c.axes,l,s,i,u,d,o)}Q.removeStaleAxes(r,l)}static getChartBounds(e,t,n=0,s=0){var v;const{cols:i,rows:o}=e,{column:r,colspan:l,row:a,rowspan:c}=t,d=r+l,u=a+c,m=1/i,p=1/o,g=Q.AXIS_SIZE_PX/n,f=Q.AXIS_SIZE_PX/s,C={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/2:0),right:d*m-(d<i?g/2:0)};return((v=Q.groupArray(t.axes,"position").get(T.plot.AxisPosition.RIGHT))!=null?v:[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(Q.LEGEND_WIDTH_PX/n,Q.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*Q.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=Fn){const a=s>0?Math.max(Q.MIN_AXIS_SIZE,Math.min(Q.AXIS_SIZE_PX/i,Q.MAX_AXIS_SIZE)):Q.DEFAULT_AXIS_SIZE,c=i>0?Math.max(Q.MIN_AXIS_SIZE,Math.min(Q.AXIS_SIZE_PX/s,Q.MAX_AXIS_SIZE)):Q.DEFAULT_AXIS_SIZE,d=e,u=Q.groupArray(t,"position"),m=Q.groupArray(t,"type"),p=[...m.keys()],g=Q.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const C=p[f],b=Q.getAxisPropertyName(C);if(b!=null){const w=m.get(C),v=g.get(C),S=C===T.plot.AxisType.Y?i:s;x(w),x(v);for(let R=0;R<w.length;R+=1){const M=w[R],O=v.indexOf(M),P=Q.getAxisLayoutProperty(b,O);d[P]==null&&(d[P]=Q.makeLayoutAxis(C,l));const W=d[P];if(W!=null){Q.updateLayoutAxis(W,M,R,u,a,c,o);const{range:B,autorange:N}=W;if(r!=null&&B!==void 0&&(N===void 0||N===!1)){const H=r(M),[k,L]=H(B);Ai.debug("Setting downsample range",S,k,L),M.range(S,k,L)}else M.range(S)}}}}}static removeStaleAxes(e,t){const n=e,s=Q.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);x(l);let a=l.length;const c=Q.getAxisPropertyName(r);if(c!=null){let d=Q.getAxisLayoutProperty(c,a);for(;n[d]!=null;)delete n[d],a+=1,d=Q.getAxisLayoutProperty(c,a)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e!=null?e:""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,r){var u,m,p;const a=t.type===T.plot.AxisType.Y?o:i,c=e,d=(u=t.label)!=null?u:"";if(c.title!==void 0&&typeof c.title!="string"?c.title.text=d:c.title={text:d},t.log&&(c.type="log"),c.side=Q.getAxisSide(t.position),n>0){c.overlaying=(m=Q.getAxisPropertyName(t.type))!=null?m:void 0;const g=(p=s.get(t.position))!=null?p:[],f=g.indexOf(t);f>0&&(c.anchor="free",t.position===T.plot.AxisPosition.RIGHT?c.position=r.right+(f-g.length+1)*a:t.position===T.plot.AxisPosition.TOP?c.position=r.top+(f-g.length+1)*a:t.position===T.plot.AxisPosition.BOTTOM?c.position=r.bottom+(g.length-f+1)*a:t.position===T.plot.AxisPosition.LEFT&&(c.position=r.left+(g.length-f+1)*a))}else if(t.type===T.plot.AxisType.X){const g=s.get(T.plot.AxisPosition.LEFT)||[],f=s.get(T.plot.AxisPosition.RIGHT)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);c.domain=[C,b]}else if(t.type===T.plot.AxisType.Y){const g=s.get(T.plot.AxisPosition.BOTTOM)||[],f=s.get(T.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);c.domain=[C,b]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>Rn.indexOf(o)),n=Rn.filter(o=>!e.includes(o)).map(o=>Rn.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+Rn.length;r+=1){const l=r%Rn.length;if(t.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-Rn.length;r-=1){const l=r<0?r+Rn.length:r;if(t.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...Q.createPartialHoliday(o,t,n)):s.push(Q.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return Q.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const c=[Q.adjustDateForTimeZone(`${s} ${l}:00.000000`,t,n)],d=wg*(Q.periodToDecimal(a)-Q.periodToDecimal(l));o.push({values:c,dvalue:d})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?Q.unwrapValue(Q.wrapValue(e,Fl,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{var r;const i=s[t],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(vg(e))return T.i18n.DateTimeFormat.format(Q.DATE_FORMAT,e,t);if(Tg(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(F.isDateType(t)&&typeof e=="string"){const s=e,i=Q.DATE_FORMAT.substr(0,e.length),o=T.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=T.i18n.DateTimeFormat.format("Z",o,n),a=T.i18n.DateTimeFormat.parse(r,`${s} ${l}`),c=T.i18n.DateTimeFormat.format("Z",a,n);return T.i18n.DateTimeFormat.parse(r,`${s} ${c}`)}return e}static makeLayoutAxis(e,t=Fn){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===T.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===T.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=Fn){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Ai.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=Fn){const t={...e,autosize:!0,colorway:Q.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...Q.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...Q.DEFAULT_MARGIN},xaxis:Q.makeLayoutAxis(T.plot.AxisType.X,e),yaxis:Q.makeLayoutAxis(T.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:T.plot.SeriesPlotStyle[e.type]}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${t.join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=Q.titleFromSettings(e),r={formatType:`${T.plot.AxisFormatType.NUMBER}`,type:`${T.plot.AxisType.X}`,position:`${T.plot.AxisPosition.BOTTOM}`},l={formatType:`${T.plot.AxisFormatType.NUMBER}`,type:`${T.plot.AxisType.Y}`,position:`${T.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${T.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${T.plot.SourceType.X}`,columnName:s,axis:r,table:t},{type:`${T.plot.SourceType.Y}`,columnName:a,axis:l,table:t}]}))}],title:o}}};let ve=Q;ve.DEFAULT_AXIS_SIZE=.15;ve.MIN_AXIS_SIZE=.025;ve.MAX_AXIS_SIZE=.2;ve.AXIS_SIZE_PX=75;ve.LEGEND_WIDTH_PX=50;ve.MAX_LEGEND_SIZE=.25;ve.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});ve.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";ve.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});ve.DEFAULT_TITLE_PADDING=Object.freeze({t:8});ve.SUBTITLE_LINE_HEIGHT=25;const In=ee.module("Chart"),Qs=class extends y.exports.Component{constructor(e){super(e),this.getCachedConfig=Re((t,n,s,i)=>{const o=[],r=Boolean(t);if(r&&o.push({name:`Downsampling failed: ${t}`,click:()=>{},icon:Qs.convertIcon(Xl),attr:"fill-warning"}),n||s||i||r){const l=Qs.downsampleButtonTitle(s,i),a=Qs.downsampleButtonAttr(s,i),c=s?$l:Ad;o.push({name:l,icon:Qs.convertIcon(c),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=Z.createRef(),this.plotWrapper=Z.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e,t;return(t=(e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())!=null?t:null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){In.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var s;const{type:t,detail:n}=e;switch(In.debug2("Received data update",t,n),t){case Qe.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:r,revision:l}=o;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:n,layout:r,revision:l+1}});const{onUpdate:i}=this.props;i({isLoading:!this.isLoadedFired});break}case Qe.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case Qe.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case Qe.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case Qe.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLENEEDED:case Qe.EVENT_DOWNSAMPLEFAILED:{const i=(s=n.message)!=null?s:n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:i});const{onError:o}=this.props;o(new Error(i));break}default:In.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=ve.getLayoutRanges(t);!ut(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(In.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(In.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){In.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=os.getColumnFormats(e),n=os.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!ut(this.columnFormats,t)||!ut(this.dateTimeFormatterOptions,n)||!ut(this.decimalFormatOptions,s)||!ut(this.integerFormatOptions,i))&&(this.columnFormats=os.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Zt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&_i.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{In.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(t,n,s,i),a=e!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(hg,{ref:this.plot,data:e,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:In.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let yg=Qs;yg.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:_n.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const st=ee.module("FigureChartModel"),sc=class extends Qe{constructor(e,t={},n=Fn){super(),this.addPendingSeries=Et(()=>{const i=ve.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r];this.addSeries(l,i),l.subscribe()}this.pendingSeries=[]},sc.ADD_SERIES_DEBOUNCE),this.getTimeZone=me((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}}),this.getValueTranslator=me((i,o)=>{const r=this.getTimeZone(i,o);return l=>ve.unwrapValue(l,r)}),this.getValueParser=me((i,o)=>{const r=this.getTimeZone(i,o);return l=>ve.wrapValue(l,i,r)}),this.getRangeParser=me((i,o)=>r=>{let[l,a]=r;const c=this.getValueParser(i,o);return l=c(l),a=c(a),[l,a]}),this.getAxisRangeParser=me((i,o)=>r=>{const l=ve.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:ve.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=ve.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const r=e[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,t)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t){const n=ve.groupArray(t,"type"),s=ve.makeSeriesDataFromSeries(e,n,ve.getSeriesVisibility(e.name,this.settings),this.theme);if(this.seriesDataMap.set(e.name,s),this.data=[...this.seriesDataMap.values()],e.plotStyle===T.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===T.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=ve.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===T.plot.SeriesPlotStyle.PIE,e.oneClick!=null){const{oneClick:i}=e,{columns:o}=i;for(let r=0;r<o.length;r+=1)this.filterColumnMap.set(o[r].name,o[r]);this.oneClicks.push(i)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){st.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?T.plot.DownsampleOptions.DISABLE:T.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(T.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(T.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(T.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(T.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(T.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(T.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(T.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(T.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(T.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(T.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(T.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(T.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(T.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(T.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(T.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(T.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(T.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(T.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){st.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){st.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){st.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){st.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;st.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];st.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:c,type:d}=a,u=this.getValueTranslator(c,this.formatter),m=t.getArray(o,d,u);this.setDataArrayForSeries(o,d,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){st.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){st.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){st.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;st.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var s,i;super.setTitle(e);const t=(i=(s=(e!=null?e:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=ve.DEFAULT_MARGIN.t+t*ve.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=ve.DEFAULT_TITLE_PADDING.t+t*ve.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((t=(e=this.layout.margin)==null?void 0:e.l)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var e,t,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((t=(e=this.layout.margin)==null?void 0:e.t)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();ve.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;ve.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{st.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):st.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),r=ve.getPlotlyProperty(i,t);o&&kl(o,r,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===T.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===T.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:c}=s;o&&r&&o!==i&&(s.error_x=ve.getPlotlyErrorBars(i,o,r)),a&&c&&a!==l&&(s.error_y=ve.getPlotlyErrorBars(l,a,c))}else if(n===T.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){st.warn("Trying to set a filter, but no one click!");return}st.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=e.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let Rg=sc;Rg.ADD_SERIES_DEBOUNCE=50;function Ig({text:e,isOpen:t,onClose:n}){var v,I;const[s,i]=y.exports.useState(!1),[o,r]=y.exports.useState(0),[l,a]=y.exports.useState(!1),[c,d]=y.exports.useState(!1),[u,m]=y.exports.useState(!1),p=y.exports.useRef();y.exports.useEffect(function(){if(!!t){try{JSON.parse(e),m(!0)}catch{m(!1)}d(!1)}},[t,e]),y.exports.useEffect(function(){p.current&&p.current.layout()},[o]),y.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]);function g(){a(!l)}function f(){var R;const S=(R=p.current)==null?void 0:R.getModel();!u||!S||(c?(S.setValue(e),d(!1)):(S.setValue(JSON.stringify(JSON.parse(e),void 0,2)),d(!0)),C())}function C(){var R,M;const S=p.current;!S||a(((M=(R=S.getModel())==null?void 0:R.getLineCount())!=null?M:0)>1)}function b(){s&&(p.current=void 0,n())}function w(S){p.current=S,S.onDidContentSizeChange(({contentHeight:R})=>r(R)),C()}return!t&&!s?null:E(Yc,{isOpen:t,centered:!0,keyboard:!0,toggle:b,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[E(jc,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(ta,{kind:"inline",tooltip:"Copy cell contents",copy:(I=(v=p.current)==null?void 0:v.getValue())!=null?I:e}),h(Y,{kind:"inline",active:l,icon:md,tooltip:"Toggle line numbers",onClick:g}),u&&h(Y,{kind:"inline",icon:dd,active:c,tooltip:"Format as JSON",onClick:f})]}),h(Qc,{style:{height:o},children:h(Er,{onEditorInitialized:w,settings:{value:e,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const Mg="###,##0";function Dg({gotoRow:e,gotoRowError:t,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:c,onClose:d}){const u=y.exports.useRef(null),m="Row number",{rowCount:p}=a;return y.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[e]),h(so,{isShown:s,className:z("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:E(Fe,{children:[E("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:z("form-control",{"is-invalid":t!==""}),placeholder:m,onChange:g=>{c(g)},value:e})}),E("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(Mg,p)]}),t&&h("div",{className:"goto-row-error text-danger",children:t})]}),h("div",{className:"goto-row-close",children:h(Y,{kind:"ghost",onClick:d,children:h(K,{icon:ti,style:{marginRight:"0"}})})})]})})}const re=ee.module("IrisGrid"),Ng=500,Fg=250,xg=250,ic=Object.freeze({aggregations:[],showOnTop:!1}),Og="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function Ol({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return e.size===0&&t.aggregations.length===0&&n.length===0&&s.size===0&&i===F.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const xn=class extends y.exports.Component{constructor(e){super(e),this.getAdvancedMenuOpenedHandler=me(L=>this.handleAdvancedMenuOpened.bind(this,L),{max:100}),this.getCachedAdvancedFilterMenuActions=me((L,_,U,q,J)=>h(Cr,{model:L,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:U,sortDirection:q,formatter:J}),{max:50}),this.getCachedOptionItems=me((L,_,U,q,J,ne,ae,Ce,ce,Se,_e,Ke,Mt,Xe,Ze,Ut)=>{const Ne=[];return L&&Ne.push({type:be.CHART_BUILDER,title:"Chart Builder",icon:kd}),Ne.push({type:be.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:Ho}),U&&Ne.push({type:be.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Bl}),_&&Ne.push({type:be.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:Td}),q&&Ne.push({type:be.ROLLUP_ROWS,title:"Rollup Rows",icon:Bd}),J&&Ne.push({type:be.AGGREGATIONS,title:"Aggregate Columns",icon:Ed}),ne&&Ne.push({type:be.SELECT_DISTINCT,title:"Select Distinct Values",icon:vd}),ae&&Mt&&Ne.push({type:be.TABLE_EXPORTER,title:"Download CSV",icon:od}),Ut&&Ne.push({type:be.ADVANCED_SETTINGS,title:"Advanced Settings",icon:yd}),Ne.push({type:be.QUICK_FILTERS,title:"Quick Filters",subtitle:Ce.shortcut.getDisplayText(),icon:Vi,isOn:_e,onChange:Ce.action}),Xe&&Ne.push({type:be.SEARCH_BAR,title:"Search Bar",subtitle:ce.shortcut.getDisplayText(),icon:ql,isOn:Ke,onChange:ce.action}),Ne.push({type:be.GOTO,title:"Go to",subtitle:Se.shortcut.getDisplayText(),icon:Sd,isOn:Ze,onChange:Se.action}),Ne},{max:1}),this.getCachedHiddenColumns=me(L=>L,{max:1,normalizer:([L])=>L.join()}),this.getAggregationMap=me((L,_)=>{const U={};return _.forEach(({operation:q,selected:J,invert:ne})=>{U[q]=An.getOperationColumnNames(L,q,J,ne)}),U}),this.getOperationMap=me((L,_)=>{const U={};return _.filter(q=>!An.isRollupOperation(q.operation)).forEach(({operation:q,selected:J,invert:ne})=>{An.getOperationColumnNames(L,q,J,ne).forEach(ae=>{var ce;const Ce=[...(ce=U[ae])!=null?ce:[],q];U[ae]=Ce})}),U}),this.getOperationOrder=me(L=>L.map(_=>_.operation).filter(_=>!An.isRollupOperation(_))),this.getCachedFormatColumns=me((L,_)=>zh(L,_)),this.getCachedModelColumns=me((L,_)=>L.columns),this.getCachedPreviewFormatColumns=me((L,_,U,q)=>{if(re.debug("getCachedPreviewFormatColumns",_,U,q),U!==void 0&&q!==void 0){const J=[..._];return J[q]=U,this.getCachedFormatColumns(L,J)}return this.getCachedFormatColumns(L,_)}),this.getModelRollupConfig=me((L,_,U)=>te.getModelRollupConfig(L,_,U)),this.getModelTotalsConfig=me((L,_,U)=>{var Ce,ce,Se;const{aggregations:q,showOnTop:J}=U;if(((ce=(Ce=_==null?void 0:_.columns)==null?void 0:Ce.length)!=null?ce:0)>0||((Se=q==null?void 0:q.length)!=null?Se:0)===0)return null;const ne=this.getOperationMap(L,q),ae=this.getOperationOrder(q);return{operationMap:ne,operationOrder:ae,showOnTop:J}}),this.getCachedStateOverride=me((L,_,U,q,J,ne,ae,Ce,ce,Se)=>({hoverSelectColumn:L,isFilterBarShown:_,isSelectingColumn:U,loadingScrimProgress:q,quickFilters:J,advancedFilters:ne,sorts:ae,reverseType:Ce,rollupConfig:ce,isMenuShown:Se}),{max:1}),this.getCachedFilter=me((L,_,U,q,J)=>[...L!=null?L:[],...q!=null?q:[],...te.getFiltersFromFilterMap(_),...te.getFiltersFromFilterMap(U),...J!==void 0?[J]:[]],{max:1}),this.getCachedTheme=me((L,_,U)=>({...Na,...L,autoSelectRow:!_,rowFooterWidth:U>0?L.rowFooterWidth:0}),{max:1}),this.getAlwaysFetchColumns=me((L,_,U,q,J,ne)=>{const ae=[];for(let ce=0;ce<q;ce+=1)ae.push(_[V.getModelIndex(ce,U)].name);for(let ce=0;ce<J;ce+=1)ae.push(_[V.getModelIndex(_.length-1-ce,U)].name);if(ne)for(let ce=ne[0];ce<=ne[1];ce+=1)ae.push(_[V.getModelIndex(ce,U)].name);return[...new Set([...L,...ae])]}),this.updateSearchFilter=Et((L,_,U,q)=>{const J=xi.createSearchFilter(L,_,U,q);this.setState({searchFilter:J})},Fg),this.handleConditionalFormatEditorUpdate=Et(L=>{this.setState({conditionalFormatPreview:L})},xg),this.handleDownloadProgressUpdate=ls((L,_)=>{const{tableDownloadStatus:U}=this.state;U===St.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:L,tableDownloadEstimatedTime:_})},Ng),this.getOverflowButtonTooltip=me(L=>{if(L==null)return null;const _={position:"absolute",...L,pointerEvents:"none"};return h("div",{style:_,children:h(He,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new Zi,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Zs,this.tableSaver=null,this.crossColumnRef=Z.createRef(),this.isAnimating=!1,this.filterInputRef=Z.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Pt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Pt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Pt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&this.discardPending().catch(re.error)},shortcut:Pt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&L.pendingDataErrors.size===0&&this.commitPending().catch(re.error)},shortcut:Pt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:c,partitionColumn:d,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:C,invertSearchColumns:b,advancedFilters:w,quickFilters:v,selectDistinctColumns:I,pendingDataMap:S,canCopy:R,frozenColumns:M}=e,O=[new nm(this),new sm(this)];R&&O.push(new Jh(this));const P=[new im(this),new om(this),new rm(this),new dm(this),new cm(this),new Cn(this),new am(this),new um(this)],W=l.length>0?l:r.movedColumns,B=a.length>0?a:r.movedRows,N=new pm({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:W}),H=C!=null?C:[],k=xi.createSearchFilter(f,H,r.columns,b);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:N,metrics:void 0,keyHandlers:O,mouseHandlers:P,partition:c,partitionColumn:d,partitionTable:null,partitionFilters:[],quickFilters:v?new Map(v):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:F.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:I,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:W,movedRows:B,shownColumnTooltip:null,formatter:new Zt,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:k,searchValue:f,selectedSearchColumns:H,invertSearchColumns:b,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:S!=null?S:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:M,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(e,t,n){try{return F.makeQuickFilter(e,t,n)}catch(s){re.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e!=null?e:t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){var d;const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const l=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(d=u.get(as.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?d:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),r!==e.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:c}=this;a!=null&&c!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=c-a,g=Math.min(m/p,1);c<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(re.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);if(n&&i!=null&&o!=null){const r=s.valueForCell(i,o);if(F.isDateType(s.columns[i].type)){const{formatter:l}=s;return T.i18n.DateTimeFormat.format(Og,r,T.i18n.TimeZone.getTimeZone(l.timeZone))}return r}return n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;x(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;x(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){var n;const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(n=Ae(e)&&e.isEditable)!=null?n:!1,e.floatingTopRowCount+e.floatingBottomRowCount)}getVisibleColumn(e){const{movedColumns:t}=this.state;return V.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),r=t?new Map:new Map(i);let l=t&&s.size>0;e.forEach(({name:a,type:c,value:d})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===c);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,d,r)||l):re.error("Unable to find column for inputFilter",a,c,d)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const r=n.get(e);if(r!=null){const{text:l}=r;if(l===t)return re.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:xn.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){re.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){re.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){var i;re.debug("setFilterMap",e);const{advancedSettings:t}=this.props;((i=t.get(as.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:o,filterList:r},l)=>{const a=s.columns.find(u=>u.name===l&&u.type===o);if(a==null)return;const c=s.getColumnIndexByName(a.name);x(c);const d=te.combineFiltersFromList(o,r);if(d.length===0)this.removeQuickFilter(c);else{const{formatter:u}=s;this.setQuickFilter(c,xn.makeQuickFilter(a,d,u.timeZone),`${d}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}removeQuickFilter(e){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:t})=>{const n=new Map(t);return n.delete(e),{quickFilters:n}})}clearAllFilters(){re.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){re.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){re.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,r=new Map;t.forEach((l,a)=>{const{options:c}=l,d=s[a],u=F.makeAdvancedFilter(d,c,i.timeZone);o.set(a,{options:c,filter:u})}),n.forEach((l,a)=>{const{text:c}=l,d=s[a];r.set(a,{text:c,filter:xn.makeQuickFilter(d,c,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){var m,p,g;const n=os.getColumnFormats(e),s=os.getDateTimeFormatterOptions(e),i=(m=e==null?void 0:e.defaultDecimalFormatOptions)!=null?m:{},o=(p=e==null?void 0:e.defaultIntegerFormatOptions)!=null?p:{},r=(g=e==null?void 0:e.truncateNumbersWithPound)!=null?g:!1,l=!ut(this.globalColumnFormats,n),a=!ut(this.dateTimeFormatterOptions,s),c=!ut(this.decimalFormatOptions,e==null?void 0:e.defaultDecimalFormatOptions),d=!ut(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||c||d||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},t),a&&t&&this.rebuildFilters())}updateFormatter(e,t=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new Zt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);re.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,c=l!=null?l:[],d=xi.createSearchFilter(r,c,s.columns,a);if(e){const u=t.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:d}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,e),this.setState({isSelectingPartition:!0})}else re.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(T.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));ni(i).catch(o=>re.error("Unable to copy cell",o))}else re.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const c={ranges:j.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:c})}else re.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){var s,i;this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;x(o),x(r);const l=(i=(s=this.gridWrapper)==null?void 0:s.getBoundingClientRect().height)!=null?i:0,a=Math.max(o,Math.min(l/2,r));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},xn.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){re.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else re.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:ic,customColumns:[],quickFilters:new Map,reverseType:F.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Ol(this.state)}startListening(e){e.addEventListener(he.EVENT.UPDATED,this.handleUpdate),e.addEventListener(he.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(he.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(he.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(he.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(he.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(he.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(he.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var e;(e=this.grid)==null||e.focus()}focusFilterBar(e){var d,u,m;const{movedColumns:t}=this.state,{model:n}=this.props,{columnCount:s}=n,i=V.getModelIndex(e,t);if(e==null||e<0||s<=e||!n.isFilterable(i)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:o,metrics:r}=this.state;x(r);const{left:l,rightVisible:a,lastLeft:c}=r;if(e<l)(d=this.grid)==null||d.setViewState({left:e},!0);else if(a<e){const p=(u=this.grid)==null?void 0:u.getMetricState();x(p);const g=o.getLastLeft(p,e,o.getVisibleWidth(p));(m=this.grid)==null||m.setViewState({left:Math.min(g,c),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){var s;const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(V.getModelIndex(e,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;re.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);x(o);const r=V.getVisibleIndex(o,n),l=V.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;re.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);x(o);const r=V.getVisibleIndex(o,n),l=V.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(e,t){var s;const{metricCalculator:n}=this.state;t===cs.VISIBILITY_OPTIONS.SHOW?e.forEach(i=>{n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}handleAnimationLoop(){var e,t;(e=this.grid)==null||e.updateCanvasScale(),(t=this.grid)==null||t.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){re.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){re.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;!n||t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;!t||this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(Pe.isCanceled(e))return;re.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){var s;const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&e.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(e,t){re.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);x(i);const o=F.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){var t;this.startLoading("Sorting..."),this.setState({sorts:e}),(t=this.grid)==null||t.forceUpdate()}sortColumn(e,t=F.sortDirection.none,n=!1,s=!1){var r;x(e);const{model:i}=this.props,o=F.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(e){var t;this.startLoading("Reversing..."),this.setState({reverseType:e}),(t=this.grid)==null||t.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&F.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:e,canToggleSearch:t}=this.props,n=(s=e==null?void 0:e.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=T.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=T.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{var n,s,i;t&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(e=""){const{isGotoRowShown:t}=this.state;if(e){this.setState({isGotoRowShown:!0,gotoRow:e,gotoRowError:""});return}this.setState({isGotoRowShown:!t,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:e}=this.props;if(!Ae(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Qd("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{Pe.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s,groupedColumns:i}=n,o={};for(let l=0;l<s.length;l+=1){const a=s[l],{name:c,type:d}=a,u=n.valueForCell(l,t),m=n.textForCell(l,t),p=this.getVisibleColumn(l),g=ze(n)&&n.isRowExpandable(t),f=i.find(C=>C.name===c)!=null;o[c]={value:u,text:m,type:d,isGrouped:f,isExpandable:g,visibleIndex:p}}const{onDataSelected:r}=this.props;r(t,o)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);x(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(e.name);x(i);const o=F.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==t)&&(t===F.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const l=F.setSortForColumn(s.sort,i,r,n);re.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var e;(e=this.grid)==null||e.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(e){var s,i;const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){re.warn("Grid Error",e),this.setState({toastMessage:h("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);x(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){var n;e&&((n=this.grid)==null||n.focus()),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;x(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const r=F.getNormalizedType(s.type);x(r);const l=Zt.makeColumnFormattingRule(r,s.name,t);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(re.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{re.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){var d;this.stopLoading(),re.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,c={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Ol(c)?this.lastLoadedConfig=null:this.lastLoadedConfig=c,(d=this.grid)==null||d.forceUpdate()}handleViewChanged(e){var i,o;const{model:t}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ae(t)&&t.isEditable){x(e);const{bottomViewport:r}=e,l=t.rowCount-t.floatingBottomRowCount;n===l-1?s=t.pendingRowCount+1:n===l-2?s=t.pendingRowCount:s=Math.max(0,r-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){x(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t=()=>null){this.setState({movedColumns:e},t)}handleTooltipRef(e){e!=null&&e.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){re.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){re.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:be.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){re.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:be.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorSave(e){re.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return re.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){re.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=t,a=t.customColumns.map(d=>`${d}`),c=te.getRemovedCustomColumnNames(a,e);if(c.length>0){const d=te.removeSortsInColumns(s,c),u=te.removeFiltersInColumns(l,i,c),m=te.removeFiltersInColumns(l,o,c),p=te.removeColumnFromMovedColumns(l,n,c),g=te.removeColumnsFromSelectDistinctColumns(r,c);d.length!==s.length&&(re.debug("removing sorts from removed custom columns..."),this.setState({sorts:d})),(u.size!==i.size||m.size!==o.size)&&(re.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ut(n,p)||(re.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ut(r,g)||(re.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:e}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var t;re.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),(t=this.grid)==null||t.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;re.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(e){re.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){re.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){re.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:be.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){var t,n;re.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(t=e==null?void 0:e.columns)==null?void 0:t.join(", "))!=null?n:""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:F.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){re.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:F.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:St.DOWNLOAD_STATUS.INITIATING}):re.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s,i,o,r){const{canDownloadCsv:l}=this.props;l?(re.info("start table downloading",e,t,n,s,i,o,r),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s,i,o,r),{tableDownloadStatus:St.DOWNLOAD_STATUS.DOWNLOADING}))):re.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var e;(e=this.tableSaver)==null||e.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:St.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:St.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{Pe.isCanceled(n)||re.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:e,shownColumnTooltip:t}=this.state;x(e),x(t);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;x(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=e,c=o.get(t),d=r.get(t);x(c),x(d);const u=n.left+lt(c+d/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+lt(c+d/2,s,l-s),bottom:n.top+a*i,right:n.left+lt(c+d/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){var i,o,r;const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:""});return}const s=parseInt(e,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=t,a=o.get(e),c=r.get(e);if(a==null||c==null)return null;const d=Math.max(0,a);let u=c;a+c>l?u=l-a:a<0&&(u=c-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:d,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const C=n.columns[f];return C==null?null:h("div",{style:m,children:h(He,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(Fa,{model:n,column:C,onStatistics:()=>{var b;(b=this.tooltip)==null||b.update()}})},C.name)})}render(){var We,us,Mr,Dr,Nr,Fr,xr,Or,Ar;const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:c,advancedSettings:d,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:C,isSelectingPartition:b,isMenuShown:w,isReady:v,copyOperation:I,focusedFilterBarColumn:S,loadingText:R,loadingScrimProgress:M,loadingSpinnerShown:O,keyHandlers:P,mouseHandlers:W,shownColumnTooltip:B,hoverAdvancedFilter:N,shownAdvancedFilter:H,hoverSelectColumn:k,quickFilters:L,advancedFilters:_,partition:U,partitionFilters:q,partitionTable:J,partitionColumn:ne,searchFilter:ae,selectDistinctColumns:Ce,movedColumns:ce,movedRows:Se,formatter:_e,conditionalFormats:Ke,conditionalFormatPreview:Mt,conditionalFormatEditIndex:Xe,sorts:Ze,reverseType:Ut,customColumns:Ne,selectedRanges:Wn,isTableDownloading:nn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:$e,showSearchBar:Be,searchValue:mt,selectedSearchColumns:Dt,invertSearchColumns:Nt,aggregationSettings:pt,selectedAggregation:zn,rollupConfig:Ft,openOptions:xt,pendingSavePromise:$n,pendingSaveError:lo,pendingRowCount:ao,pendingDataErrors:co,pendingDataMap:ai,toastMessage:ci,frozenColumns:di,showOverflowModal:ui,overflowText:hi,overflowButtonTooltipProps:mi,isGotoRowShown:pi,gotoRow:uo,gotoRowError:ho}=this.state;if(!v)return null;const Gn=this.getTheme(),mo=this.getCachedFilter(t,L,_,q,ae),qn=g.getUserColumnWidths(),Hs=this.getCachedStateOverride(k,C,s,M,L,_,Ze,Ut,Ft,w),gi=f?f.top:0,fi=f?f.bottomViewport:0;let _s=null,Vs=null;a&&(_s=f?f.left:0,Vs=f?f.right:0);const po=f!=null&&f.width>0&&f.height>0,go=((us=(We=Ft==null?void 0:Ft.columns)==null?void 0:We.length)!=null?us:0)>0;let Ci=null;const fo=f?Math.min(Math.max(xn.minDebounce,Math.round(f.rowCount/200)),xn.maxDebounce):xn.maxDebounce;if(C&&S!=null&&f!=null){const{gridX:xe,gridY:gt,visibleColumnXs:bn,visibleColumnWidths:Us,width:hs}=f,Bt=bn.get(S),ct=Us.get(S);if(Bt!=null&&ct!=null){const nt=xe+Bt,sn=gt-((Mr=Gn.filterBarHeight)!=null?Mr:0),Kn=ct+1,Xn=((Dr=Gn.filterBarHeight)!=null?Dr:0)-1,Ei={top:sn,left:nt,minWidth:Math.min(Kn,hs-nt),height:Xn};let Wt="",ms=!0;const Yn=this.getModelColumn(S);x(Yn);const ps=L.get(Yn),wn=_.get(Yn);ps!=null&&(Wt=ps.text,ms=ps.filter!=null);const gs=L.size!==0||_.size!==0;Ci=h(Ra,{ref:this.filterInputRef,style:Ei,className:z({error:!ms,active:Wt!==""||wn!=null,"iris-grid-has-filter":gs}),isAdvancedFilterSet:wn!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:S})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(Nr=this.grid)==null?void 0:Nr.handleContextMenu,debounceMs:fo,value:Wt},S)}}let bi=null;if(R!=null){const xe=E("div",{className:"iris-grid-loading-status",children:[h("div",{className:z("iris-grid-loading-status-bar",{show:O}),children:R}),E("button",{type:"button",onClick:this.handleCancel,className:z("iris-grid-btn-cancel",{show:O}),children:[h(K,{icon:ti,transform:"down-1"}),"Cancel"]})]}),gt=f?f.gridY:0;bi=h("div",{className:"iris-grid-loading",style:{top:gt},children:xe})}let wi=null;B!=null&&f&&(wi=this.getColumnTooltip(B,f,r),(Fr=this.tooltip)==null||Fr.update());const Si=[];if(f&&C){const{gridX:xe,gridY:gt,visibleColumns:bn,visibleColumnXs:Us,visibleColumnWidths:hs}=f,{filterBarHeight:Bt}=Gn;for(let ct=0;ct<bn.length;ct+=1){const nt=bn[ct],sn=Us.get(nt),Kn=hs.get(nt),Xn=this.getModelColumn(nt);if(Xn!=null&&r.isFilterable(Xn)&&sn!=null&&Kn!=null&&Kn>0){const Wt=xe+sn+Kn-24,ms=gt-(Bt!=null?Bt:0)+2,Yn={position:"absolute",top:ms,left:Wt},wn=_.get(Xn)!=null,gs=nt===N||nt===S||wn,wo=h("div",{className:z("advanced-filter-button-container",{hidden:!gs}),style:Yn,children:gs&&h(Y,{kind:"ghost",className:z("btn-link-icon advanced-filter-button",{"filter-set":wn}),onClick:()=>{this.setState({shownAdvancedFilter:nt})},onContextMenu:ac=>{var kr;(kr=this.grid)==null||kr.handleContextMenu(ac)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:nt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:E("div",{className:"fa-layers",children:[h(K,{icon:jo,className:"filter-solid"}),h(K,{icon:Vi,className:"filter-light"})]})})},nt);Si.push(wo)}}}const vi=[];if(f){const{gridX:xe,visibleColumns:gt,visibleColumnXs:bn,visibleColumnWidths:Us,columnHeaderHeight:hs}=f;for(let Bt=0;Bt<gt.length;Bt+=1){const ct=gt[Bt],nt=bn.get(ct),sn=Us.get(ct);if(nt!=null&&sn!=null&&sn>0){const Kn=xe+nt,Xn=xe+nt+sn-20,Ei=C?{position:"absolute",top:hs,left:Xn,width:20,height:Gn.filterBarHeight}:{position:"absolute",top:0,left:Kn,width:sn,height:hs},Wt=this.getModelColumn(ct);if(Wt!=null){const ms=r.columns[Wt],Yn=_.get(Wt),{options:ps}=Yn||{},wn=F.getSortForColumn(r.sort,Wt),gs=wn?wn.direction:null,wo=h("div",{className:"advanced-filter-menu-container",style:Ei,children:h(fn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(ct),onExited:()=>{this.handleAdvancedMenuClosed(ct)},isShown:H===ct,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,ms,ps,gs,_e)})},ct);vi.push(wo)}}}}const Ti=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,Be,m,this.isTableSearchAvailable(),pi,d.size>0),Co=xt.map(xe=>{switch(xe.type){case be.CHART_BUILDER:return h(Aa,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},be.CHART_BUILDER);case be.VISIBILITY_ORDERING_BUILDER:return h(cs,{model:r,movedColumns:ce,userColumnWidths:qn,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},be.VISIBILITY_ORDERING_BUILDER);case be.CONDITIONAL_FORMATTING:return h(zm,{rules:Ke,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case be.CONDITIONAL_FORMATTING_EDIT:return x(r.columns),x(this.handleConditionalFormatEditorUpdate),h(fp,{columns:r.columns,rule:Mt,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case be.CUSTOM_COLUMN_BUILDER:return h(wr,{model:r,customColumns:Ne,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},be.CUSTOM_COLUMN_BUILDER);case be.ROLLUP_ROWS:return h(Sr,{model:r,onChange:this.handleRollupChange,config:Ft},be.ROLLUP_ROWS);case be.AGGREGATIONS:return h(vm,{settings:pt,isRollup:go,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case be.AGGREGATION_EDIT:return zn&&h(Em,{aggregation:zn,columns:r.originalColumns,onChange:this.handleAggregationChange});case be.TABLE_EXPORTER:return h(St,{model:r,name:l,userColumnWidths:qn,movedColumns:ce,isDownloading:nn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:$e!=null?$e:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Wn},be.TABLE_EXPORTER);case be.SELECT_DISTINCT:return h(Ha,{model:r,selectDistinctColumns:Ce,onChange:this.handleSelectDistinctChanged});case be.ADVANCED_SETTINGS:return h(vr,{items:d,onChange:u});default:throw Error(`Unexpected option type ${xe.type}`)}}),bo=this.getCachedHiddenColumns(te.getHiddenColumns(qn));return E("div",{className:"iris-grid",role:"presentation",children:[E("div",{className:"iris-grid-column",children:[e!=null&&h("div",{className:"iris-grid-bar",children:e}),h(rt,{in:b,timeout:It.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:J&&ne&&U!=null&&h(Pa,{table:J,getFormattedString:(xe,gt,bn)=>r.displayString(xe,gt,bn),columnName:ne.name,partition:U,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(rt,{in:Be,timeout:It.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(xi,{value:mt,selectedColumns:Dt,invertSelection:Nt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),E("div",{className:"grid-wrapper",ref:xe=>{this.gridWrapper=xe},children:[h(ks,{ref:xe=>{this.grid=xe},isStickyBottom:!Ae(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:P,mouseHandlers:W,movedColumns:ce,movedRows:Se,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:Hs,theme:Gn}),h(Ig,{isOpen:ui,text:hi,onClose:this.handleOverflowClose}),po&&h(Da,{model:r,modelColumns:r.columns,top:gi,bottom:fi,left:_s,right:Vs,filter:mo,formatter:_e,sorts:Ze,reverseType:Ut,movedColumns:ce,customColumns:Ne,hiddenColumns:bo,alwaysFetchColumns:this.getAlwaysFetchColumns(c,r.columns,ce,r.floatingLeftColumnCount,r.floatingRightColumnCount,(Or=(xr=this.grid)==null?void 0:xr.state.draggingColumn)==null?void 0:Or.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,Ne),Ke,Mt,((Ar=xt[xt.length-1])==null?void 0:Ar.type)===be.CONDITIONAL_FORMATTING_EDIT&&Xe!=null?Xe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ft,pt),totalsConfig:this.getModelTotalsConfig(r.columns,Ft,pt),selectDistinctColumns:Ce,pendingRowCount:ao,pendingDataMap:ai,frozenColumns:di}),!w&&h("div",{className:"grid-settings-button",children:h(Y,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${l}`,onClick:this.handleMenu,icon:h(K,{icon:gd,transform:"up-1"}),tooltip:"Table Options"})}),Ci,bi,Si,wi,vi,mi&&this.getOverflowButtonTooltip(mi)]}),h(Dg,{model:r,isShown:pi,gotoRow:uo,gotoRowError:ho,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(Kh,{error:lo,isSaving:$n!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:co,pendingDataMap:ai,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(mm,{children:ci}),h(Ls,{model:r,copyOperation:I!=null?I:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(Ps,{ref:xe=>{this.tableSaver=xe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:tt===St.DOWNLOAD_STATUS.DOWNLOADING,formatter:_e})]}),h(rt,{in:w,timeout:It.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:E(wu,{children:[h(el,{title:"Table Options",onClose:this.handleMenuClose,children:h(ma,{onSelect:xe=>this.handleMenuSelect(Ti[xe]),items:Ti})}),Co.map((xe,gt)=>h(el,{title:xt[gt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:xe},xt[gt].type))]})})}),h(oe,{actions:this.contextActions})]})}};let li=xn;li.minDebounce=150;li.maxDebounce=500;li.loadingSpinnerDelay=800;li.defaultProps={children:null,advancedFilters:new Map,advancedSettings:new Map,alwaysFetchColumns:[],conditionalFormats:[],customColumnFormatMap:new Map,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:[],movedRows:[],inputFilters:[],customFilters:[],onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:new Map,selectDistinctColumns:[],sorts:[],reverseType:F.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:ic,rollupConfig:void 0,userColumnWidths:new Map,userRowHeights:new Map,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:new Map,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:_n.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:[],decimalFormatOptions:D.exports.shape({defaultFormatString:D.exports.string}),integerFormatOptions:D.exports.shape({defaultFormatString:D.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Na,canToggleSearch:!0};class Ag extends Error{constructor(t,n){super(`${n} can't be empty (on pending row ${t+1})`),this.isMissingKey=!0,this.rowIndex=t,this.columnName=n}}const kg=ee.module("ColumnHeaderGroup");function Al(e){return e instanceof oc}class oc{constructor({name:t,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=Re(r=>{const l=this.childIndexes.flat(),a=V.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&kg.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=t,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const Le=ee.module("IrisGridTableModel"),Lg=150,Pg=0;function ki(e){return e.table!==void 0}const $o=class extends he{constructor(e,t=new Zt,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=Re(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=Re(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=ls((s,i,o)=>{if(i<s){Le.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){Le.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},Le.debug2("setViewport",this.viewport),this.applyViewport()},Lg),this.applyViewport=ls(()=>{if(!this.viewport)return;Le.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},Pg,{leading:!1}),this.getCachedFormattedString=vt((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=vt(os.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=Re((s,i)=>{const o=i-s,r=Math.max(0,s-o*$o.ROW_BUFFER_PAGES),l=i+o*$o.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=Re((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var d;const{data:c}=l;for(let u=0;u<o;u+=1)c.has(u)||(r.has(a)||r.set(a,[]),(d=r.get(a))==null||d.push(new Ag(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(T.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(T.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(T.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(T.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(T.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(T.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(T.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(T.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(T.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(T.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(T.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(T.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ee(he.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ee(he.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Ee(he.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Ee(he.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Ee(he.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Ee(he.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var e,t,n;return this.table.size+this.pendingNewRowCount+((n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0)}get pendingDataErrors(){var e,t;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(t=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?t:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!te.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!te.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ee(he.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new Ee(he.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get floatingTopRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop&&(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){var n,s,i;if(((n=this.pendingStringData[e])==null?void 0:n[t])!==void 0)return this.pendingStringData[e][t];if(((s=this.formattedStringData[e])==null?void 0:s[t])===void 0){const o=this.valueForCell(e,t);if(o==null)return null;const r=(i=this.totalsColumn(e,t))!=null?i:this.columns[e],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const d=this.formatForCell(e,t);(d==null?void 0:d.formatString)!=null&&(a=d)}const c=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(e,t,c)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(F.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){var i;const s=this.dataForCell(e,t);if(s){const{format:o,value:r}=s;if(r==null||r==="")return x(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(t))return x(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(e,t))!=null?i:this.columns[e];if(F.isDateType(l.type)||l.name==="Date")return x(n.dateColor),n.dateColor;if(F.isNumberType(l.type))return r>0?(x(n.positiveNumberColor),n.positiveNumberColor):r<0?(x(n.negativeNumberColor),n.negativeNumberColor):(x(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return x(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){var n,s;return(s=(n=this.formatForCell(e,t))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return F.isNumberType(n)?"right":F.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){var n,s;return(s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(e,t=0){var s;const n=this.columnAtDepth(e,t);return Al(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(Al(n))return n}getColumnHeaderParentGroup(e,t){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:"")}columnAtDepth(e,t=0){var o;if(t===0)return this.columns[e];const n=(o=this.columns[e])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}get movedColumns(){var i;let e=[];const t=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=V.getVisibleIndex(l,e);e=V.moveItem(a,r,e)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(e);e=V.moveRange(a,r,e)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let c;if(a!=null)c=V.getVisibleIndex(a,e);else{const d=this.columnHeaderGroupMap.get(l);if(!d)throw new Error(`Unknown column ${l} in group ${r.name}`);[,c]=d.getVisibleRange(e)}for(let d=1;d<r.children.length;d+=1){const u=r.children[d],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(e)[0]<c?c-m.childIndexes.length+1:c+1;n(u,f),c=f+m.childIndexes.length-1}else if(p!=null){const f=V.getVisibleIndex(p,e)<c?c:c+1;t(u,f),c=f}}})}return e}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var e,t;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((e=this.layoutHints)==null?void 0:e.columnGroups),(t=this._columnHeaderMaxDepth)!=null?t:1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}setColumnHeaderGroups(e){if(e===this._columnHeaderGroups||(this._columnHeaderGroups=e!=null?e:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!e||e.length===0))return;const t=new Map(e.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let c=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=t.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),c=Math.max(c,g.depth+1)}else if(p!=null)a.push(p),c=Math.max(c,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const d=new oc({...o,depth:c,childIndexes:a});return this.columnHeaderGroupMap.set(r,d),o.children.forEach(u=>this.columnHeaderParentMap.set(u,d)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,d.depth+1),d},i=new Set;e.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(e){var l,a,c,d,u,m,p,g,f,C,b,w,v,I;const t=(c=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?c:0,n=(u=(d=this.totals)==null?void 0:d.showOnTop)!=null?u:!1,s=this.totalsRow(e);if(s!=null){const S=(m=this.totals)==null?void 0:m.operationOrder[s];return x(S),(g=(p=this.totalsDataMap)==null?void 0:p.get(S))!=null?g:null}const i=this.pendingRow(e);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(b=(C=this.viewportData)==null?void 0:C.offset)!=null?b:0,r=(n?e-t:e)-o;return(I=(v=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:v[r])!=null?I:null}totalsColumn(e,t){var r,l,a,c;const n=this.totalsRow(t);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:we.SUM,o=this.columns[e];return(c=this.totalsTable)==null?void 0:c.columns.find(d=>{var u;return d.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&d.name===o.name})}totalsRow(e){var i,o,r,l,a;const t=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){var n;return(n=this.row(t))==null?void 0:n.data.get(e)}formatForCell(e,t){var n;return(n=this.dataForCell(e,t))==null?void 0:n.format}valueForCell(e,t){var s;const n=this.dataForCell(e,t);if(n)return(s=n.value)!=null?s:null}copyViewportData(e){if(e==null){Le.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){var l,a,c,d,u;if(e==null){Le.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){Le.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:we.SUM,r=(c=this.totals)==null?void 0:c.operationMap;for(let m=0;m<t.length;m+=1){const p=t[m],[g,f=(u=(d=r==null?void 0:r[g])==null?void 0:d[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:C}=s.get(f),b=this.columns.findIndex(w=>w.name===g);C.set(b,{value:i.get(p),format:i.getFormat(p)})}Le.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);x(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){Le.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new Ee(he.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(Le.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Ee(he.EVENT.UPDATED));return}this.totalsTablePromise=Pe.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{Pe.isCanceled(t)||(Le.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Ee(he.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){Le.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(e,t,n){Le.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(Le.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(Le.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=i=>i,s=!0){if(this.subscription==null)throw new Error("No subscription available");const i=s?j.consolidate(e):e;if(!te.isValidSnapshotRanges(i))throw new Error(`Invalid snapshot ranges ${e}`);const o=new Set,r=[],l=new Set;for(let m=0;m<i.length;m+=1){const p=i[m];x(p.endRow),x(p.startRow);for(let g=p.startRow;g<=p.endRow&&g<this.floatingTopRowCount;g+=1)o.add(g);p.endRow>=this.floatingTopRowCount&&p.startRow<=this.floatingTopRowCount+this.table.size&&r.push(new j(p.startColumn,Math.min(Math.max(0,p.startRow-this.floatingTopRowCount)),p.endColumn,Math.min(Math.max(0,p.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let g=Math.max(p.startRow,this.floatingTopRowCount+this.table.size);g<=p.endRow&&g<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;g+=1)l.add(g)}const a=te.columnsFromRanges(i,this.columns),c=[];t&&c.push(a.map(m=>m.name));const d=[...o].sort();for(let m=0;m<d.length;m+=1){const p=d[m],g=a.map(f=>{const C=this.getColumnIndexByName(f.name);return x(C),n(this.valueForCell(C,p),f)});t&&g.push(this.textForRowFooter(p)),c.push(g)}if(r.length>0){const m=te.rangeSetFromRanges(r),p=await this.subscription.snapshot(m,a);c.push(...p.rows.map(g=>a.map(f=>n(g.get(f),f))))}const u=[...l].sort();for(let m=0;m<u.length;m+=1){const p=u[m],g=a.map(f=>{const C=this.getColumnIndexByName(f.name);return x(C),n(this.valueForCell(C,p),f)});t&&g.push(this.textForRowFooter(p)),c.push(g)}return c}async textSnapshot(e,t=!1,n=s=>`${s}`){return Le.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n,!1)).map(i=>i.join(" ")).join(`
32
32
  `)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t!=null&&t.close()}}isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){var t,n;return e<((n=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(e){return this.inputTable!=null&&j.isBounded(e)&&(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new j(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new j(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new j(e,t,e,t)],n)}async setValueForRanges(e,t){var n;if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const s=new Set,i=[];j.forEachCell(e,(c,d)=>{const u=this.columns[c];if(s.add(u),i[c]===void 0){const m=F.makeValue(u.type,t,this.formatter.timeZone);i[c]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(c,d,i[c])});const o=this.getPendingAreaRange(),r=e.map(c=>j.intersection(o,c)).filter(c=>c!=null).map(c=>(x(c),j.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const c=new Map(this.pendingNewDataMap);j.forEachCell(r,(d,u)=>{c.has(u)||c.set(u,{data:new Map});const m=this.columns[d],p=c.get(u);x(p);const{data:g}=p,f=new Map(g),C=F.makeValue(m.type,t,this.formatter.timeZone);C!=null?f.set(d,{value:C}):f.delete(d),f.size>0?c.set(u,{...p,data:f}):c.delete(u)}),this.pendingDataMap=c}this.dispatchEvent(new Ee(he.EVENT.UPDATED));const l=this.getTableAreaRange(),a=e.map(c=>j.intersection(l,c)).filter(c=>c!=null);if(a.length>0){const d=(await this.snapshot(a.map(m=>{var p,g;return new j(null,(p=m==null?void 0:m.startRow)!=null?p:null,null,(g=m==null?void 0:m.endRow)!=null?g:null)}))).map(m=>{const p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return s.forEach(g=>{p[g.name]=F.makeValue(g.type,t,this.formatter.timeZone)}),p}),u=await((n=this.inputTable)==null?void 0:n.addRows(d));Le.debug("setValueForRanges(",e,",",t,") set tableRanges",a,"result",u)}j.forEachCell(e,(c,d)=>{const u=i[c];x(u),this.cacheFormattedValue(c,d,u)})}catch(s){Le.error("Unable to set ranges",e,t,s)}finally{j.forEachCell(e,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(e=[]){var t;if(Le.debug("setValues(",e,")"),!e.every(n=>{var s,i;return this.isEditableRange(j.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${e}`);try{const n=new Map(this.pendingNewDataMap);e.forEach(l=>{var f,C;const{text:a}=l,c=(f=l.column)!=null?f:l.x,d=(C=l.row)!=null?C:l.y,u=this.columns[c],m=F.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(c,d,p);const g=this.pendingRow(d);if(g!=null){n.has(g)||n.set(g,{data:new Map});const b=n.get(g);x(b);const{data:w}=b,v=new Map(w);m!=null?v.set(c,{value:m}):v.delete(c),v.size>0?n.set(g,{...b,data:v}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Ee(he.EVENT.UPDATED));const s=e.reduce((l,a)=>{var d,u;const c=(d=a.row)!=null?d:a.y;return l.has(c)||l.set(c,[]),(u=l.get(c))==null||u.push(a),l},new Map),i=j.consolidate(e.map(l=>{var a,c;return j.makeCell((a=l.column)!=null?a:l.x,(c=l.row)!=null?c:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>j.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(d=>(x(d),new j(null,d.startRow,null,d.endRow))))).map((d,u)=>{let m=null,p=u;for(let C=0;C<r.length;C+=1){const b=r[C];x(b);const w=j.rowCount([b]);if(p<w){x(b.startRow),m=b.startRow+p;break}p-=w}const g={};for(let C=0;C<this.columns.length;C+=1)g[this.columns[C].name]=d[C];x(m);const f=s.get(m);return f!=null&&f.forEach(C=>{var w;const b=this.columns[(w=C.column)!=null?w:C.x];g[b.name]=F.makeValue(b.type,C.text,this.formatter.timeZone)}),g});Le.info("setValues setting tableRanges",r);const c=await((t=this.inputTable)==null?void 0:t.addRows(a));Le.info("setValues set tableRanges",r,"SUCCESS",c)}e.forEach(l=>{var g,f;const{text:a}=l,c=(g=l.column)!=null?g:l.x,d=(f=l.row)!=null?f:l.y,u=this.columns[c],m=F.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(c,d,p)})}finally{e.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var e,t,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(o=>{const r={};o.data.forEach(({value:l},a)=>{const c=this.columns[a];r[c.name]=l}),s.push(r)});const i=await((e=this.inputTable)==null?void 0:e.addRows(s));Le.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(t=this.viewport)==null?void 0:t.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ee(he.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);x(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(d=>j.intersection(n,d)).filter(d=>d!=null).map(d=>(x(d),j.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const d=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];x(m.startRow),x(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)d.delete(p)}this.pendingNewDataMap=d,this.formattedStringData=[],this.dispatchEvent(new Ee(he.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ee(he.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(d=>j.intersection(i,d)).filter(d=>d!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(d=>(x(d),new j(0,d.startRow,t.length-1,d.endRow)))),this.table.copy()]),c=r.map(d=>{const u=[];for(let m=0;m<t.length;m+=1){const p=t[m],g=d[m],f=F.makeFilterRawValue(p.type,g),C=p.filter().eq(f);u.push(C)}return u.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((d,u)=>{var m;return(m=d==null?void 0:d.or(u))!=null?m:u});l.applyFilter([c]),l.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return F.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let Rr=$o;Rr.ROW_BUFFER_PAGES=1;const Mn=ee.module("IrisGridTableModel");class Hg extends Rr{constructor(t,n=new Zt,s=null){super(t,n,s),this.getMemoizedFrontColumns=Re(i=>i!=null?i:[]),this.getMemoizedBackColumns=Re(i=>i!=null?i:[]),this.getMemoizedFrozenColumns=Re((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:[]}),this.getCachedFilterableColumnSet=Re(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var t;return this.getMemoizedFrontColumns((t=this.layoutHints)==null?void 0:t.frontColumns)}get backColumns(){var t;return this.getMemoizedBackColumns((t=this.layoutHints)==null?void 0:t.backColumns)}get frozenColumns(){var t;return this.getMemoizedFrozenColumns((t=this.layoutHints)==null?void 0:t.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(t){if(Mn.debug2("set customColumns",t,this.customColumnList,t===this.customColumnList),this.customColumnList.length===0&&t.length===0){Mn.debug("Ignore empty initial customColumns"),this.customColumnList=t;return}if(this.customColumnList===t){Mn.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=t,this.table.applyCustomColumns([...t,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(t){if(Mn.debug2("set formatColumns",t,this.formatColumnList,t===this.formatColumnList),this.formatColumnList.length===0&&t.length===0){Mn.debug("Ignore empty initial formatColumns"),this.formatColumnList=t;return}if(this.formatColumnList===t){Mn.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=t,this.table.applyCustomColumns([...this.customColumns,...t]),this.applyViewport()}updateFrozenColumns(t){this.userFrozenColumns=t,this.dispatchEvent(new Ee(he.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(t){if(Mn.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Ee(he.EVENT.UPDATED));return}this.totalsTablePromise=Pe.makeCancelable(this.table.getTotalsTable(t),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{Pe.isCanceled(n)||(Mn.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ee(he.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns).has(t)}async export(){return this.table.freeze()}columnStatistics(t){return this.table.getColumnStatistics(t)}isColumnMovable(t){const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(t)}isColumnFrozen(t){return this.frozenColumns.includes(this.columns[t].name)}async delete(t){var u;if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);x(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=t.map(m=>j.intersection(s,m)).filter(m=>m!=null).map(m=>(x(m),j.offset(m,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const m=new Map(super.pendingDataMap);for(let p=0;p<i.length;p+=1){const g=i[p];x(g.startRow),x(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Ee(he.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ee(he.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=t.map(m=>j.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(x(m),new j(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),d=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],C=m[g],b=F.makeFilterRawValue(f.type,C),w=f.filter().eq(b);p.push(w)}return p.reduce((g,f)=>{var C;return(C=g==null?void 0:g.and(f))!=null?C:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([d]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}}class _g extends Rr{constructor(){super(...arguments),this.getCachedFilterableColumnSet=Re((t,n)=>new Set(((n==null?void 0:n.length)>0?n:t).map(s=>t.findIndex(i=>s.name===i.name))))}applyBufferedViewport(t,n,s){this.table.setViewport(t,n,s)}textForCell(t,n){const s=this.columns[t],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(t,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(t,n)}extractViewportRow(t,n){const{isExpanded:s,hasChildren:i,depth:o}=t;return{...super.extractViewportRow(t,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(t,n,s){var l,a;x(this.viewport),x(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(c=>c.name));const r=new j(0,(l=this.viewportData)==null?void 0:l.offset,i.length,this.viewportData.offset+this.viewportData.rows.length);for(let c=0;c<t.length;c+=1){const d=j.intersection(r,t[c]);x(d),x(d.startRow),x(d.endRow);for(let u=d.startRow;u<=d.endRow;u+=1){const m=[],p=this.viewportData.rows[u-this.viewportData.offset];x(d.startColumn),x(d.endColumn);for(let g=d.startColumn;g<=d.endColumn;g+=1)x(s),m.push(s((a=p.data.get(g))==null?void 0:a.value,this.columns[g]));o.push(m)}}return o}get groupedColumns(){return[]}get hasExpandableRows(){return!0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(t)}isColumnMovable(t){return t>=this.groupedColumns.length}isRowExpandable(t){var s;const n=this.row(t);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(t){var s;const n=this.row(t);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(t,n){this.table.setExpanded(t,n)}depthForRow(t){var s;const n=this.row(t);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Dn=ee.module("IrisGridProxyModel");function ko(e,t,n){return F.isTreeTable(e)?new _g(e,t):new Hg(e,t,n)}class Vg extends he{constructor(t,n=new Zt,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>ze(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>ze(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(ze(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>ze(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>Ae(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>(Ae(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Ae(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Ae(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Ae(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Ae(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=ko(t,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(t){Dn.debug2("handleModelEvent",t);const{detail:n,type:s}=t;this.dispatchEvent(new Ee(s,{detail:n}))}setModel(t){Dn.debug("setModel",t);const n=this.model;n!==this.originalModel&&n.close(),this.model=t,this.listenerCount>0&&this.addListeners(t),this.dispatchEvent(new Ee(he.EVENT.COLUMNS_CHANGED,{detail:t.columns})),ki(t)&&this.dispatchEvent(new Ee(he.EVENT.TABLE_CHANGED,{detail:t.table}))}setNextModel(t){Dn.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=Pe.makeCancelable(t,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(Pe.isCanceled(n)){Dn.debug2("setNextModel cancelled");return}Dn.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ee(he.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(t){const n=Object.keys(he.EVENT);for(let s=0;s<n.length;s+=1)t.addEventListener(n[s],this.handleModelEvent)}removeListeners(t){const n=Object.keys(he.EVENT);for(let s=0;s<n.length;s+=1)t.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(t){return this.model.isColumnFrozen(t)}get hasExpandableRows(){return ze(this.model)?this.model.hasExpandableRows:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get movedColumns(){return this.model.movedColumns}get movedRows(){return this.model.movedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(t){return this.model.updateFrozenColumns(t)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(t){this.model.filter=t}get formatter(){return this.model.formatter}set formatter(t){this.model.formatter=t}get sort(){return this.model.sort}set sort(t){this.model.sort=t}get customColumns(){return this.model.customColumns}set customColumns(t){this.model.customColumns=t}get formatColumns(){return this.model.formatColumns}set formatColumns(t){this.model.formatColumns=t}get rollupConfig(){return this.rollup}set rollupConfig(t){if(Dn.debug("set rollupConfig",t),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ut(t,this.rollup))return;this.rollup=t;let n=Promise.resolve(this.originalModel);ki(this.originalModel)&&t!=null&&(n=this.originalModel.table.rollup(t).then(s=>ko(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(t){if(Dn.debug("set selectDistinctColumns",t),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(t===this.selectDistinctColumns||t.length===0&&this.selectDistinctColumns.length===0){Dn.debug("Ignore same selectDistinctColumns",t);return}this.selectDistinct=t;const n=t.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);ki(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>ko(i,this.formatter))),this.setNextModel(s)}get table(){if(ki(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(t){this.model.totalsConfig=t}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ae(this.model)&&this.model.isEditable}export(){if(F.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(t){if(F.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(t)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(t){this.model.pendingDataMap=t}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(t){this.model.pendingRowCount=t}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(t){return this.model.getColumnIndexByName(t)}}class Ug{static async makeModel(t,n=new Zt){let s=null;return!F.isTreeTable(t)&&t.hasInputTable&&(s=await t.inputTable()),new Vg(t,n,s)}}const an=ee.module("TableViewportUpdater"),Bg=150,js=class extends y.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=Re((e,t,n)=>{const s=n-t,i=Math.max(0,t-s*js.ROW_BUFFER_PAGES),o=n+s*js.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=Re((e,t,n,s)=>{if(t==null||n==null)return null;const i=n-t,o=Math.max(0,t-i*js.COLUMN_BUFFER_PAGES),r=Math.min(n+i*js.COLUMN_BUFFER_PAGES,e.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const c=V.getModelIndex(a,s);l.push(e.columns[c])}return l}),this.updateViewport=ls((e,t,n,s,i)=>{if(t<e){an.error("Invalid viewport",e,t);return}if(e===0&&t===0){an.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,e,t),c=i!=null?i:this.getViewportColumns(r,n,s,o);if(an.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",c),this.subscription==null){an.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,c);const{onSubscription:d}=this.props;d(this.subscription)}else an.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,c)},Bg)}componentDidMount(){const{top:e,bottom:t,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(e,t,n,s,l)}componentDidUpdate(e){const{top:t,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:c}=this.props,d=r!==e.filters,u=l!==e.sorts,m=a!==e.customColumns,p=o!==e.table;(d||u||m||p)&&this.closeSubscription(),(d||p)&&(an.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(an.debug("update table sort",l),o.applySort(l)),(m||p)&&(an.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(t,n,s,i,c)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(an.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:e}=this.props;e()}this.updateViewport.cancel()}render(){return null}};let Ir=js;Ir.ROW_BUFFER_PAGES=3;Ir.COLUMN_BUFFER_PAGES=1;Ir.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const Ss=ee.module("TreeTableViewportUpdater"),Wg=150,rc=class extends y.exports.PureComponent{constructor(e){super(e),this.updateViewport=ls((t,n)=>{if(n<t){Ss.error("Invalid viewport",t,n);return}if(t===0&&n===0){Ss.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-t,r=Math.max(0,t-o*3),l=n+o*3+1;if(Ss.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(T.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},Wg),this.listenerCleanup=null}componentDidMount(){const{top:e,bottom:t,table:n,filters:s,sorts:i}=this.props;Ss.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(e,t)}componentDidUpdate(e){const{top:t,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==e.filters&&(Ss.debug("update table filter",i),s.applyFilter(i)),o!==e.sorts&&(Ss.debug("update table sort",o),s.applySort(o)),this.updateViewport(t,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let lc=rc;lc.UPDATE_INTERVAL=1e3;lc.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:rc.UPDATE_INTERVAL};ee.setLogLevel(parseInt("2",10));const Rs=ee.module("EmbedGrid.App"),zg=[T.VariableType.TABLE,T.VariableType.TREETABLE,T.VariableType.PANDAS];async function $g(e,t){Rs.info(`Fetching table ${t}...`);const n=await eh(e,t);if(!zg.includes(n.type))throw new Error(`Unsupported type '${n.type}' for variable named '${t}'`);return await e.getObject(n)}function Gg(){const[e,t]=y.exports.useState(),[n,s]=y.exports.useState(),[i,o]=y.exports.useState(),[r,l]=y.exports.useState(),[a,c]=y.exports.useState(!0),d=y.exports.useMemo(()=>new URLSearchParams(window.location.search),[]),u=d.get("canCopy")!=null,m=d.get("canDownloadCsv")!=null;y.exports.useEffect(function(){async function f(){try{const C=d.get("name");if(C==null)throw new Error("No name param provided");const b=new URL("/jsapi",`${window.location}`),w=`${b.protocol}//${b.host}`;Rs.debug("Starting connection...");const v=new T.IdeConnection(w);Rs.debug("Loading table",C,"...");const I=await $g(v,C);Rs.debug("Creating model...");const S=await Ug.makeModel(I);t(S),Rs.debug("Table successfully loaded!")}catch(C){Rs.error("Unable to load table",C),s(`${C}`)}c(!1)}f()},[d]),y.exports.useEffect(function(){function f(C){const{command:b,value:w}=C.data;switch(b){case"filter":{const I=w.map(({name:S,value:R})=>{const M=e==null?void 0:e.columns.find(O=>O.name===S);if(M==null)throw new Error(`Could not find column named ${S}`);return{name:S,value:R,type:F.getNormalizedType(M.type)}});o(I);break}case"sort":{const I=w.map(({name:S,direction:R})=>{const M=e==null?void 0:e.columns.find(O=>O.name===S);if(M==null)throw new Error(`Could not find column named ${S}`);return R==="DESC"?M.sort().desc():M.sort().asc()});l(I);break}}}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[e]);const p=e!=null;return E("div",{className:"App",children:[p&&h(li,{canCopy:u,canDownloadCsv:m,model:e,inputFilters:i,sorts:r}),!p&&h(ua,{isLoaded:p,isLoading:a,errorMessage:n!=null?n:null}),h(jd,{})]})}Go.render(h(Gg,{}),document.getElementById("root"));
33
- //# sourceMappingURL=index.bbae6f3c.js.map
33
+ //# sourceMappingURL=index.86951514.js.map